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

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

Issue 2201373002: Ignore invalid managed user settings values gracefully. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: response to code review comments Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698