#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
#include "base/callback.h"
#include "base/callback_list.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/managed_mode/managed_users.h"
#include "components/keyed_service/core/keyed_service.h"
#include "sync/api/syncable_service.h"
class PrefService;
namespace base {
class DictionaryValue;
class Value;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
class ManagedUserSharedSettingsService : public KeyedService,
public syncer::SyncableService {
public:
typedef base::Callback<void(const std::string& ,
const std::string& )> ChangeCallback;
typedef base::CallbackList<
void(const std::string& , const std::string& )>
ChangeCallbackList;
explicit ManagedUserSharedSettingsService(PrefService* prefs);
virtual ~ManagedUserSharedSettingsService();
const base::Value* GetValue(const std::string& mu_id, const std::string& key);
void SetValue(const std::string& mu_id,
const std::string& key,
const base::Value& value);
scoped_ptr<ChangeCallbackList::Subscription> Subscribe(
const ChangeCallback& cb);
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
void SetValueInternal(const std::string& mu_id,
const std::string& key,
const base::Value& value,
bool acknowledged);
static syncer::SyncData CreateSyncDataForSetting(const std::string& mu_id,
const std::string& key,
const base::Value& value,
bool acknowledged);
virtual void Shutdown() OVERRIDE;
virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
scoped_ptr<syncer::SyncErrorFactory> error_handler) 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;
private:
friend class ManagedUserSharedSettingsUpdate;
scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
scoped_ptr<syncer::SyncErrorFactory> error_handler_;
ChangeCallbackList callbacks_;
PrefService* prefs_;
};
#endif