| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 Value::TYPE_STRING }, | 80 Value::TYPE_STRING }, |
| 81 { key::kDefaultSearchProviderInstantURL, | 81 { key::kDefaultSearchProviderInstantURL, |
| 82 prefs::kDefaultSearchProviderInstantURL, | 82 prefs::kDefaultSearchProviderInstantURL, |
| 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, |
| 91 prefs::kDefaultSearchProviderAlternateURLs, |
| 92 Value::TYPE_STRING }, |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 // List of entries determining which proxy policies can be specified, depending | 95 // List of entries determining which proxy policies can be specified, depending |
| 93 // on the ProxyMode. | 96 // on the ProxyMode. |
| 94 const ProxyModeValidationEntry kProxyModeValidationMap[] = { | 97 const ProxyModeValidationEntry kProxyModeValidationMap[] = { |
| 95 { ProxyPrefs::kDirectProxyModeName, | 98 { ProxyPrefs::kDirectProxyModeName, |
| 96 false, false, false, IDS_POLICY_PROXY_MODE_DISABLED_ERROR }, | 99 false, false, false, IDS_POLICY_PROXY_MODE_DISABLED_ERROR }, |
| 97 { ProxyPrefs::kAutoDetectProxyModeName, | 100 { ProxyPrefs::kAutoDetectProxyModeName, |
| 98 false, false, false, IDS_POLICY_PROXY_MODE_AUTO_DETECT_ERROR }, | 101 false, false, false, IDS_POLICY_PROXY_MODE_AUTO_DETECT_ERROR }, |
| 99 { ProxyPrefs::kPacScriptProxyModeName, | 102 { ProxyPrefs::kPacScriptProxyModeName, |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 prefs->SetBoolean(prefs::kDefaultSearchProviderEnabled, false); | 645 prefs->SetBoolean(prefs::kDefaultSearchProviderEnabled, false); |
| 643 | 646 |
| 644 // If default search is disabled, the other fields are ignored. | 647 // If default search is disabled, the other fields are ignored. |
| 645 prefs->SetString(prefs::kDefaultSearchProviderName, std::string()); | 648 prefs->SetString(prefs::kDefaultSearchProviderName, std::string()); |
| 646 prefs->SetString(prefs::kDefaultSearchProviderSearchURL, std::string()); | 649 prefs->SetString(prefs::kDefaultSearchProviderSearchURL, std::string()); |
| 647 prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, std::string()); | 650 prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, std::string()); |
| 648 prefs->SetString(prefs::kDefaultSearchProviderIconURL, std::string()); | 651 prefs->SetString(prefs::kDefaultSearchProviderIconURL, std::string()); |
| 649 prefs->SetString(prefs::kDefaultSearchProviderEncodings, std::string()); | 652 prefs->SetString(prefs::kDefaultSearchProviderEncodings, std::string()); |
| 650 prefs->SetString(prefs::kDefaultSearchProviderKeyword, std::string()); | 653 prefs->SetString(prefs::kDefaultSearchProviderKeyword, std::string()); |
| 651 prefs->SetString(prefs::kDefaultSearchProviderInstantURL, std::string()); | 654 prefs->SetString(prefs::kDefaultSearchProviderInstantURL, std::string()); |
| 655 prefs->SetString(prefs::kDefaultSearchProviderAlternateURLs, std::string()); |
| 652 } else { | 656 } else { |
| 653 // The search URL is required. The other entries are optional. Just make | 657 // The search URL is required. The other entries are optional. Just make |
| 654 // sure that they are all specified via policy, so that the regular prefs | 658 // sure that they are all specified via policy, so that the regular prefs |
| 655 // aren't used. | 659 // aren't used. |
| 656 const Value* dummy; | 660 const Value* dummy; |
| 657 std::string url; | 661 std::string url; |
| 658 if (DefaultSearchURLIsValid(policies, &dummy, &url)) { | 662 if (DefaultSearchURLIsValid(policies, &dummy, &url)) { |
| 659 for (std::vector<ConfigurationPolicyHandler*>::const_iterator handler = | 663 for (std::vector<ConfigurationPolicyHandler*>::const_iterator handler = |
| 660 handlers_.begin(); handler != handlers_.end(); ++handler) | 664 handlers_.begin(); handler != handlers_.end(); ++handler) |
| 661 (*handler)->ApplyPolicySettings(policies, prefs); | 665 (*handler)->ApplyPolicySettings(policies, prefs); |
| 662 | 666 |
| 663 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderSuggestURL); | 667 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderSuggestURL); |
| 664 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderIconURL); | 668 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderIconURL); |
| 665 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderEncodings); | 669 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderEncodings); |
| 666 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderKeyword); | 670 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderKeyword); |
| 667 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderInstantURL); | 671 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderInstantURL); |
| 672 EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderAlternateURLs); |
| 668 | 673 |
| 669 // For the name and keyword, default to the host if not specified. If | 674 // For the name and keyword, default to the host if not specified. If |
| 670 // there is no host (file: URLs? Not sure), use "_" to guarantee that the | 675 // there is no host (file: URLs? Not sure), use "_" to guarantee that the |
| 671 // keyword is non-empty. | 676 // keyword is non-empty. |
| 672 std::string name, keyword; | 677 std::string name, keyword; |
| 673 std::string host(GURL(url).host()); | 678 std::string host(GURL(url).host()); |
| 674 if (host.empty()) | 679 if (host.empty()) |
| 675 host = "_"; | 680 host = "_"; |
| 676 if (!prefs->GetString(prefs::kDefaultSearchProviderName, &name) || | 681 if (!prefs->GetString(prefs::kDefaultSearchProviderName, &name) || |
| 677 name.empty()) | 682 name.empty()) |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 errors->AddError(policy_name(), | 1273 errors->AddError(policy_name(), |
| 1269 IDS_POLICY_OUT_OF_RANGE_ERROR, | 1274 IDS_POLICY_OUT_OF_RANGE_ERROR, |
| 1270 base::IntToString(restore_value)); | 1275 base::IntToString(restore_value)); |
| 1271 } | 1276 } |
| 1272 } | 1277 } |
| 1273 } | 1278 } |
| 1274 return true; | 1279 return true; |
| 1275 } | 1280 } |
| 1276 | 1281 |
| 1277 } // namespace policy | 1282 } // namespace policy |
| OLD | NEW |