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

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

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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 #include <utility>
8 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/prefs/pref_value_map.h" 11 #include "base/prefs/pref_value_map.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "components/policy/core/browser/policy_error_map.h" 15 #include "components/policy/core/browser/policy_error_map.h"
15 #include "components/policy/core/common/policy_map.h" 16 #include "components/policy/core/common/policy_map.h"
16 #include "components/search_engines/default_search_manager.h" 17 #include "components/search_engines/default_search_manager.h"
17 #include "components/search_engines/search_engines_pref_names.h" 18 #include "components/search_engines/search_engines_pref_names.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 errors->AddError(key::kDefaultSearchProviderSearchURL, url ? 227 errors->AddError(key::kDefaultSearchProviderSearchURL, url ?
227 IDS_POLICY_INVALID_SEARCH_URL_ERROR : IDS_POLICY_NOT_SPECIFIED_ERROR); 228 IDS_POLICY_INVALID_SEARCH_URL_ERROR : IDS_POLICY_NOT_SPECIFIED_ERROR);
228 return false; 229 return false;
229 } 230 }
230 231
231 void DefaultSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies, 232 void DefaultSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
232 PrefValueMap* prefs) { 233 PrefValueMap* prefs) {
233 if (DefaultSearchProviderIsDisabled(policies)) { 234 if (DefaultSearchProviderIsDisabled(policies)) {
234 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 235 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
235 dict->SetBoolean(DefaultSearchManager::kDisabledByPolicy, true); 236 dict->SetBoolean(DefaultSearchManager::kDisabledByPolicy, true);
236 DefaultSearchManager::AddPrefValueToMap(dict.Pass(), prefs); 237 DefaultSearchManager::AddPrefValueToMap(std::move(dict), prefs);
237 return; 238 return;
238 } 239 }
239 240
240 // The search URL is required. The other entries are optional. Just make 241 // The search URL is required. The other entries are optional. Just make
241 // sure that they are all specified via policy, so that the regular prefs 242 // sure that they are all specified via policy, so that the regular prefs
242 // aren't used. 243 // aren't used.
243 const base::Value* dummy; 244 const base::Value* dummy;
244 std::string url; 245 std::string url;
245 if (!DefaultSearchURLIsValid(policies, &dummy, &url)) 246 if (!DefaultSearchURLIsValid(policies, &dummy, &url))
246 return; 247 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 dict->GetString(DefaultSearchManager::kURL, &url); 291 dict->GetString(DefaultSearchManager::kURL, &url);
291 292
292 std::string host(GURL(url).host()); 293 std::string host(GURL(url).host());
293 if (host.empty()) 294 if (host.empty())
294 host = "_"; 295 host = "_";
295 if (name.empty()) 296 if (name.empty())
296 dict->SetString(DefaultSearchManager::kShortName, host); 297 dict->SetString(DefaultSearchManager::kShortName, host);
297 if (keyword.empty()) 298 if (keyword.empty())
298 dict->SetString(DefaultSearchManager::kKeyword, host); 299 dict->SetString(DefaultSearchManager::kKeyword, host);
299 300
300 DefaultSearchManager::AddPrefValueToMap(dict.Pass(), prefs); 301 DefaultSearchManager::AddPrefValueToMap(std::move(dict), prefs);
301 } 302 }
302 303
303 bool DefaultSearchPolicyHandler::CheckIndividualPolicies( 304 bool DefaultSearchPolicyHandler::CheckIndividualPolicies(
304 const PolicyMap& policies, 305 const PolicyMap& policies,
305 PolicyErrorMap* errors) { 306 PolicyErrorMap* errors) {
306 for (std::vector<TypeCheckingPolicyHandler*>::const_iterator handler = 307 for (std::vector<TypeCheckingPolicyHandler*>::const_iterator handler =
307 handlers_.begin(); 308 handlers_.begin();
308 handler != handlers_.end(); ++handler) { 309 handler != handlers_.end(); ++handler) {
309 if (!(*handler)->CheckPolicySettings(policies, errors)) 310 if (!(*handler)->CheckPolicySettings(policies, errors))
310 return false; 311 return false;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 void DefaultSearchPolicyHandler::EnsureListPrefExists( 364 void DefaultSearchPolicyHandler::EnsureListPrefExists(
364 PrefValueMap* prefs, 365 PrefValueMap* prefs,
365 const std::string& path) { 366 const std::string& path) {
366 base::Value* value; 367 base::Value* value;
367 base::ListValue* list_value; 368 base::ListValue* list_value;
368 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value)) 369 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value))
369 prefs->SetValue(path, make_scoped_ptr(new base::ListValue())); 370 prefs->SetValue(path, make_scoped_ptr(new base::ListValue()));
370 } 371 }
371 372
372 } // namespace policy 373 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698