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 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 Clear(); | 234 Clear(); |
| 235 int num_added = 0; | 235 int num_added = 0; |
| 236 int num_modified = 0; | 236 int num_modified = 0; |
| 237 std::set<std::string> added_sync_keys; | 237 std::set<std::string> added_sync_keys; |
| 238 for (const SyncData& sync_data : initial_sync_data) { | 238 for (const SyncData& sync_data : initial_sync_data) { |
| 239 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); | 239 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); |
| 240 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = | 240 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = |
| 241 sync_data.GetSpecifics().managed_user_setting(); | 241 sync_data.GetSpecifics().managed_user_setting(); |
| 242 std::unique_ptr<base::Value> value = | 242 std::unique_ptr<base::Value> value = |
| 243 JSONReader::Read(supervised_user_setting.value()); | 243 JSONReader::Read(supervised_user_setting.value()); |
| 244 // null values will cause Chrome to crash when building the settings | |
| 245 // dictionary. Therefore, we ignore them here to prevent such crashes. | |
|
Marc Treib
2016/08/03 15:30:16
Just say that SetWithoutPathExpansion below requir
| |
| 246 if (!value) { | |
| 247 DLOG(ERROR) << "Invalid managed user setting value: " | |
| 248 << supervised_user_setting.value() | |
| 249 << ". Values must be JSON values."; | |
| 250 continue; | |
| 251 } | |
| 244 std::string name_suffix = supervised_user_setting.name(); | 252 std::string name_suffix = supervised_user_setting.name(); |
| 245 std::string name_key = name_suffix; | 253 std::string name_key = name_suffix; |
| 246 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); | 254 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); |
| 247 dict->SetWithoutPathExpansion(name_suffix, value.release()); | 255 dict->SetWithoutPathExpansion(name_suffix, value.release()); |
| 248 if (seen_keys.find(name_key) == seen_keys.end()) { | 256 if (seen_keys.find(name_key) == seen_keys.end()) { |
| 249 added_sync_keys.insert(name_key); | 257 added_sync_keys.insert(name_key); |
| 250 num_added++; | 258 num_added++; |
| 251 } else { | 259 } else { |
| 252 num_modified++; | 260 num_modified++; |
| 253 } | 261 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 return settings; | 489 return settings; |
| 482 } | 490 } |
| 483 | 491 |
| 484 void SupervisedUserSettingsService::InformSubscribers() { | 492 void SupervisedUserSettingsService::InformSubscribers() { |
| 485 if (!IsReady()) | 493 if (!IsReady()) |
| 486 return; | 494 return; |
| 487 | 495 |
| 488 std::unique_ptr<base::DictionaryValue> settings = GetSettings(); | 496 std::unique_ptr<base::DictionaryValue> settings = GetSettings(); |
| 489 callback_list_.Notify(settings.get()); | 497 callback_list_.Notify(settings.get()); |
| 490 } | 498 } |
| OLD | NEW |