OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/policy/configuration_policy_handler.h" | 5 #include "chrome/browser/policy/configuration_policy_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 Value::TYPE_STRING }, | 83 Value::TYPE_STRING }, |
84 { key::kDefaultSearchProviderIconURL, | 84 { key::kDefaultSearchProviderIconURL, |
85 prefs::kDefaultSearchProviderIconURL, | 85 prefs::kDefaultSearchProviderIconURL, |
86 Value::TYPE_STRING }, | 86 Value::TYPE_STRING }, |
87 { key::kDefaultSearchProviderEncodings, | 87 { key::kDefaultSearchProviderEncodings, |
88 prefs::kDefaultSearchProviderEncodings, | 88 prefs::kDefaultSearchProviderEncodings, |
89 Value::TYPE_LIST }, | 89 Value::TYPE_LIST }, |
90 { key::kDefaultSearchProviderAlternateURLs, | 90 { key::kDefaultSearchProviderAlternateURLs, |
91 prefs::kDefaultSearchProviderAlternateURLs, | 91 prefs::kDefaultSearchProviderAlternateURLs, |
92 Value::TYPE_LIST }, | 92 Value::TYPE_LIST }, |
| 93 { key::kDefaultSearchProviderSearchTermsReplacementKey, |
| 94 prefs::kDefaultSearchProviderSearchTermsReplacementKey, |
| 95 Value::TYPE_STRING }, |
93 }; | 96 }; |
94 | 97 |
95 // List of entries determining which proxy policies can be specified, depending | 98 // List of entries determining which proxy policies can be specified, depending |
96 // on the ProxyMode. | 99 // on the ProxyMode. |
97 const ProxyModeValidationEntry kProxyModeValidationMap[] = { | 100 const ProxyModeValidationEntry kProxyModeValidationMap[] = { |
98 { ProxyPrefs::kDirectProxyModeName, | 101 { ProxyPrefs::kDirectProxyModeName, |
99 false, false, false, IDS_POLICY_PROXY_MODE_DISABLED_ERROR }, | 102 false, false, false, IDS_POLICY_PROXY_MODE_DISABLED_ERROR }, |
100 { ProxyPrefs::kAutoDetectProxyModeName, | 103 { ProxyPrefs::kAutoDetectProxyModeName, |
101 false, false, false, IDS_POLICY_PROXY_MODE_AUTO_DETECT_ERROR }, | 104 false, false, false, IDS_POLICY_PROXY_MODE_AUTO_DETECT_ERROR }, |
102 { ProxyPrefs::kPacScriptProxyModeName, | 105 { ProxyPrefs::kPacScriptProxyModeName, |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 // If default search is disabled, the other fields are ignored. | 728 // If default search is disabled, the other fields are ignored. |
726 prefs->SetString(prefs::kDefaultSearchProviderName, std::string()); | 729 prefs->SetString(prefs::kDefaultSearchProviderName, std::string()); |
727 prefs->SetString(prefs::kDefaultSearchProviderSearchURL, std::string()); | 730 prefs->SetString(prefs::kDefaultSearchProviderSearchURL, std::string()); |
728 prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, std::string()); | 731 prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, std::string()); |
729 prefs->SetString(prefs::kDefaultSearchProviderIconURL, std::string()); | 732 prefs->SetString(prefs::kDefaultSearchProviderIconURL, std::string()); |
730 prefs->SetString(prefs::kDefaultSearchProviderEncodings, std::string()); | 733 prefs->SetString(prefs::kDefaultSearchProviderEncodings, std::string()); |
731 prefs->SetString(prefs::kDefaultSearchProviderKeyword, std::string()); | 734 prefs->SetString(prefs::kDefaultSearchProviderKeyword, std::string()); |
732 prefs->SetString(prefs::kDefaultSearchProviderInstantURL, std::string()); | 735 prefs->SetString(prefs::kDefaultSearchProviderInstantURL, std::string()); |
733 prefs->SetValue(prefs::kDefaultSearchProviderAlternateURLs, | 736 prefs->SetValue(prefs::kDefaultSearchProviderAlternateURLs, |
734 new ListValue()); | 737 new ListValue()); |
| 738 prefs->SetString(prefs::kDefaultSearchProviderSearchTermsReplacementKey, |
| 739 std::string()); |
735 } else { | 740 } else { |
736 // The search URL is required. The other entries are optional. Just make | 741 // The search URL is required. The other entries are optional. Just make |
737 // sure that they are all specified via policy, so that the regular prefs | 742 // sure that they are all specified via policy, so that the regular prefs |
738 // aren't used. | 743 // aren't used. |
739 const Value* dummy; | 744 const Value* dummy; |
740 std::string url; | 745 std::string url; |
741 if (DefaultSearchURLIsValid(policies, &dummy, &url)) { | 746 if (DefaultSearchURLIsValid(policies, &dummy, &url)) { |
742 for (std::vector<ConfigurationPolicyHandler*>::const_iterator handler = | 747 for (std::vector<ConfigurationPolicyHandler*>::const_iterator handler = |
743 handlers_.begin(); handler != handlers_.end(); ++handler) | 748 handlers_.begin(); handler != handlers_.end(); ++handler) |
744 (*handler)->ApplyPolicySettings(policies, prefs); | 749 (*handler)->ApplyPolicySettings(policies, prefs); |
745 | 750 |
746 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderSuggestURL); | 751 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderSuggestURL); |
747 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderIconURL); | 752 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderIconURL); |
748 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderEncodings); | 753 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderEncodings); |
749 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderKeyword); | 754 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderKeyword); |
750 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderInstantURL); | 755 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderInstantURL); |
751 EnsureListPrefExists(prefs, prefs::kDefaultSearchProviderAlternateURLs); | 756 EnsureListPrefExists(prefs, prefs::kDefaultSearchProviderAlternateURLs); |
| 757 EnsureStringPrefExists(prefs, |
| 758 prefs::kDefaultSearchProviderSearchTermsReplacementKey); |
752 | 759 |
753 // For the name and keyword, default to the host if not specified. If | 760 // For the name and keyword, default to the host if not specified. If |
754 // there is no host (file: URLs? Not sure), use "_" to guarantee that the | 761 // there is no host (file: URLs? Not sure), use "_" to guarantee that the |
755 // keyword is non-empty. | 762 // keyword is non-empty. |
756 std::string name, keyword; | 763 std::string name, keyword; |
757 std::string host(GURL(url).host()); | 764 std::string host(GURL(url).host()); |
758 if (host.empty()) | 765 if (host.empty()) |
759 host = "_"; | 766 host = "_"; |
760 if (!prefs->GetString(prefs::kDefaultSearchProviderName, &name) || | 767 if (!prefs->GetString(prefs::kDefaultSearchProviderName, &name) || |
761 name.empty()) | 768 name.empty()) |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 errors->AddError(policy_name(), | 1368 errors->AddError(policy_name(), |
1362 IDS_POLICY_OUT_OF_RANGE_ERROR, | 1369 IDS_POLICY_OUT_OF_RANGE_ERROR, |
1363 base::IntToString(restore_value)); | 1370 base::IntToString(restore_value)); |
1364 } | 1371 } |
1365 } | 1372 } |
1366 } | 1373 } |
1367 return true; | 1374 return true; |
1368 } | 1375 } |
1369 | 1376 |
1370 } // namespace policy | 1377 } // namespace policy |
OLD | NEW |