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

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: 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 if (!value) {
245 LOG(ERROR) << "Invalid managed user setting value:"
Marc Treib 2016/08/03 14:40:32 DLOG please, so the message won't make it into rel
Marc Treib 2016/08/03 14:40:32 nit: Space after : please
mamir 2016/08/03 15:19:36 Done.
mamir 2016/08/03 15:19:36 Done.
246 << supervised_user_setting.value()
247 << ". Values must be JSON values.";
248 continue;
Bernhard Bauer 2016/08/03 14:44:07 Note that even if we compile out the log, we will
mamir 2016/08/03 15:19:36 Done.
249 }
244 std::string name_suffix = supervised_user_setting.name(); 250 std::string name_suffix = supervised_user_setting.name();
245 std::string name_key = name_suffix; 251 std::string name_key = name_suffix;
246 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); 252 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix);
247 dict->SetWithoutPathExpansion(name_suffix, value.release()); 253 dict->SetWithoutPathExpansion(name_suffix, value.release());
248 if (seen_keys.find(name_key) == seen_keys.end()) { 254 if (seen_keys.find(name_key) == seen_keys.end()) {
249 added_sync_keys.insert(name_key); 255 added_sync_keys.insert(name_key);
250 num_added++; 256 num_added++;
251 } else { 257 } else {
252 num_modified++; 258 num_modified++;
253 } 259 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 return settings; 487 return settings;
482 } 488 }
483 489
484 void SupervisedUserSettingsService::InformSubscribers() { 490 void SupervisedUserSettingsService::InformSubscribers() {
485 if (!IsReady()) 491 if (!IsReady())
486 return; 492 return;
487 493
488 std::unique_ptr<base::DictionaryValue> settings = GetSettings(); 494 std::unique_ptr<base::DictionaryValue> settings = GetSettings();
489 callback_list_.Notify(settings.get()); 495 callback_list_.Notify(settings.get());
490 } 496 }
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