OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search_engines/default_search_policy_handler.h" | 5 #include "chrome/browser/search_engines/default_search_policy_handler.h" |
6 | 6 |
7 #include "base/prefs/pref_value_map.h" | 7 #include "base/prefs/pref_value_map.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 const PolicyMap& policies, | 431 const PolicyMap& policies, |
432 const base::Value** url_value, | 432 const base::Value** url_value, |
433 std::string* url_string) { | 433 std::string* url_string) { |
434 *url_value = policies.GetValue(key::kDefaultSearchProviderSearchURL); | 434 *url_value = policies.GetValue(key::kDefaultSearchProviderSearchURL); |
435 if (!*url_value || !(*url_value)->GetAsString(url_string) || | 435 if (!*url_value || !(*url_value)->GetAsString(url_string) || |
436 url_string->empty()) | 436 url_string->empty()) |
437 return false; | 437 return false; |
438 TemplateURLData data; | 438 TemplateURLData data; |
439 data.SetURL(*url_string); | 439 data.SetURL(*url_string); |
440 SearchTermsData search_terms_data; | 440 SearchTermsData search_terms_data; |
441 return TemplateURL(NULL, data).SupportsReplacement(search_terms_data); | 441 return TemplateURL(data).SupportsReplacement(search_terms_data); |
442 } | 442 } |
443 | 443 |
444 void DefaultSearchPolicyHandler::EnsureStringPrefExists( | 444 void DefaultSearchPolicyHandler::EnsureStringPrefExists( |
445 PrefValueMap* prefs, | 445 PrefValueMap* prefs, |
446 const std::string& path) { | 446 const std::string& path) { |
447 std::string value; | 447 std::string value; |
448 if (!prefs->GetString(path, &value)) | 448 if (!prefs->GetString(path, &value)) |
449 prefs->SetString(path, value); | 449 prefs->SetString(path, value); |
450 } | 450 } |
451 | 451 |
452 void DefaultSearchPolicyHandler::EnsureListPrefExists( | 452 void DefaultSearchPolicyHandler::EnsureListPrefExists( |
453 PrefValueMap* prefs, | 453 PrefValueMap* prefs, |
454 const std::string& path) { | 454 const std::string& path) { |
455 base::Value* value; | 455 base::Value* value; |
456 base::ListValue* list_value; | 456 base::ListValue* list_value; |
457 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value)) | 457 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value)) |
458 prefs->SetValue(path, new base::ListValue()); | 458 prefs->SetValue(path, new base::ListValue()); |
459 } | 459 } |
460 | 460 |
461 } // namespace policy | 461 } // namespace policy |
OLD | NEW |