#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "chrome/browser/extensions/app_sync_bundle.h"
#include "chrome/browser/extensions/extension_sync_bundle.h"
#include "chrome/browser/extensions/pending_enables.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/common/extension.h"
#include "sync/api/string_ordinal.h"
#include "sync/api/sync_change.h"
#include "sync/api/syncable_service.h"
class ExtensionErrorUI;
class ExtensionSyncData;
class Profile;
namespace base {
class SequencedTaskRunner;
}
namespace extensions {
class AppSyncData;
class ExtensionPrefs;
class ExtensionSyncData;
}
namespace syncer {
class SyncErrorFactory;
}
class ExtensionSyncService : public syncer::SyncableService,
public KeyedService {
public:
ExtensionSyncService(Profile* profile,
extensions::ExtensionPrefs* extension_prefs,
ExtensionService* extension_service);
virtual ~ExtensionSyncService();
static ExtensionSyncService* Get(Profile* profile);
const extensions::ExtensionPrefs& extension_prefs() const {
return *extension_prefs_;
}
virtual void SyncExtensionChangeIfNeeded(
const extensions::Extension& extension);
virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
virtual syncer::SyncDataList GetAllSyncData(
syncer::ModelType type) const OVERRIDE;
virtual syncer::SyncError ProcessSyncChanges(
const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) OVERRIDE;
extensions::ExtensionSyncData GetExtensionSyncData(
const extensions::Extension& extension) const;
extensions::AppSyncData GetAppSyncData(
const extensions::Extension& extension) const;
std::vector<extensions::ExtensionSyncData> GetExtensionSyncDataList() const;
std::vector<extensions::AppSyncData> GetAppSyncDataList() const;
bool ProcessExtensionSyncData(
const extensions::ExtensionSyncData& extension_sync_data);
bool ProcessAppSyncData(const extensions::AppSyncData& app_sync_data);
syncer::SyncChange PrepareToSyncUninstallExtension(
const extensions::Extension* extension,
bool extensions_ready);
void ProcessSyncUninstallExtension(const std::string& extension_id,
const syncer::SyncChange& sync_change);
void SyncEnableExtension(const extensions::Extension& extension);
void SyncDisableExtension(const extensions::Extension& extension);
void SyncOrderingChange(const std::string& extension_id);
void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare);
private:
bool IsCorrectSyncType(const extensions::Extension& extension,
syncer::ModelType type)
const;
bool IsPendingEnable(const std::string& extension_id) const;
bool ProcessExtensionSyncDataHelper(
const extensions::ExtensionSyncData& extension_sync_data,
syncer::ModelType type);
Profile* profile_;
extensions::ExtensionPrefs* extension_prefs_;
ExtensionService* extension_service_;
extensions::AppSyncBundle app_sync_bundle_;
extensions::ExtensionSyncBundle extension_sync_bundle_;
extensions::PendingEnables pending_app_enables_;
extensions::PendingEnables pending_extension_enables_;
scoped_ptr<ExtensionErrorUI> extension_error_ui_;
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
syncer::SyncableService::StartSyncFlare flare_;
DISALLOW_COPY_AND_ASSIGN(ExtensionSyncService);
};
#endif