Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: chrome/browser/supervised_user/supervised_user_settings_service.h

Issue 1878143002: Convert //chrome/browser/supervised_user from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/callback_list.h" 13 #include "base/callback_list.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/supervised_user/supervised_users.h" 17 #include "chrome/browser/supervised_user/supervised_users.h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "components/prefs/pref_store.h" 19 #include "components/prefs/pref_store.h"
20 #include "sync/api/syncable_service.h" 20 #include "sync/api/syncable_service.h"
21 21
22 class PersistentPrefStore; 22 class PersistentPrefStore;
23 class Profile; 23 class Profile;
24 24
25 namespace base { 25 namespace base {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 base::SequencedTaskRunner* sequenced_task_runner, 73 base::SequencedTaskRunner* sequenced_task_runner,
74 bool load_synchronously); 74 bool load_synchronously);
75 75
76 // Initializes the service by loading its settings from the |pref_store|. 76 // Initializes the service by loading its settings from the |pref_store|.
77 // Use this method in tests to inject a different PrefStore than the 77 // Use this method in tests to inject a different PrefStore than the
78 // default one. 78 // default one.
79 void Init(scoped_refptr<PersistentPrefStore> pref_store); 79 void Init(scoped_refptr<PersistentPrefStore> pref_store);
80 80
81 // Adds a callback to be called when supervised user settings are initially 81 // Adds a callback to be called when supervised user settings are initially
82 // available, or when they change. 82 // available, or when they change.
83 scoped_ptr<SettingsCallbackList::Subscription> Subscribe( 83 std::unique_ptr<SettingsCallbackList::Subscription> Subscribe(
84 const SettingsCallback& callback) WARN_UNUSED_RESULT; 84 const SettingsCallback& callback) WARN_UNUSED_RESULT;
85 85
86 // Gets the associated profile 86 // Gets the associated profile
87 // This is currently only used for subscribing to notifications, it will be 87 // This is currently only used for subscribing to notifications, it will be
88 // nullptr in tests and will soon be removed. 88 // nullptr in tests and will soon be removed.
89 // TODO(peconn): Remove this once SupervisedUserPrefStore is (partially at 89 // TODO(peconn): Remove this once SupervisedUserPrefStore is (partially at
90 // least) a KeyedService, see TODO in SupervisedUserPrefStore. 90 // least) a KeyedService, see TODO in SupervisedUserPrefStore.
91 Profile* GetProfile(); 91 Profile* GetProfile();
92 92
93 // Activates/deactivates the service. This is called by the 93 // Activates/deactivates the service. This is called by the
94 // SupervisedUserService when it is (de)activated. 94 // SupervisedUserService when it is (de)activated.
95 void SetActive(bool active); 95 void SetActive(bool active);
96 96
97 // Whether supervised user settings are available. 97 // Whether supervised user settings are available.
98 bool IsReady(); 98 bool IsReady();
99 99
100 // Clears all supervised user settings and items. 100 // Clears all supervised user settings and items.
101 void Clear(); 101 void Clear();
102 102
103 // Constructs a key for a split supervised user setting from a prefix and a 103 // Constructs a key for a split supervised user setting from a prefix and a
104 // variable key. 104 // variable key.
105 static std::string MakeSplitSettingKey(const std::string& prefix, 105 static std::string MakeSplitSettingKey(const std::string& prefix,
106 const std::string& key); 106 const std::string& key);
107 107
108 // Uploads an item to the Sync server. Items are the same data structure as 108 // Uploads an item to the Sync server. Items are the same data structure as
109 // supervised user settings (i.e. key-value pairs, as described at the top of 109 // supervised user settings (i.e. key-value pairs, as described at the top of
110 // the file), but they are only uploaded (whereas supervised user settings are 110 // the file), but they are only uploaded (whereas supervised user settings are
111 // only downloaded), and never passed to the preference system. 111 // only downloaded), and never passed to the preference system.
112 // An example of an uploaded item is an access request to a blocked URL. 112 // An example of an uploaded item is an access request to a blocked URL.
113 void UploadItem(const std::string& key, scoped_ptr<base::Value> value); 113 void UploadItem(const std::string& key, std::unique_ptr<base::Value> value);
114 114
115 // Sets the setting with the given |key| to a copy of the given |value|. 115 // Sets the setting with the given |key| to a copy of the given |value|.
116 void SetLocalSetting(const std::string& key, scoped_ptr<base::Value> value); 116 void SetLocalSetting(const std::string& key,
117 std::unique_ptr<base::Value> value);
117 118
118 // Public for testing. 119 // Public for testing.
119 static syncer::SyncData CreateSyncDataForSetting(const std::string& name, 120 static syncer::SyncData CreateSyncDataForSetting(const std::string& name,
120 const base::Value& value); 121 const base::Value& value);
121 122
122 // KeyedService implementation: 123 // KeyedService implementation:
123 void Shutdown() override; 124 void Shutdown() override;
124 125
125 // SyncableService implementation: 126 // SyncableService implementation:
126 syncer::SyncMergeResult MergeDataAndStartSyncing( 127 syncer::SyncMergeResult MergeDataAndStartSyncing(
127 syncer::ModelType type, 128 syncer::ModelType type,
128 const syncer::SyncDataList& initial_sync_data, 129 const syncer::SyncDataList& initial_sync_data,
129 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 130 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
130 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; 131 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override;
131 void StopSyncing(syncer::ModelType type) override; 132 void StopSyncing(syncer::ModelType type) override;
132 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; 133 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
133 syncer::SyncError ProcessSyncChanges( 134 syncer::SyncError ProcessSyncChanges(
134 const tracked_objects::Location& from_here, 135 const tracked_objects::Location& from_here,
135 const syncer::SyncChangeList& change_list) override; 136 const syncer::SyncChangeList& change_list) override;
136 137
137 // PrefStore::Observer implementation: 138 // PrefStore::Observer implementation:
138 void OnPrefValueChanged(const std::string& key) override; 139 void OnPrefValueChanged(const std::string& key) override;
139 void OnInitializationCompleted(bool success) override; 140 void OnInitializationCompleted(bool success) override;
140 141
141 private: 142 private:
142 base::DictionaryValue* GetOrCreateDictionary(const std::string& key) const; 143 base::DictionaryValue* GetOrCreateDictionary(const std::string& key) const;
143 base::DictionaryValue* GetAtomicSettings() const; 144 base::DictionaryValue* GetAtomicSettings() const;
144 base::DictionaryValue* GetSplitSettings() const; 145 base::DictionaryValue* GetSplitSettings() const;
145 base::DictionaryValue* GetQueuedItems() const; 146 base::DictionaryValue* GetQueuedItems() const;
146 147
147 // Returns the dictionary where a given Sync item should be stored, depending 148 // Returns the dictionary where a given Sync item should be stored, depending
148 // on whether the supervised user setting is atomic or split. In case of a 149 // on whether the supervised user setting is atomic or split. In case of a
149 // split setting, the split setting prefix of |key| is removed, so that |key| 150 // split setting, the split setting prefix of |key| is removed, so that |key|
150 // can be used to update the returned dictionary. 151 // can be used to update the returned dictionary.
151 base::DictionaryValue* GetDictionaryAndSplitKey(std::string* key) const; 152 base::DictionaryValue* GetDictionaryAndSplitKey(std::string* key) const;
152 153
153 // Returns a dictionary with all supervised user settings if the service is 154 // Returns a dictionary with all supervised user settings if the service is
154 // active, or NULL otherwise. 155 // active, or NULL otherwise.
155 scoped_ptr<base::DictionaryValue> GetSettings(); 156 std::unique_ptr<base::DictionaryValue> GetSettings();
156 157
157 // Sends the settings to all subscribers. This method should be called by the 158 // Sends the settings to all subscribers. This method should be called by the
158 // subclass whenever the settings change. 159 // subclass whenever the settings change.
159 void InformSubscribers(); 160 void InformSubscribers();
160 161
161 // Used for persisting the settings. Unlike other PrefStores, this one is not 162 // Used for persisting the settings. Unlike other PrefStores, this one is not
162 // directly hooked up to the PrefService. 163 // directly hooked up to the PrefService.
163 scoped_refptr<PersistentPrefStore> store_; 164 scoped_refptr<PersistentPrefStore> store_;
164 165
165 Profile* profile_; 166 Profile* profile_;
166 167
167 bool active_; 168 bool active_;
168 169
169 bool initialization_failed_; 170 bool initialization_failed_;
170 171
171 // A set of local settings that are fixed and not configured remotely. 172 // A set of local settings that are fixed and not configured remotely.
172 scoped_ptr<base::DictionaryValue> local_settings_; 173 std::unique_ptr<base::DictionaryValue> local_settings_;
173 174
174 SettingsCallbackList callback_list_; 175 SettingsCallbackList callback_list_;
175 176
176 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 177 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_;
177 scoped_ptr<syncer::SyncErrorFactory> error_handler_; 178 std::unique_ptr<syncer::SyncErrorFactory> error_handler_;
178 179
179 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSettingsService); 180 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSettingsService);
180 }; 181 };
181 182
182 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_ 183 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698