| 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 = 0; |
| 198 // Getting number of atomic setting items. |
| 199 num_before_association = GetAtomicSettings()->size(); |
| 200 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); |
| 201 it.Advance()) { |
| 202 seen_keys.insert(it.key()); |
| 203 } |
| 204 // Getting number of split setting items. |
| 205 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
| 206 it.Advance()) { |
| 207 const base::DictionaryValue* dict = nullptr; |
| 208 it.value().GetAsDictionary(&dict); |
| 209 num_before_association += dict->size(); |
| 210 for (base::DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); |
| 211 jt.Advance()) { |
| 212 seen_keys.insert(MakeSplitSettingKey(it.key(), jt.key())); |
| 213 } |
| 214 } |
| 215 |
| 216 int num_deleted = num_before_association; |
| 217 // Getting number of queued items. |
| 218 base::DictionaryValue* queued_items = GetQueuedItems(); |
| 219 num_before_association += queued_items->size(); |
| 220 |
| 196 // Clear all atomic and split settings, then recreate them from Sync data. | 221 // Clear all atomic and split settings, then recreate them from Sync data. |
| 197 Clear(); | 222 Clear(); |
| 223 int num_added = 0; |
| 224 int num_modified = 0; |
| 225 std::set<std::string> added_sync_keys; |
| 198 for (const SyncData& sync_data : initial_sync_data) { | 226 for (const SyncData& sync_data : initial_sync_data) { |
| 199 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); | 227 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); |
| 200 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = | 228 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = |
| 201 sync_data.GetSpecifics().managed_user_setting(); | 229 sync_data.GetSpecifics().managed_user_setting(); |
| 202 scoped_ptr<base::Value> value = | 230 scoped_ptr<base::Value> value = |
| 203 JSONReader::Read(supervised_user_setting.value()); | 231 JSONReader::Read(supervised_user_setting.value()); |
| 204 std::string name_suffix = supervised_user_setting.name(); | 232 std::string name_suffix = supervised_user_setting.name(); |
| 233 std::string name_key = name_suffix; |
| 205 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); | 234 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); |
| 206 dict->SetWithoutPathExpansion(name_suffix, value.release()); | 235 dict->SetWithoutPathExpansion(name_suffix, value.release()); |
| 236 if (seen_keys.find(name_key) == seen_keys.end()) { |
| 237 added_sync_keys.insert(name_key); |
| 238 num_added++; |
| 239 } else { |
| 240 num_modified++; |
| 241 } |
| 207 } | 242 } |
| 243 |
| 244 num_deleted -= num_modified; |
| 245 |
| 208 store_->ReportValueChanged(kAtomicSettings, | 246 store_->ReportValueChanged(kAtomicSettings, |
| 209 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 247 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 210 store_->ReportValueChanged(kSplitSettings, | 248 store_->ReportValueChanged(kSplitSettings, |
| 211 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 249 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 212 InformSubscribers(); | 250 InformSubscribers(); |
| 213 | 251 |
| 214 // Upload all the queued up items (either with an ADD or an UPDATE action, | 252 // 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. | 253 // depending on whether they already exist) and move them to split settings. |
| 216 SyncChangeList change_list; | 254 SyncChangeList change_list; |
| 217 base::DictionaryValue* queued_items = GetQueuedItems(); | |
| 218 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); | 255 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); |
| 219 it.Advance()) { | 256 it.Advance()) { |
| 220 std::string key_suffix = it.key(); | 257 std::string key_suffix = it.key(); |
| 258 std::string name_key = key_suffix; |
| 221 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); | 259 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); |
| 222 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); | 260 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); |
| 223 SyncChange::SyncChangeType change_type = | 261 SyncChange::SyncChangeType change_type = |
| 224 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 262 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
| 225 : SyncChange::ACTION_ADD; | 263 : SyncChange::ACTION_ADD; |
| 226 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 264 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
| 227 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); | 265 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); |
| 266 if (added_sync_keys.find(name_key) != added_sync_keys.end()) { |
| 267 num_added--; |
| 268 } |
| 228 } | 269 } |
| 229 queued_items->Clear(); | 270 queued_items->Clear(); |
| 230 | 271 |
| 231 SyncMergeResult result(SUPERVISED_USER_SETTINGS); | 272 SyncMergeResult result(SUPERVISED_USER_SETTINGS); |
| 232 // Process all the accumulated changes from the queued items. | 273 // Process all the accumulated changes from the queued items. |
| 233 if (change_list.size() > 0) { | 274 if (change_list.size() > 0) { |
| 234 store_->ReportValueChanged(kQueuedItems, | 275 store_->ReportValueChanged(kQueuedItems, |
| 235 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 276 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 236 result.set_error( | 277 result.set_error( |
| 237 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); | 278 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); |
| 238 } | 279 } |
| 239 | 280 |
| 240 // TODO(bauerb): Statistics? | 281 // Calculating number of items after association. |
| 282 int num_after_association = 0; |
| 283 // Getting number of atomic setting items. |
| 284 num_after_association = GetAtomicSettings()->size(); |
| 285 // Getting number of split setting items. |
| 286 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
| 287 it.Advance()) { |
| 288 const base::DictionaryValue* dict = nullptr; |
| 289 it.value().GetAsDictionary(&dict); |
| 290 num_after_association += dict->size(); |
| 291 } |
| 292 // Getting number of queued items. |
| 293 queued_items = GetQueuedItems(); |
| 294 num_after_association += queued_items->size(); |
| 295 |
| 296 result.set_num_items_added(num_added); |
| 297 result.set_num_items_modified(num_modified); |
| 298 result.set_num_items_deleted(num_deleted); |
| 299 result.set_num_items_before_association(num_before_association); |
| 300 result.set_num_items_after_association(num_after_association); |
| 241 return result; | 301 return result; |
| 242 } | 302 } |
| 243 | 303 |
| 244 void SupervisedUserSettingsService::StopSyncing(ModelType type) { | 304 void SupervisedUserSettingsService::StopSyncing(ModelType type) { |
| 245 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); | 305 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); |
| 246 sync_processor_.reset(); | 306 sync_processor_.reset(); |
| 247 error_handler_.reset(); | 307 error_handler_.reset(); |
| 248 } | 308 } |
| 249 | 309 |
| 250 SyncDataList SupervisedUserSettingsService::GetAllSyncData( | 310 SyncDataList SupervisedUserSettingsService::GetAllSyncData( |
| 251 ModelType type) const { | 311 ModelType type) const { |
| 252 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); | 312 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); |
| 253 SyncDataList data; | 313 SyncDataList data; |
| 254 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); | 314 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); |
| 255 it.Advance()) { | 315 it.Advance()) { |
| 256 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); | 316 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); |
| 257 } | 317 } |
| 258 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); | 318 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
| 259 it.Advance()) { | 319 it.Advance()) { |
| 260 const base::DictionaryValue* dict = NULL; | 320 const base::DictionaryValue* dict = nullptr; |
| 261 it.value().GetAsDictionary(&dict); | 321 it.value().GetAsDictionary(&dict); |
| 262 for (base::DictionaryValue::Iterator jt(*dict); | 322 for (base::DictionaryValue::Iterator jt(*dict); |
| 263 !jt.IsAtEnd(); jt.Advance()) { | 323 !jt.IsAtEnd(); jt.Advance()) { |
| 264 data.push_back(CreateSyncDataForSetting( | 324 data.push_back(CreateSyncDataForSetting( |
| 265 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); | 325 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); |
| 266 } | 326 } |
| 267 } | 327 } |
| 268 DCHECK_EQ(0u, GetQueuedItems()->size()); | 328 DCHECK_EQ(0u, GetQueuedItems()->size()); |
| 269 return data; | 329 return data; |
| 270 } | 330 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 291 } else { | 351 } else { |
| 292 DLOG_IF(WARNING, change_type == SyncChange::ACTION_UPDATE) | 352 DLOG_IF(WARNING, change_type == SyncChange::ACTION_UPDATE) |
| 293 << "Value for key " << key << " doesn't exist yet"; | 353 << "Value for key " << key << " doesn't exist yet"; |
| 294 } | 354 } |
| 295 dict->SetWithoutPathExpansion(key, value.release()); | 355 dict->SetWithoutPathExpansion(key, value.release()); |
| 296 break; | 356 break; |
| 297 } | 357 } |
| 298 case SyncChange::ACTION_DELETE: { | 358 case SyncChange::ACTION_DELETE: { |
| 299 DLOG_IF(WARNING, !dict->HasKey(key)) << "Trying to delete nonexistent " | 359 DLOG_IF(WARNING, !dict->HasKey(key)) << "Trying to delete nonexistent " |
| 300 << "key " << key; | 360 << "key " << key; |
| 301 dict->RemoveWithoutPathExpansion(key, NULL); | 361 dict->RemoveWithoutPathExpansion(key, nullptr); |
| 302 break; | 362 break; |
| 303 } | 363 } |
| 304 case SyncChange::ACTION_INVALID: { | 364 case SyncChange::ACTION_INVALID: { |
| 305 NOTREACHED(); | 365 NOTREACHED(); |
| 306 break; | 366 break; |
| 307 } | 367 } |
| 308 } | 368 } |
| 309 } | 369 } |
| 310 store_->ReportValueChanged(kAtomicSettings, | 370 store_->ReportValueChanged(kAtomicSettings, |
| 311 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 371 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 330 } | 390 } |
| 331 | 391 |
| 332 // TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. | 392 // TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. |
| 333 // Remove (or change back to DCHECK) once the bug is fixed. | 393 // Remove (or change back to DCHECK) once the bug is fixed. |
| 334 CHECK(IsReady()); | 394 CHECK(IsReady()); |
| 335 InformSubscribers(); | 395 InformSubscribers(); |
| 336 } | 396 } |
| 337 | 397 |
| 338 base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary( | 398 base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary( |
| 339 const std::string& key) const { | 399 const std::string& key) const { |
| 340 base::Value* value = NULL; | 400 base::Value* value = nullptr; |
| 341 base::DictionaryValue* dict = NULL; | 401 base::DictionaryValue* dict = nullptr; |
| 342 if (store_->GetMutableValue(key, &value)) { | 402 if (store_->GetMutableValue(key, &value)) { |
| 343 bool success = value->GetAsDictionary(&dict); | 403 bool success = value->GetAsDictionary(&dict); |
| 344 DCHECK(success); | 404 DCHECK(success); |
| 345 } else { | 405 } else { |
| 346 dict = new base::DictionaryValue; | 406 dict = new base::DictionaryValue; |
| 347 store_->SetValue(key, make_scoped_ptr(dict), | 407 store_->SetValue(key, make_scoped_ptr(dict), |
| 348 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 408 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 349 } | 409 } |
| 350 | 410 |
| 351 return dict; | 411 return dict; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 365 } | 425 } |
| 366 | 426 |
| 367 base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( | 427 base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( |
| 368 std::string* key) const { | 428 std::string* key) const { |
| 369 size_t pos = key->find_first_of(kSplitSettingKeySeparator); | 429 size_t pos = key->find_first_of(kSplitSettingKeySeparator); |
| 370 if (pos == std::string::npos) | 430 if (pos == std::string::npos) |
| 371 return GetAtomicSettings(); | 431 return GetAtomicSettings(); |
| 372 | 432 |
| 373 base::DictionaryValue* split_settings = GetSplitSettings(); | 433 base::DictionaryValue* split_settings = GetSplitSettings(); |
| 374 std::string prefix = key->substr(0, pos); | 434 std::string prefix = key->substr(0, pos); |
| 375 base::DictionaryValue* dict = NULL; | 435 base::DictionaryValue* dict = nullptr; |
| 376 if (!split_settings->GetDictionary(prefix, &dict)) { | 436 if (!split_settings->GetDictionary(prefix, &dict)) { |
| 377 dict = new base::DictionaryValue; | 437 dict = new base::DictionaryValue; |
| 378 DCHECK(!split_settings->HasKey(prefix)); | 438 DCHECK(!split_settings->HasKey(prefix)); |
| 379 split_settings->Set(prefix, dict); | 439 split_settings->Set(prefix, dict); |
| 380 } | 440 } |
| 381 key->erase(0, pos + 1); | 441 key->erase(0, pos + 1); |
| 382 return dict; | 442 return dict; |
| 383 } | 443 } |
| 384 | 444 |
| 385 scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { | 445 scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 410 return settings; | 470 return settings; |
| 411 } | 471 } |
| 412 | 472 |
| 413 void SupervisedUserSettingsService::InformSubscribers() { | 473 void SupervisedUserSettingsService::InformSubscribers() { |
| 414 if (!IsReady()) | 474 if (!IsReady()) |
| 415 return; | 475 return; |
| 416 | 476 |
| 417 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 477 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
| 418 callback_list_.Notify(settings.get()); | 478 callback_list_.Notify(settings.get()); |
| 419 } | 479 } |
| OLD | NEW |