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

Side by Side Diff: components/search_engines/default_search_policy_handler.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 6 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
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 "components/search_engines/default_search_policy_handler.h" 5 #include "components/search_engines/default_search_policy_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 18 matching lines...) Expand all
29 const char* policy_name, 29 const char* policy_name,
30 const char* key, 30 const char* key,
31 base::DictionaryValue* dict) { 31 base::DictionaryValue* dict) {
32 DCHECK(dict); 32 DCHECK(dict);
33 const base::Value* policy_value = policies.GetValue(policy_name); 33 const base::Value* policy_value = policies.GetValue(policy_name);
34 const base::ListValue* policy_list = NULL; 34 const base::ListValue* policy_list = NULL;
35 if (policy_value) { 35 if (policy_value) {
36 bool is_list = policy_value->GetAsList(&policy_list); 36 bool is_list = policy_value->GetAsList(&policy_list);
37 DCHECK(is_list); 37 DCHECK(is_list);
38 } 38 }
39 dict->Set(key, policy_list ? policy_list->DeepCopy() : new base::ListValue()); 39 dict->Set(key, policy_list ? base::MakeUnique<base::ListValue>(*policy_list)
40 : base::MakeUnique<base::ListValue>());
40 } 41 }
41 42
42 // Extracts a string from a policy value and adds it to a pref dictionary. 43 // Extracts a string from a policy value and adds it to a pref dictionary.
43 void SetStringInPref(const PolicyMap& policies, 44 void SetStringInPref(const PolicyMap& policies,
44 const char* policy_name, 45 const char* policy_name,
45 const char* key, 46 const char* key,
46 base::DictionaryValue* dict) { 47 base::DictionaryValue* dict) {
47 DCHECK(dict); 48 DCHECK(dict);
48 const base::Value* policy_value = policies.GetValue(policy_name); 49 const base::Value* policy_value = policies.GetValue(policy_name);
49 std::string str; 50 std::string str;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void DefaultSearchPolicyHandler::EnsureListPrefExists( 273 void DefaultSearchPolicyHandler::EnsureListPrefExists(
273 PrefValueMap* prefs, 274 PrefValueMap* prefs,
274 const std::string& path) { 275 const std::string& path) {
275 base::Value* value; 276 base::Value* value;
276 base::ListValue* list_value; 277 base::ListValue* list_value;
277 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value)) 278 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value))
278 prefs->SetValue(path, base::MakeUnique<base::ListValue>()); 279 prefs->SetValue(path, base::MakeUnique<base::ListValue>());
279 } 280 }
280 281
281 } // namespace policy 282 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698