| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 class SupervisedUserSettingsService : public KeyedService, | 52 class SupervisedUserSettingsService : public KeyedService, |
| 53 public syncer::SyncableService, | 53 public syncer::SyncableService, |
| 54 public PrefStore::Observer { | 54 public PrefStore::Observer { |
| 55 public: | 55 public: |
| 56 // A callback whose first parameter is a dictionary containing all supervised | 56 // A callback whose first parameter is a dictionary containing all supervised |
| 57 // user settings. If the dictionary is NULL, it means that the service is | 57 // user settings. If the dictionary is NULL, it means that the service is |
| 58 // inactive, i.e. the user is not supervised. | 58 // inactive, i.e. the user is not supervised. |
| 59 typedef base::Callback<void(const base::DictionaryValue*)> SettingsCallback; | 59 typedef base::Callback<void(const base::DictionaryValue*)> SettingsCallback; |
| 60 | 60 |
| 61 SupervisedUserSettingsService(); | 61 SupervisedUserSettingsService(); |
| 62 virtual ~SupervisedUserSettingsService(); | 62 ~SupervisedUserSettingsService() override; |
| 63 | 63 |
| 64 // Initializes the service by loading its settings from a file underneath the | 64 // Initializes the service by loading its settings from a file underneath the |
| 65 // |profile_path|. File I/O will be serialized via the | 65 // |profile_path|. File I/O will be serialized via the |
| 66 // |sequenced_task_runner|. If |load_synchronously| is true, the settings will | 66 // |sequenced_task_runner|. If |load_synchronously| is true, the settings will |
| 67 // be loaded synchronously, otherwise asynchronously. | 67 // be loaded synchronously, otherwise asynchronously. |
| 68 void Init(base::FilePath profile_path, | 68 void Init(base::FilePath profile_path, |
| 69 base::SequencedTaskRunner* sequenced_task_runner, | 69 base::SequencedTaskRunner* sequenced_task_runner, |
| 70 bool load_synchronously); | 70 bool load_synchronously); |
| 71 | 71 |
| 72 // Initializes the service by loading its settings from the |pref_store|. | 72 // Initializes the service by loading its settings from the |pref_store|. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 102 | 102 |
| 103 // Sets the setting with the given |key| to a copy of the given |value|. | 103 // Sets the setting with the given |key| to a copy of the given |value|. |
| 104 void SetLocalSettingForTesting(const std::string& key, | 104 void SetLocalSettingForTesting(const std::string& key, |
| 105 scoped_ptr<base::Value> value); | 105 scoped_ptr<base::Value> value); |
| 106 | 106 |
| 107 // Public for testing. | 107 // Public for testing. |
| 108 static syncer::SyncData CreateSyncDataForSetting(const std::string& name, | 108 static syncer::SyncData CreateSyncDataForSetting(const std::string& name, |
| 109 const base::Value& value); | 109 const base::Value& value); |
| 110 | 110 |
| 111 // KeyedService implementation: | 111 // KeyedService implementation: |
| 112 virtual void Shutdown() override; | 112 void Shutdown() override; |
| 113 | 113 |
| 114 // SyncableService implementation: | 114 // SyncableService implementation: |
| 115 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 115 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 116 syncer::ModelType type, | 116 syncer::ModelType type, |
| 117 const syncer::SyncDataList& initial_sync_data, | 117 const syncer::SyncDataList& initial_sync_data, |
| 118 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 118 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 119 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; | 119 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 120 virtual void StopSyncing(syncer::ModelType type) override; | 120 void StopSyncing(syncer::ModelType type) override; |
| 121 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const | 121 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 122 override; | 122 syncer::SyncError ProcessSyncChanges( |
| 123 virtual syncer::SyncError ProcessSyncChanges( | |
| 124 const tracked_objects::Location& from_here, | 123 const tracked_objects::Location& from_here, |
| 125 const syncer::SyncChangeList& change_list) override; | 124 const syncer::SyncChangeList& change_list) override; |
| 126 | 125 |
| 127 // PrefStore::Observer implementation: | 126 // PrefStore::Observer implementation: |
| 128 virtual void OnPrefValueChanged(const std::string& key) override; | 127 void OnPrefValueChanged(const std::string& key) override; |
| 129 virtual void OnInitializationCompleted(bool success) override; | 128 void OnInitializationCompleted(bool success) override; |
| 130 | 129 |
| 131 private: | 130 private: |
| 132 base::DictionaryValue* GetOrCreateDictionary(const std::string& key) const; | 131 base::DictionaryValue* GetOrCreateDictionary(const std::string& key) const; |
| 133 base::DictionaryValue* GetAtomicSettings() const; | 132 base::DictionaryValue* GetAtomicSettings() const; |
| 134 base::DictionaryValue* GetSplitSettings() const; | 133 base::DictionaryValue* GetSplitSettings() const; |
| 135 base::DictionaryValue* GetQueuedItems() const; | 134 base::DictionaryValue* GetQueuedItems() const; |
| 136 | 135 |
| 137 // Returns the dictionary where a given Sync item should be stored, depending | 136 // Returns the dictionary where a given Sync item should be stored, depending |
| 138 // on whether the supervised user setting is atomic or split. In case of a | 137 // on whether the supervised user setting is atomic or split. In case of a |
| 139 // split setting, the split setting prefix of |key| is removed, so that |key| | 138 // split setting, the split setting prefix of |key| is removed, so that |key| |
| (...skipping 19 matching lines...) Expand all Loading... |
| 159 | 158 |
| 160 std::vector<SettingsCallback> subscribers_; | 159 std::vector<SettingsCallback> subscribers_; |
| 161 | 160 |
| 162 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 161 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| 163 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 162 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
| 164 | 163 |
| 165 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSettingsService); | 164 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSettingsService); |
| 166 }; | 165 }; |
| 167 | 166 |
| 168 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ | 167 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ |
| OLD | NEW |