OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/managed_mode/managed_user_settings_service.h" | 5 #include "chrome/browser/managed_mode/managed_user_settings_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/prefs/json_pref_store.h" | 10 #include "base/prefs/json_pref_store.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 bool SettingShouldApplyToPrefs(const std::string& name) { | 45 bool SettingShouldApplyToPrefs(const std::string& name) { |
46 return !StartsWithASCII(name, kManagedUserInternalItemPrefix, false); | 46 return !StartsWithASCII(name, kManagedUserInternalItemPrefix, false); |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 ManagedUserSettingsService::ManagedUserSettingsService() | 51 ManagedUserSettingsService::ManagedUserSettingsService() |
52 : active_(false), local_settings_(new DictionaryValue) {} | 52 : active_(false), local_settings_(new base::DictionaryValue) {} |
53 | 53 |
54 ManagedUserSettingsService::~ManagedUserSettingsService() {} | 54 ManagedUserSettingsService::~ManagedUserSettingsService() {} |
55 | 55 |
56 void ManagedUserSettingsService::Init( | 56 void ManagedUserSettingsService::Init( |
57 base::FilePath profile_path, | 57 base::FilePath profile_path, |
58 base::SequencedTaskRunner* sequenced_task_runner, | 58 base::SequencedTaskRunner* sequenced_task_runner, |
59 bool load_synchronously) { | 59 bool load_synchronously) { |
60 base::FilePath path = | 60 base::FilePath path = |
61 profile_path.Append(chrome::kManagedUserSettingsFilename); | 61 profile_path.Append(chrome::kManagedUserSettingsFilename); |
62 PersistentPrefStore* store = new JsonPrefStore(path, sequenced_task_runner); | 62 PersistentPrefStore* store = new JsonPrefStore(path, sequenced_task_runner); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 // static | 100 // static |
101 std::string ManagedUserSettingsService::MakeSplitSettingKey( | 101 std::string ManagedUserSettingsService::MakeSplitSettingKey( |
102 const std::string& prefix, | 102 const std::string& prefix, |
103 const std::string& key) { | 103 const std::string& key) { |
104 return prefix + kSplitSettingKeySeparator + key; | 104 return prefix + kSplitSettingKeySeparator + key; |
105 } | 105 } |
106 | 106 |
107 void ManagedUserSettingsService::UploadItem(const std::string& key, | 107 void ManagedUserSettingsService::UploadItem(const std::string& key, |
108 scoped_ptr<Value> value) { | 108 scoped_ptr<base::Value> value) { |
109 DCHECK(!SettingShouldApplyToPrefs(key)); | 109 DCHECK(!SettingShouldApplyToPrefs(key)); |
110 | 110 |
111 std::string key_suffix = key; | 111 std::string key_suffix = key; |
112 DictionaryValue* dict = NULL; | 112 base::DictionaryValue* dict = NULL; |
113 if (sync_processor_) { | 113 if (sync_processor_) { |
114 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Syncing")); | 114 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Syncing")); |
115 dict = GetDictionaryAndSplitKey(&key_suffix); | 115 dict = GetDictionaryAndSplitKey(&key_suffix); |
116 DCHECK(GetQueuedItems()->empty()); | 116 DCHECK(GetQueuedItems()->empty()); |
117 SyncChangeList change_list; | 117 SyncChangeList change_list; |
118 SyncData data = CreateSyncDataForSetting(key, *value); | 118 SyncData data = CreateSyncDataForSetting(key, *value); |
119 SyncChange::SyncChangeType change_type = | 119 SyncChange::SyncChangeType change_type = |
120 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 120 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
121 : SyncChange::ACTION_ADD; | 121 : SyncChange::ACTION_ADD; |
122 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 122 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
123 SyncError error = | 123 SyncError error = |
124 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); | 124 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); |
125 DCHECK(!error.IsSet()) << error.ToString(); | 125 DCHECK(!error.IsSet()) << error.ToString(); |
126 } else { | 126 } else { |
127 // Queue the item up to be uploaded when we start syncing | 127 // Queue the item up to be uploaded when we start syncing |
128 // (in MergeDataAndStartSyncing()). | 128 // (in MergeDataAndStartSyncing()). |
129 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); | 129 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); |
130 dict = GetQueuedItems(); | 130 dict = GetQueuedItems(); |
131 } | 131 } |
132 dict->SetWithoutPathExpansion(key_suffix, value.release()); | 132 dict->SetWithoutPathExpansion(key_suffix, value.release()); |
133 } | 133 } |
134 | 134 |
135 void ManagedUserSettingsService::SetLocalSettingForTesting( | 135 void ManagedUserSettingsService::SetLocalSettingForTesting( |
136 const std::string& key, | 136 const std::string& key, |
137 scoped_ptr<Value> value) { | 137 scoped_ptr<base::Value> value) { |
138 if (value) | 138 if (value) |
139 local_settings_->SetWithoutPathExpansion(key, value.release()); | 139 local_settings_->SetWithoutPathExpansion(key, value.release()); |
140 else | 140 else |
141 local_settings_->RemoveWithoutPathExpansion(key, NULL); | 141 local_settings_->RemoveWithoutPathExpansion(key, NULL); |
142 | 142 |
143 InformSubscribers(); | 143 InformSubscribers(); |
144 } | 144 } |
145 | 145 |
146 // static | 146 // static |
147 SyncData ManagedUserSettingsService::CreateSyncDataForSetting( | 147 SyncData ManagedUserSettingsService::CreateSyncDataForSetting( |
148 const std::string& name, | 148 const std::string& name, |
149 const Value& value) { | 149 const base::Value& value) { |
150 std::string json_value; | 150 std::string json_value; |
151 base::JSONWriter::Write(&value, &json_value); | 151 base::JSONWriter::Write(&value, &json_value); |
152 ::sync_pb::EntitySpecifics specifics; | 152 ::sync_pb::EntitySpecifics specifics; |
153 specifics.mutable_managed_user_setting()->set_name(name); | 153 specifics.mutable_managed_user_setting()->set_name(name); |
154 specifics.mutable_managed_user_setting()->set_value(json_value); | 154 specifics.mutable_managed_user_setting()->set_value(json_value); |
155 return SyncData::CreateLocalData(name, name, specifics); | 155 return SyncData::CreateLocalData(name, name, specifics); |
156 } | 156 } |
157 | 157 |
158 void ManagedUserSettingsService::Shutdown() { | 158 void ManagedUserSettingsService::Shutdown() { |
159 store_->RemoveObserver(this); | 159 store_->RemoveObserver(this); |
160 } | 160 } |
161 | 161 |
162 SyncMergeResult ManagedUserSettingsService::MergeDataAndStartSyncing( | 162 SyncMergeResult ManagedUserSettingsService::MergeDataAndStartSyncing( |
163 ModelType type, | 163 ModelType type, |
164 const SyncDataList& initial_sync_data, | 164 const SyncDataList& initial_sync_data, |
165 scoped_ptr<SyncChangeProcessor> sync_processor, | 165 scoped_ptr<SyncChangeProcessor> sync_processor, |
166 scoped_ptr<SyncErrorFactory> error_handler) { | 166 scoped_ptr<SyncErrorFactory> error_handler) { |
167 DCHECK_EQ(MANAGED_USER_SETTINGS, type); | 167 DCHECK_EQ(MANAGED_USER_SETTINGS, type); |
168 sync_processor_ = sync_processor.Pass(); | 168 sync_processor_ = sync_processor.Pass(); |
169 error_handler_ = error_handler.Pass(); | 169 error_handler_ = error_handler.Pass(); |
170 | 170 |
171 // Clear all atomic and split settings, then recreate them from Sync data. | 171 // Clear all atomic and split settings, then recreate them from Sync data. |
172 Clear(); | 172 Clear(); |
173 for (SyncDataList::const_iterator it = initial_sync_data.begin(); | 173 for (SyncDataList::const_iterator it = initial_sync_data.begin(); |
174 it != initial_sync_data.end(); ++it) { | 174 it != initial_sync_data.end(); ++it) { |
175 DCHECK_EQ(MANAGED_USER_SETTINGS, it->GetDataType()); | 175 DCHECK_EQ(MANAGED_USER_SETTINGS, it->GetDataType()); |
176 const ::sync_pb::ManagedUserSettingSpecifics& managed_user_setting = | 176 const ::sync_pb::ManagedUserSettingSpecifics& managed_user_setting = |
177 it->GetSpecifics().managed_user_setting(); | 177 it->GetSpecifics().managed_user_setting(); |
178 scoped_ptr<Value> value(JSONReader::Read(managed_user_setting.value())); | 178 scoped_ptr<base::Value> value( |
| 179 JSONReader::Read(managed_user_setting.value())); |
179 std::string name_suffix = managed_user_setting.name(); | 180 std::string name_suffix = managed_user_setting.name(); |
180 DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); | 181 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); |
181 dict->SetWithoutPathExpansion(name_suffix, value.release()); | 182 dict->SetWithoutPathExpansion(name_suffix, value.release()); |
182 } | 183 } |
183 store_->ReportValueChanged(kAtomicSettings); | 184 store_->ReportValueChanged(kAtomicSettings); |
184 store_->ReportValueChanged(kSplitSettings); | 185 store_->ReportValueChanged(kSplitSettings); |
185 InformSubscribers(); | 186 InformSubscribers(); |
186 | 187 |
187 // Upload all the queued up items (either with an ADD or an UPDATE action, | 188 // Upload all the queued up items (either with an ADD or an UPDATE action, |
188 // depending on whether they already exist) and move them to split settings. | 189 // depending on whether they already exist) and move them to split settings. |
189 SyncChangeList change_list; | 190 SyncChangeList change_list; |
190 DictionaryValue* queued_items = GetQueuedItems(); | 191 base::DictionaryValue* queued_items = GetQueuedItems(); |
191 for (DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); | 192 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); |
192 it.Advance()) { | 193 it.Advance()) { |
193 std::string key_suffix = it.key(); | 194 std::string key_suffix = it.key(); |
194 DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); | 195 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); |
195 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); | 196 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); |
196 SyncChange::SyncChangeType change_type = | 197 SyncChange::SyncChangeType change_type = |
197 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 198 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
198 : SyncChange::ACTION_ADD; | 199 : SyncChange::ACTION_ADD; |
199 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 200 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
200 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); | 201 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); |
201 } | 202 } |
202 queued_items->Clear(); | 203 queued_items->Clear(); |
203 | 204 |
204 SyncMergeResult result(MANAGED_USER_SETTINGS); | 205 SyncMergeResult result(MANAGED_USER_SETTINGS); |
(...skipping 11 matching lines...) Expand all Loading... |
216 void ManagedUserSettingsService::StopSyncing(ModelType type) { | 217 void ManagedUserSettingsService::StopSyncing(ModelType type) { |
217 DCHECK_EQ(syncer::MANAGED_USER_SETTINGS, type); | 218 DCHECK_EQ(syncer::MANAGED_USER_SETTINGS, type); |
218 sync_processor_.reset(); | 219 sync_processor_.reset(); |
219 error_handler_.reset(); | 220 error_handler_.reset(); |
220 } | 221 } |
221 | 222 |
222 SyncDataList ManagedUserSettingsService::GetAllSyncData( | 223 SyncDataList ManagedUserSettingsService::GetAllSyncData( |
223 ModelType type) const { | 224 ModelType type) const { |
224 DCHECK_EQ(syncer::MANAGED_USER_SETTINGS, type); | 225 DCHECK_EQ(syncer::MANAGED_USER_SETTINGS, type); |
225 SyncDataList data; | 226 SyncDataList data; |
226 for (DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); | 227 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); |
227 it.Advance()) { | 228 it.Advance()) { |
228 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); | 229 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); |
229 } | 230 } |
230 for (DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); | 231 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
231 it.Advance()) { | 232 it.Advance()) { |
232 const DictionaryValue* dict = NULL; | 233 const base::DictionaryValue* dict = NULL; |
233 it.value().GetAsDictionary(&dict); | 234 it.value().GetAsDictionary(&dict); |
234 for (DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); jt.Advance()) { | 235 for (base::DictionaryValue::Iterator jt(*dict); |
| 236 !jt.IsAtEnd(); jt.Advance()) { |
235 data.push_back(CreateSyncDataForSetting( | 237 data.push_back(CreateSyncDataForSetting( |
236 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); | 238 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); |
237 } | 239 } |
238 } | 240 } |
239 DCHECK_EQ(0u, GetQueuedItems()->size()); | 241 DCHECK_EQ(0u, GetQueuedItems()->size()); |
240 return data; | 242 return data; |
241 } | 243 } |
242 | 244 |
243 SyncError ManagedUserSettingsService::ProcessSyncChanges( | 245 SyncError ManagedUserSettingsService::ProcessSyncChanges( |
244 const tracked_objects::Location& from_here, | 246 const tracked_objects::Location& from_here, |
245 const SyncChangeList& change_list) { | 247 const SyncChangeList& change_list) { |
246 for (SyncChangeList::const_iterator it = change_list.begin(); | 248 for (SyncChangeList::const_iterator it = change_list.begin(); |
247 it != change_list.end(); ++it) { | 249 it != change_list.end(); ++it) { |
248 SyncData data = it->sync_data(); | 250 SyncData data = it->sync_data(); |
249 DCHECK_EQ(MANAGED_USER_SETTINGS, data.GetDataType()); | 251 DCHECK_EQ(MANAGED_USER_SETTINGS, data.GetDataType()); |
250 const ::sync_pb::ManagedUserSettingSpecifics& managed_user_setting = | 252 const ::sync_pb::ManagedUserSettingSpecifics& managed_user_setting = |
251 data.GetSpecifics().managed_user_setting(); | 253 data.GetSpecifics().managed_user_setting(); |
252 std::string key = managed_user_setting.name(); | 254 std::string key = managed_user_setting.name(); |
253 DictionaryValue* dict = GetDictionaryAndSplitKey(&key); | 255 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key); |
254 switch (it->change_type()) { | 256 switch (it->change_type()) { |
255 case SyncChange::ACTION_ADD: | 257 case SyncChange::ACTION_ADD: |
256 case SyncChange::ACTION_UPDATE: { | 258 case SyncChange::ACTION_UPDATE: { |
257 scoped_ptr<Value> value(JSONReader::Read(managed_user_setting.value())); | 259 scoped_ptr<base::Value> value( |
| 260 JSONReader::Read(managed_user_setting.value())); |
258 if (dict->HasKey(key)) { | 261 if (dict->HasKey(key)) { |
259 DLOG_IF(WARNING, it->change_type() == SyncChange::ACTION_ADD) | 262 DLOG_IF(WARNING, it->change_type() == SyncChange::ACTION_ADD) |
260 << "Value for key " << key << " already exists"; | 263 << "Value for key " << key << " already exists"; |
261 } else { | 264 } else { |
262 DLOG_IF(WARNING, it->change_type() == SyncChange::ACTION_UPDATE) | 265 DLOG_IF(WARNING, it->change_type() == SyncChange::ACTION_UPDATE) |
263 << "Value for key " << key << " doesn't exist yet"; | 266 << "Value for key " << key << " doesn't exist yet"; |
264 } | 267 } |
265 dict->SetWithoutPathExpansion(key, value.release()); | 268 dict->SetWithoutPathExpansion(key, value.release()); |
266 break; | 269 break; |
267 } | 270 } |
(...skipping 18 matching lines...) Expand all Loading... |
286 } | 289 } |
287 | 290 |
288 void ManagedUserSettingsService::OnPrefValueChanged(const std::string& key) {} | 291 void ManagedUserSettingsService::OnPrefValueChanged(const std::string& key) {} |
289 | 292 |
290 void ManagedUserSettingsService::OnInitializationCompleted(bool success) { | 293 void ManagedUserSettingsService::OnInitializationCompleted(bool success) { |
291 DCHECK(success); | 294 DCHECK(success); |
292 DCHECK(IsReady()); | 295 DCHECK(IsReady()); |
293 InformSubscribers(); | 296 InformSubscribers(); |
294 } | 297 } |
295 | 298 |
296 DictionaryValue* ManagedUserSettingsService::GetOrCreateDictionary( | 299 base::DictionaryValue* ManagedUserSettingsService::GetOrCreateDictionary( |
297 const std::string& key) const { | 300 const std::string& key) const { |
298 Value* value = NULL; | 301 base::Value* value = NULL; |
299 DictionaryValue* dict = NULL; | 302 base::DictionaryValue* dict = NULL; |
300 if (store_->GetMutableValue(key, &value)) { | 303 if (store_->GetMutableValue(key, &value)) { |
301 bool success = value->GetAsDictionary(&dict); | 304 bool success = value->GetAsDictionary(&dict); |
302 DCHECK(success); | 305 DCHECK(success); |
303 } else { | 306 } else { |
304 dict = new base::DictionaryValue; | 307 dict = new base::DictionaryValue; |
305 store_->SetValue(key, dict); | 308 store_->SetValue(key, dict); |
306 } | 309 } |
307 | 310 |
308 return dict; | 311 return dict; |
309 } | 312 } |
310 | 313 |
311 DictionaryValue* ManagedUserSettingsService::GetAtomicSettings() const { | 314 base::DictionaryValue* ManagedUserSettingsService::GetAtomicSettings() const { |
312 return GetOrCreateDictionary(kAtomicSettings); | 315 return GetOrCreateDictionary(kAtomicSettings); |
313 } | 316 } |
314 | 317 |
315 DictionaryValue* ManagedUserSettingsService::GetSplitSettings() const { | 318 base::DictionaryValue* ManagedUserSettingsService::GetSplitSettings() const { |
316 return GetOrCreateDictionary(kSplitSettings); | 319 return GetOrCreateDictionary(kSplitSettings); |
317 } | 320 } |
318 | 321 |
319 DictionaryValue* ManagedUserSettingsService::GetQueuedItems() const { | 322 base::DictionaryValue* ManagedUserSettingsService::GetQueuedItems() const { |
320 return GetOrCreateDictionary(kQueuedItems); | 323 return GetOrCreateDictionary(kQueuedItems); |
321 } | 324 } |
322 | 325 |
323 DictionaryValue* ManagedUserSettingsService::GetDictionaryAndSplitKey( | 326 base::DictionaryValue* ManagedUserSettingsService::GetDictionaryAndSplitKey( |
324 std::string* key) const { | 327 std::string* key) const { |
325 size_t pos = key->find_first_of(kSplitSettingKeySeparator); | 328 size_t pos = key->find_first_of(kSplitSettingKeySeparator); |
326 if (pos == std::string::npos) | 329 if (pos == std::string::npos) |
327 return GetAtomicSettings(); | 330 return GetAtomicSettings(); |
328 | 331 |
329 DictionaryValue* split_settings = GetSplitSettings(); | 332 base::DictionaryValue* split_settings = GetSplitSettings(); |
330 std::string prefix = key->substr(0, pos); | 333 std::string prefix = key->substr(0, pos); |
331 DictionaryValue* dict = NULL; | 334 base::DictionaryValue* dict = NULL; |
332 if (!split_settings->GetDictionary(prefix, &dict)) { | 335 if (!split_settings->GetDictionary(prefix, &dict)) { |
333 dict = new DictionaryValue; | 336 dict = new base::DictionaryValue; |
334 DCHECK(!split_settings->HasKey(prefix)); | 337 DCHECK(!split_settings->HasKey(prefix)); |
335 split_settings->Set(prefix, dict); | 338 split_settings->Set(prefix, dict); |
336 } | 339 } |
337 key->erase(0, pos + 1); | 340 key->erase(0, pos + 1); |
338 return dict; | 341 return dict; |
339 } | 342 } |
340 | 343 |
341 scoped_ptr<DictionaryValue> ManagedUserSettingsService::GetSettings() { | 344 scoped_ptr<base::DictionaryValue> ManagedUserSettingsService::GetSettings() { |
342 DCHECK(IsReady()); | 345 DCHECK(IsReady()); |
343 if (!active_) | 346 if (!active_) |
344 return scoped_ptr<base::DictionaryValue>(); | 347 return scoped_ptr<base::DictionaryValue>(); |
345 | 348 |
346 scoped_ptr<DictionaryValue> settings(local_settings_->DeepCopy()); | 349 scoped_ptr<base::DictionaryValue> settings(local_settings_->DeepCopy()); |
347 | 350 |
348 DictionaryValue* atomic_settings = GetAtomicSettings(); | 351 base::DictionaryValue* atomic_settings = GetAtomicSettings(); |
349 for (DictionaryValue::Iterator it(*atomic_settings); !it.IsAtEnd(); | 352 for (base::DictionaryValue::Iterator it(*atomic_settings); !it.IsAtEnd(); |
350 it.Advance()) { | 353 it.Advance()) { |
351 if (!SettingShouldApplyToPrefs(it.key())) | 354 if (!SettingShouldApplyToPrefs(it.key())) |
352 continue; | 355 continue; |
353 | 356 |
354 settings->Set(it.key(), it.value().DeepCopy()); | 357 settings->Set(it.key(), it.value().DeepCopy()); |
355 } | 358 } |
356 | 359 |
357 DictionaryValue* split_settings = GetSplitSettings(); | 360 base::DictionaryValue* split_settings = GetSplitSettings(); |
358 for (DictionaryValue::Iterator it(*split_settings); !it.IsAtEnd(); | 361 for (base::DictionaryValue::Iterator it(*split_settings); !it.IsAtEnd(); |
359 it.Advance()) { | 362 it.Advance()) { |
360 if (!SettingShouldApplyToPrefs(it.key())) | 363 if (!SettingShouldApplyToPrefs(it.key())) |
361 continue; | 364 continue; |
362 | 365 |
363 settings->Set(it.key(), it.value().DeepCopy()); | 366 settings->Set(it.key(), it.value().DeepCopy()); |
364 } | 367 } |
365 | 368 |
366 return settings.Pass(); | 369 return settings.Pass(); |
367 } | 370 } |
368 | 371 |
369 void ManagedUserSettingsService::InformSubscribers() { | 372 void ManagedUserSettingsService::InformSubscribers() { |
370 if (!IsReady()) | 373 if (!IsReady()) |
371 return; | 374 return; |
372 | 375 |
373 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 376 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
374 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); | 377 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); |
375 it != subscribers_.end(); ++it) { | 378 it != subscribers_.end(); ++it) { |
376 it->Run(settings.get()); | 379 it->Run(settings.get()); |
377 } | 380 } |
378 } | 381 } |
OLD | NEW |