| Index: chrome/browser/policy/policy_browsertest.cc
|
| diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
|
| index ff79bcb42760ce046570e893be665489895cb74c..8e53fa850bce2a796bac6cf24bbcffd276cefbf8 100644
|
| --- a/chrome/browser/policy/policy_browsertest.cc
|
| +++ b/chrome/browser/policy/policy_browsertest.cc
|
| @@ -648,6 +648,55 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
|
| EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL());
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(PolicyTest, ForceSafeSearch) {
|
| + // Verifies that requests to Google Search engine with the SafeSearch
|
| + // enabled set the safe=active&ssui=on parameters at the end of the query.
|
| + TemplateURLService* service = TemplateURLServiceFactory::GetForProfile(
|
| + browser()->profile());
|
| + ui_test_utils::WaitForTemplateURLServiceToLoad(service);
|
| +
|
| + // First check that nothing happens.
|
| + chrome::FocusLocationBar(browser());
|
| + LocationBar* location_bar = browser()->window()->GetLocationBar();
|
| + ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/");
|
| + OmniboxEditModel* model = location_bar->GetLocationEntry()->model();
|
| + EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid());
|
| + content::WebContents* web_contents = chrome::GetActiveWebContents(browser());
|
| + GURL expected_without("http://google.com/");
|
| + EXPECT_EQ(expected_without, web_contents->GetURL());
|
| +
|
| + PrefService* prefs = browser()->profile()->GetPrefs();
|
| + EXPECT_FALSE(prefs->IsManagedPreference(prefs::kForceSafeSearch));
|
| + EXPECT_FALSE(prefs->GetBoolean(prefs::kForceSafeSearch));
|
| +
|
| + // Override the default SafeSearch setting using policies.
|
| + PolicyMap policies;
|
| + policies.Set(key::kForceSafeSearch, POLICY_LEVEL_MANDATORY,
|
| + POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
|
| + provider_.UpdateChromePolicy(policies);
|
| +
|
| + EXPECT_TRUE(prefs->IsManagedPreference(prefs::kForceSafeSearch));
|
| + EXPECT_TRUE(prefs->GetBoolean(prefs::kForceSafeSearch));
|
| +
|
| + content::WindowedNotificationObserver observer(
|
| + content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
|
| + content::NotificationService::AllSources());
|
| +
|
| + // Verify that searching from google.com works.
|
| + chrome::FocusLocationBar(browser());
|
| + location_bar = browser()->window()->GetLocationBar();
|
| + ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/");
|
| + observer.Wait();
|
| + model = location_bar->GetLocationEntry()->model();
|
| + EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid());
|
| + web_contents = chrome::GetActiveWebContents(browser());
|
| + std::string expected_url("http://google.com/?");
|
| + expected_url += std::string(chrome::kSafeSearchSafeParameter) + "&" +
|
| + chrome::kSafeSearchSsuiParameter;
|
| + GURL expected_with_parameters(expected_url);
|
| + EXPECT_EQ(expected_with_parameters, web_contents->GetURL());
|
| +}
|
| +
|
| IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) {
|
| CommandLine::ForCurrentProcess()->AppendSwitch(
|
| switches::kEnableInstantExtendedAPI);
|
|
|