Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 11186002: Add a SafeSearch preference, policy and implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fine grain parameter match + more tests. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 494fe79afd276ac25d0e72cba039d717eb1581db..b8fc4f83f15da5e346e6b3fdad5d383981b5b7d8 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -647,6 +647,55 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL());
}
+IN_PROC_BROWSER_TEST_F(PolicyTest, SafeSearch) {
Joao da Silva 2012/10/19 10:00:38 ForceSafeSeach
Sergiu 2012/10/19 12:00:18 Done.
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698