summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/policy')
-rw-r--r--chrome/browser/policy/configuration_policy_handler.cc7
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store_unittest.cc20
-rw-r--r--chrome/browser/policy/policy_browsertest.cc10
3 files changed, 36 insertions, 1 deletions
diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc
index 68536d3..5587cae 100644
--- a/chrome/browser/policy/configuration_policy_handler.cc
+++ b/chrome/browser/policy/configuration_policy_handler.cc
@@ -92,6 +92,9 @@ const DefaultSearchSimplePolicyHandlerEntry kDefaultSearchPolicyMap[] = {
{ key::kDefaultSearchProviderAlternateURLs,
prefs::kDefaultSearchProviderAlternateURLs,
Value::TYPE_LIST },
+ { key::kDefaultSearchProviderSearchTermsReplacementKey,
+ prefs::kDefaultSearchProviderSearchTermsReplacementKey,
+ Value::TYPE_STRING },
};
// List of entries determining which proxy policies can be specified, depending
@@ -825,6 +828,8 @@ void DefaultSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
prefs->SetString(prefs::kDefaultSearchProviderInstantURL, std::string());
prefs->SetValue(prefs::kDefaultSearchProviderAlternateURLs,
new ListValue());
+ prefs->SetString(prefs::kDefaultSearchProviderSearchTermsReplacementKey,
+ std::string());
} else {
// The search URL is required. The other entries are optional. Just make
// sure that they are all specified via policy, so that the regular prefs
@@ -842,6 +847,8 @@ void DefaultSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderKeyword);
EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderInstantURL);
EnsureListPrefExists(prefs, prefs::kDefaultSearchProviderAlternateURLs);
+ EnsureStringPrefExists(prefs,
+ prefs::kDefaultSearchProviderSearchTermsReplacementKey);
// For the name and keyword, default to the host if not specified. If
// there is no host (file: URLs? Not sure), use "_" to guarantee that the
diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
index ccd9a05..0600465 100644
--- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
@@ -567,6 +567,7 @@ class ConfigurationPolicyPrefStoreDefaultSearchTest
static const char* const kIconURL;
static const char* const kName;
static const char* const kKeyword;
+ static const char* const kReplacementKey;
// Build a default search policy by setting search-related keys in |policy| to
// reasonable values. You can update any of the keys after calling this
@@ -586,6 +587,8 @@ const char* const ConfigurationPolicyPrefStoreDefaultSearchTest::kName =
"MyName";
const char* const ConfigurationPolicyPrefStoreDefaultSearchTest::kKeyword =
"MyKeyword";
+const char* const
+ ConfigurationPolicyPrefStoreDefaultSearchTest::kReplacementKey = "espv";
void ConfigurationPolicyPrefStoreDefaultSearchTest::
BuildDefaultSearchPolicy(PolicyMap* policy) {
@@ -608,6 +611,9 @@ void ConfigurationPolicyPrefStoreDefaultSearchTest::
POLICY_SCOPE_USER, encodings);
policy->Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, default_alternate_urls_.DeepCopy());
+ policy->Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ base::Value::CreateStringValue(kReplacementKey));
}
// Checks that if the policy for default search is valid, i.e. there's a
@@ -647,6 +653,11 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) {
EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderAlternateURLs,
&value));
EXPECT_TRUE(base::ListValue().Equals(value));
+
+ EXPECT_TRUE(
+ store_->GetValue(prefs::kDefaultSearchProviderSearchTermsReplacementKey,
+ &value));
+ EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
}
// Checks that for a fully defined search policy, all elements have been
@@ -679,6 +690,11 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, FullyDefined) {
EXPECT_TRUE(store_->GetValue(
prefs::kDefaultSearchProviderAlternateURLs, &value));
EXPECT_TRUE(default_alternate_urls_.Equals(value));
+
+ EXPECT_TRUE(
+ store_->GetValue(prefs::kDefaultSearchProviderSearchTermsReplacementKey,
+ &value));
+ EXPECT_TRUE(base::StringValue(kReplacementKey).Equals(value));
}
// Checks that if the default search policy is missing, that no elements of the
@@ -697,6 +713,8 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MissingUrl) {
EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderEncodings, NULL));
EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderAlternateURLs,
NULL));
+ EXPECT_FALSE(store_->GetValue(
+ prefs::kDefaultSearchProviderSearchTermsReplacementKey, NULL));
}
// Checks that if the default search policy is invalid, that no elements of the
@@ -718,6 +736,8 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, Invalid) {
EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderEncodings, NULL));
EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderAlternateURLs,
NULL));
+ EXPECT_FALSE(store_->GetValue(
+ prefs::kDefaultSearchProviderSearchTermsReplacementKey, NULL));
}
// Checks that if the default search policy is invalid, that no elements of the
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 86cbac3..1bec8bd 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -659,6 +659,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
const std::string kAlternateURL0(
"http://search.example/search#q={searchTerms}");
const std::string kAlternateURL1("http://search.example/#q={searchTerms}");
+ const std::string kSearchTermsReplacementKey("zekey");
TemplateURLService* service = TemplateURLServiceFactory::GetForProfile(
browser()->profile());
@@ -670,7 +671,9 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
EXPECT_FALSE(
default_search->alternate_urls().size() == 2 &&
default_search->alternate_urls()[0] == kAlternateURL0 &&
- default_search->alternate_urls()[1] == kAlternateURL1);
+ default_search->alternate_urls()[1] == kAlternateURL1 &&
+ default_search->search_terms_replacement_key() ==
+ kSearchTermsReplacementKey);
// Override the default search provider using policies.
PolicyMap policies;
@@ -685,6 +688,9 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
alternate_urls->AppendString(kAlternateURL1);
policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, alternate_urls);
+ policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ base::Value::CreateStringValue(kSearchTermsReplacementKey));
provider_.UpdateChromePolicy(policies);
default_search = service->GetDefaultSearchProvider();
ASSERT_TRUE(default_search);
@@ -693,6 +699,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
EXPECT_EQ(2U, default_search->alternate_urls().size());
EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]);
EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]);
+ EXPECT_EQ(kSearchTermsReplacementKey,
+ default_search->search_terms_replacement_key());
// Verify that searching from the omnibox uses kSearchURL.
chrome::FocusLocationBar(browser());