Chromium Code Reviews| 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 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 PersistentPrefStore* store = new JsonPrefStore( | 71 PersistentPrefStore* store = new JsonPrefStore( |
| 72 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); | 72 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); |
| 73 Init(store); | 73 Init(store); |
| 74 if (load_synchronously) { | 74 if (load_synchronously) { |
| 75 store_->ReadPrefs(); | 75 store_->ReadPrefs(); |
| 76 // TODO(bauerb): Temporary CHECK while investigating | 76 // TODO(bauerb): Temporary CHECK while investigating |
| 77 // https://crbug.com/425785. Remove (or change to DCHECK) once the bug | 77 // https://crbug.com/425785. Remove (or change to DCHECK) once the bug |
| 78 // is fixed. | 78 // is fixed. |
| 79 CHECK(store_->IsInitializationComplete()); | 79 CHECK(store_->IsInitializationComplete()); |
| 80 } else { | 80 } else { |
| 81 store_->ReadPrefsAsync(NULL); | 81 store_->ReadPrefsAsync(nullptr); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SupervisedUserSettingsService::Init( | 85 void SupervisedUserSettingsService::Init( |
| 86 scoped_refptr<PersistentPrefStore> store) { | 86 scoped_refptr<PersistentPrefStore> store) { |
| 87 DCHECK(!store_.get()); | 87 DCHECK(!store_.get()); |
| 88 store_ = store; | 88 store_ = store; |
| 89 store_->AddObserver(this); | 89 store_->AddObserver(this); |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 const std::string& prefix, | 127 const std::string& prefix, |
| 128 const std::string& key) { | 128 const std::string& key) { |
| 129 return prefix + kSplitSettingKeySeparator + key; | 129 return prefix + kSplitSettingKeySeparator + key; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void SupervisedUserSettingsService::UploadItem(const std::string& key, | 132 void SupervisedUserSettingsService::UploadItem(const std::string& key, |
| 133 scoped_ptr<base::Value> value) { | 133 scoped_ptr<base::Value> value) { |
| 134 DCHECK(!SettingShouldApplyToPrefs(key)); | 134 DCHECK(!SettingShouldApplyToPrefs(key)); |
| 135 | 135 |
| 136 std::string key_suffix = key; | 136 std::string key_suffix = key; |
| 137 base::DictionaryValue* dict = NULL; | 137 base::DictionaryValue* dict = nullptr; |
| 138 if (sync_processor_) { | 138 if (sync_processor_) { |
| 139 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Syncing")); | 139 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Syncing")); |
| 140 dict = GetDictionaryAndSplitKey(&key_suffix); | 140 dict = GetDictionaryAndSplitKey(&key_suffix); |
| 141 DCHECK(GetQueuedItems()->empty()); | 141 DCHECK(GetQueuedItems()->empty()); |
| 142 SyncChangeList change_list; | 142 SyncChangeList change_list; |
| 143 SyncData data = CreateSyncDataForSetting(key, *value); | 143 SyncData data = CreateSyncDataForSetting(key, *value); |
| 144 SyncChange::SyncChangeType change_type = | 144 SyncChange::SyncChangeType change_type = |
| 145 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 145 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
| 146 : SyncChange::ACTION_ADD; | 146 : SyncChange::ACTION_ADD; |
| 147 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 147 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
| 148 SyncError error = | 148 SyncError error = |
| 149 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); | 149 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); |
| 150 DCHECK(!error.IsSet()) << error.ToString(); | 150 DCHECK(!error.IsSet()) << error.ToString(); |
| 151 } else { | 151 } else { |
| 152 // Queue the item up to be uploaded when we start syncing | 152 // Queue the item up to be uploaded when we start syncing |
| 153 // (in MergeDataAndStartSyncing()). | 153 // (in MergeDataAndStartSyncing()). |
| 154 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); | 154 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); |
| 155 dict = GetQueuedItems(); | 155 dict = GetQueuedItems(); |
| 156 } | 156 } |
| 157 dict->SetWithoutPathExpansion(key_suffix, value.release()); | 157 dict->SetWithoutPathExpansion(key_suffix, value.release()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void SupervisedUserSettingsService::SetLocalSetting( | 160 void SupervisedUserSettingsService::SetLocalSetting( |
| 161 const std::string& key, | 161 const std::string& key, |
| 162 scoped_ptr<base::Value> value) { | 162 scoped_ptr<base::Value> value) { |
| 163 if (value) | 163 if (value) |
| 164 local_settings_->SetWithoutPathExpansion(key, value.release()); | 164 local_settings_->SetWithoutPathExpansion(key, value.release()); |
| 165 else | 165 else |
| 166 local_settings_->RemoveWithoutPathExpansion(key, NULL); | 166 local_settings_->RemoveWithoutPathExpansion(key, nullptr); |
| 167 | 167 |
| 168 InformSubscribers(); | 168 InformSubscribers(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 // static | 171 // static |
| 172 SyncData SupervisedUserSettingsService::CreateSyncDataForSetting( | 172 SyncData SupervisedUserSettingsService::CreateSyncDataForSetting( |
| 173 const std::string& name, | 173 const std::string& name, |
| 174 const base::Value& value) { | 174 const base::Value& value) { |
| 175 std::string json_value; | 175 std::string json_value; |
| 176 base::JSONWriter::Write(value, &json_value); | 176 base::JSONWriter::Write(value, &json_value); |
| 177 ::sync_pb::EntitySpecifics specifics; | 177 ::sync_pb::EntitySpecifics specifics; |
| 178 specifics.mutable_managed_user_setting()->set_name(name); | 178 specifics.mutable_managed_user_setting()->set_name(name); |
| 179 specifics.mutable_managed_user_setting()->set_value(json_value); | 179 specifics.mutable_managed_user_setting()->set_value(json_value); |
| 180 return SyncData::CreateLocalData(name, name, specifics); | 180 return SyncData::CreateLocalData(name, name, specifics); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SupervisedUserSettingsService::Shutdown() { | 183 void SupervisedUserSettingsService::Shutdown() { |
| 184 store_->RemoveObserver(this); | 184 store_->RemoveObserver(this); |
| 185 } | 185 } |
| 186 | 186 |
| 187 SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing( | 187 SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing( |
| 188 ModelType type, | 188 ModelType type, |
| 189 const SyncDataList& initial_sync_data, | 189 const SyncDataList& initial_sync_data, |
| 190 scoped_ptr<SyncChangeProcessor> sync_processor, | 190 scoped_ptr<SyncChangeProcessor> sync_processor, |
| 191 scoped_ptr<SyncErrorFactory> error_handler) { | 191 scoped_ptr<SyncErrorFactory> error_handler) { |
| 192 DCHECK_EQ(SUPERVISED_USER_SETTINGS, type); | 192 DCHECK_EQ(SUPERVISED_USER_SETTINGS, type); |
| 193 sync_processor_ = std::move(sync_processor); | 193 sync_processor_ = std::move(sync_processor); |
| 194 error_handler_ = std::move(error_handler); | 194 error_handler_ = std::move(error_handler); |
| 195 | 195 |
| 196 std::set<std::string> seen_keys; | |
| 197 int num_before_association = GetAtomicSettings()->size(); | |
| 198 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); | |
| 199 it.Advance()) { | |
| 200 seen_keys.insert(it.key()); | |
| 201 } | |
| 202 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); | |
| 203 it.Advance()) { | |
| 204 const base::DictionaryValue* dict = nullptr; | |
| 205 it.value().GetAsDictionary(&dict); | |
| 206 num_before_association += dict->size(); | |
| 207 for (base::DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); | |
| 208 jt.Advance()) { | |
| 209 seen_keys.insert(MakeSplitSettingKey(it.key(), jt.key())); | |
| 210 } | |
| 211 } | |
| 212 | |
|
Bernhard Bauer
2016/01/28 13:56:33
We are still missing queued items in |num_before_a
Deepak
2016/01/29 07:00:29
Done.
| |
| 196 // Clear all atomic and split settings, then recreate them from Sync data. | 213 // Clear all atomic and split settings, then recreate them from Sync data. |
| 197 Clear(); | 214 Clear(); |
| 215 int num_added = 0; | |
| 216 int num_modified = 0; | |
| 217 std::set<std::string> added_sync_keys; | |
| 198 for (const SyncData& sync_data : initial_sync_data) { | 218 for (const SyncData& sync_data : initial_sync_data) { |
| 199 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); | 219 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); |
| 200 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = | 220 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = |
| 201 sync_data.GetSpecifics().managed_user_setting(); | 221 sync_data.GetSpecifics().managed_user_setting(); |
| 202 scoped_ptr<base::Value> value = | 222 scoped_ptr<base::Value> value = |
| 203 JSONReader::Read(supervised_user_setting.value()); | 223 JSONReader::Read(supervised_user_setting.value()); |
| 204 std::string name_suffix = supervised_user_setting.name(); | 224 std::string name_suffix = supervised_user_setting.name(); |
| 225 std::string name_key = name_suffix; | |
| 205 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); | 226 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); |
| 206 dict->SetWithoutPathExpansion(name_suffix, value.release()); | 227 dict->SetWithoutPathExpansion(name_suffix, value.release()); |
| 228 if (seen_keys.find(name_key) == seen_keys.end()) { | |
| 229 added_sync_keys.insert(name_key); | |
| 230 num_added++; | |
| 231 } else { | |
| 232 num_modified++; | |
| 233 } | |
| 207 } | 234 } |
| 235 | |
| 208 store_->ReportValueChanged(kAtomicSettings, | 236 store_->ReportValueChanged(kAtomicSettings, |
| 209 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 237 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 210 store_->ReportValueChanged(kSplitSettings, | 238 store_->ReportValueChanged(kSplitSettings, |
| 211 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 239 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 212 InformSubscribers(); | 240 InformSubscribers(); |
| 213 | 241 |
| 214 // Upload all the queued up items (either with an ADD or an UPDATE action, | 242 // Upload all the queued up items (either with an ADD or an UPDATE action, |
| 215 // depending on whether they already exist) and move them to split settings. | 243 // depending on whether they already exist) and move them to split settings. |
| 216 SyncChangeList change_list; | 244 SyncChangeList change_list; |
| 217 base::DictionaryValue* queued_items = GetQueuedItems(); | 245 base::DictionaryValue* queued_items = GetQueuedItems(); |
| 218 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); | 246 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); |
| 219 it.Advance()) { | 247 it.Advance()) { |
| 220 std::string key_suffix = it.key(); | 248 std::string key_suffix = it.key(); |
| 249 std::string name_key = key_suffix; | |
| 221 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); | 250 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); |
| 222 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); | 251 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); |
| 223 SyncChange::SyncChangeType change_type = | 252 SyncChange::SyncChangeType change_type = |
| 224 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 253 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
| 225 : SyncChange::ACTION_ADD; | 254 : SyncChange::ACTION_ADD; |
| 226 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 255 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
| 227 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); | 256 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); |
| 257 if (added_sync_keys.find(name_key) != added_sync_keys.end()) { | |
| 258 num_added--; | |
| 259 num_modified++; | |
| 260 } | |
| 228 } | 261 } |
| 229 queued_items->Clear(); | 262 queued_items->Clear(); |
| 230 | 263 |
| 231 SyncMergeResult result(SUPERVISED_USER_SETTINGS); | 264 SyncMergeResult result(SUPERVISED_USER_SETTINGS); |
| 232 // Process all the accumulated changes from the queued items. | 265 // Process all the accumulated changes from the queued items. |
| 233 if (change_list.size() > 0) { | 266 if (change_list.size() > 0) { |
| 234 store_->ReportValueChanged(kQueuedItems, | 267 store_->ReportValueChanged(kQueuedItems, |
| 235 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 268 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 236 result.set_error( | 269 result.set_error( |
| 237 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); | 270 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); |
| 238 } | 271 } |
| 239 | 272 |
| 240 // TODO(bauerb): Statistics? | 273 // Calculating number of items after association. |
| 274 int num_after_association = GetAtomicSettings()->size(); | |
| 275 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); | |
| 276 it.Advance()) { | |
| 277 const base::DictionaryValue* dict = nullptr; | |
| 278 it.value().GetAsDictionary(&dict); | |
| 279 num_after_association += dict->size(); | |
| 280 } | |
| 281 | |
| 282 result.set_num_items_added(num_added); | |
| 283 result.set_num_items_modified(num_modified); | |
| 284 result.set_num_items_deleted(num_after_association - | |
| 285 (num_added + num_modified)); | |
| 286 result.set_num_items_before_association(num_before_association); | |
| 287 result.set_num_items_after_association(num_after_association); | |
| 241 return result; | 288 return result; |
| 242 } | 289 } |
| 243 | 290 |
| 244 void SupervisedUserSettingsService::StopSyncing(ModelType type) { | 291 void SupervisedUserSettingsService::StopSyncing(ModelType type) { |
| 245 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); | 292 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); |
| 246 sync_processor_.reset(); | 293 sync_processor_.reset(); |
| 247 error_handler_.reset(); | 294 error_handler_.reset(); |
| 248 } | 295 } |
| 249 | 296 |
| 250 SyncDataList SupervisedUserSettingsService::GetAllSyncData( | 297 SyncDataList SupervisedUserSettingsService::GetAllSyncData( |
| 251 ModelType type) const { | 298 ModelType type) const { |
| 252 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); | 299 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); |
| 253 SyncDataList data; | 300 SyncDataList data; |
| 254 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); | 301 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); |
| 255 it.Advance()) { | 302 it.Advance()) { |
| 256 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); | 303 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); |
| 257 } | 304 } |
| 258 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); | 305 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
| 259 it.Advance()) { | 306 it.Advance()) { |
| 260 const base::DictionaryValue* dict = NULL; | 307 const base::DictionaryValue* dict = nullptr; |
| 261 it.value().GetAsDictionary(&dict); | 308 it.value().GetAsDictionary(&dict); |
| 262 for (base::DictionaryValue::Iterator jt(*dict); | 309 for (base::DictionaryValue::Iterator jt(*dict); |
| 263 !jt.IsAtEnd(); jt.Advance()) { | 310 !jt.IsAtEnd(); jt.Advance()) { |
| 264 data.push_back(CreateSyncDataForSetting( | 311 data.push_back(CreateSyncDataForSetting( |
| 265 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); | 312 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); |
| 266 } | 313 } |
| 267 } | 314 } |
| 268 DCHECK_EQ(0u, GetQueuedItems()->size()); | 315 DCHECK_EQ(0u, GetQueuedItems()->size()); |
| 269 return data; | 316 return data; |
| 270 } | 317 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 291 } else { | 338 } else { |
| 292 DLOG_IF(WARNING, change_type == SyncChange::ACTION_UPDATE) | 339 DLOG_IF(WARNING, change_type == SyncChange::ACTION_UPDATE) |
| 293 << "Value for key " << key << " doesn't exist yet"; | 340 << "Value for key " << key << " doesn't exist yet"; |
| 294 } | 341 } |
| 295 dict->SetWithoutPathExpansion(key, value.release()); | 342 dict->SetWithoutPathExpansion(key, value.release()); |
| 296 break; | 343 break; |
| 297 } | 344 } |
| 298 case SyncChange::ACTION_DELETE: { | 345 case SyncChange::ACTION_DELETE: { |
| 299 DLOG_IF(WARNING, !dict->HasKey(key)) << "Trying to delete nonexistent " | 346 DLOG_IF(WARNING, !dict->HasKey(key)) << "Trying to delete nonexistent " |
| 300 << "key " << key; | 347 << "key " << key; |
| 301 dict->RemoveWithoutPathExpansion(key, NULL); | 348 dict->RemoveWithoutPathExpansion(key, nullptr); |
| 302 break; | 349 break; |
| 303 } | 350 } |
| 304 case SyncChange::ACTION_INVALID: { | 351 case SyncChange::ACTION_INVALID: { |
| 305 NOTREACHED(); | 352 NOTREACHED(); |
| 306 break; | 353 break; |
| 307 } | 354 } |
| 308 } | 355 } |
| 309 } | 356 } |
| 310 store_->ReportValueChanged(kAtomicSettings, | 357 store_->ReportValueChanged(kAtomicSettings, |
| 311 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 358 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 330 } | 377 } |
| 331 | 378 |
| 332 // TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. | 379 // TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. |
| 333 // Remove (or change back to DCHECK) once the bug is fixed. | 380 // Remove (or change back to DCHECK) once the bug is fixed. |
| 334 CHECK(IsReady()); | 381 CHECK(IsReady()); |
| 335 InformSubscribers(); | 382 InformSubscribers(); |
| 336 } | 383 } |
| 337 | 384 |
| 338 base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary( | 385 base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary( |
| 339 const std::string& key) const { | 386 const std::string& key) const { |
| 340 base::Value* value = NULL; | 387 base::Value* value = nullptr; |
| 341 base::DictionaryValue* dict = NULL; | 388 base::DictionaryValue* dict = nullptr; |
| 342 if (store_->GetMutableValue(key, &value)) { | 389 if (store_->GetMutableValue(key, &value)) { |
| 343 bool success = value->GetAsDictionary(&dict); | 390 bool success = value->GetAsDictionary(&dict); |
| 344 DCHECK(success); | 391 DCHECK(success); |
| 345 } else { | 392 } else { |
| 346 dict = new base::DictionaryValue; | 393 dict = new base::DictionaryValue; |
| 347 store_->SetValue(key, make_scoped_ptr(dict), | 394 store_->SetValue(key, make_scoped_ptr(dict), |
| 348 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 395 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 349 } | 396 } |
| 350 | 397 |
| 351 return dict; | 398 return dict; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 365 } | 412 } |
| 366 | 413 |
| 367 base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( | 414 base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( |
| 368 std::string* key) const { | 415 std::string* key) const { |
| 369 size_t pos = key->find_first_of(kSplitSettingKeySeparator); | 416 size_t pos = key->find_first_of(kSplitSettingKeySeparator); |
| 370 if (pos == std::string::npos) | 417 if (pos == std::string::npos) |
| 371 return GetAtomicSettings(); | 418 return GetAtomicSettings(); |
| 372 | 419 |
| 373 base::DictionaryValue* split_settings = GetSplitSettings(); | 420 base::DictionaryValue* split_settings = GetSplitSettings(); |
| 374 std::string prefix = key->substr(0, pos); | 421 std::string prefix = key->substr(0, pos); |
| 375 base::DictionaryValue* dict = NULL; | 422 base::DictionaryValue* dict = nullptr; |
| 376 if (!split_settings->GetDictionary(prefix, &dict)) { | 423 if (!split_settings->GetDictionary(prefix, &dict)) { |
| 377 dict = new base::DictionaryValue; | 424 dict = new base::DictionaryValue; |
| 378 DCHECK(!split_settings->HasKey(prefix)); | 425 DCHECK(!split_settings->HasKey(prefix)); |
| 379 split_settings->Set(prefix, dict); | 426 split_settings->Set(prefix, dict); |
| 380 } | 427 } |
| 381 key->erase(0, pos + 1); | 428 key->erase(0, pos + 1); |
| 382 return dict; | 429 return dict; |
| 383 } | 430 } |
| 384 | 431 |
| 385 scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { | 432 scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 410 return settings; | 457 return settings; |
| 411 } | 458 } |
| 412 | 459 |
| 413 void SupervisedUserSettingsService::InformSubscribers() { | 460 void SupervisedUserSettingsService::InformSubscribers() { |
| 414 if (!IsReady()) | 461 if (!IsReady()) |
| 415 return; | 462 return; |
| 416 | 463 |
| 417 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 464 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
| 418 callback_list_.Notify(settings.get()); | 465 callback_list_.Notify(settings.get()); |
| 419 } | 466 } |
| OLD | NEW |