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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); | 640 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); |
641 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 641 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
642 provider_.UpdateChromePolicy(policies); | 642 provider_.UpdateChromePolicy(policies); |
643 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 643 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
644 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 644 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
645 // This means that submitting won't trigger any action. | 645 // This means that submitting won't trigger any action. |
646 EXPECT_FALSE(model->CurrentMatch().destination_url.is_valid()); | 646 EXPECT_FALSE(model->CurrentMatch().destination_url.is_valid()); |
647 EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL()); | 647 EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL()); |
648 } | 648 } |
649 | 649 |
650 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.
| |
651 // Verifies that requests to Google Search engine with the SafeSearch | |
652 // enabled set the safe=active&ssui=on parameters at the end of the query. | |
653 TemplateURLService* service = TemplateURLServiceFactory::GetForProfile( | |
654 browser()->profile()); | |
655 ui_test_utils::WaitForTemplateURLServiceToLoad(service); | |
656 | |
657 // First check that nothing happens. | |
658 chrome::FocusLocationBar(browser()); | |
659 LocationBar* location_bar = browser()->window()->GetLocationBar(); | |
660 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); | |
661 OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); | |
662 EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); | |
663 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); | |
664 GURL expected_without("http://google.com/"); | |
665 EXPECT_EQ(expected_without, web_contents->GetURL()); | |
666 | |
667 PrefService* prefs = browser()->profile()->GetPrefs(); | |
668 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kForceSafeSearch)); | |
669 EXPECT_FALSE(prefs->GetBoolean(prefs::kForceSafeSearch)); | |
670 | |
671 // Override the default SafeSearch setting using policies. | |
672 PolicyMap policies; | |
673 policies.Set(key::kForceSafeSearch, POLICY_LEVEL_MANDATORY, | |
674 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | |
675 provider_.UpdateChromePolicy(policies); | |
676 | |
677 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kForceSafeSearch)); | |
678 EXPECT_TRUE(prefs->GetBoolean(prefs::kForceSafeSearch)); | |
679 | |
680 content::WindowedNotificationObserver observer( | |
681 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | |
682 content::NotificationService::AllSources()); | |
683 | |
684 // Verify that searching from google.com works. | |
685 chrome::FocusLocationBar(browser()); | |
686 location_bar = browser()->window()->GetLocationBar(); | |
687 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); | |
688 observer.Wait(); | |
689 model = location_bar->GetLocationEntry()->model(); | |
690 EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); | |
691 web_contents = chrome::GetActiveWebContents(browser()); | |
692 std::string expected_url("http://google.com/?"); | |
693 expected_url += std::string(chrome::kSafeSearchSafeParameter) + "&" + | |
694 chrome::kSafeSearchSsuiParameter; | |
695 GURL expected_with_parameters(expected_url); | |
696 EXPECT_EQ(expected_with_parameters, web_contents->GetURL()); | |
697 } | |
698 | |
650 IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { | 699 IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { |
651 CommandLine::ForCurrentProcess()->AppendSwitch( | 700 CommandLine::ForCurrentProcess()->AppendSwitch( |
652 switches::kEnableInstantExtendedAPI); | 701 switches::kEnableInstantExtendedAPI); |
653 | 702 |
654 // Adding the kEnableInstantExtendedAPI is not enough since | 703 // Adding the kEnableInstantExtendedAPI is not enough since |
655 // IsInstantExtendedAPIEnabled does not return true on CHANNEL_DEV. | 704 // IsInstantExtendedAPIEnabled does not return true on CHANNEL_DEV. |
656 if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) | 705 if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) |
657 return; | 706 return; |
658 | 707 |
659 // Verifies that a default search is made using the provider configured via | 708 // Verifies that a default search is made using the provider configured via |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1573 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); | 1622 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); |
1574 // HomepageLocation has policy ID 1. | 1623 // HomepageLocation has policy ID 1. |
1575 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); | 1624 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); |
1576 // ShowHomeButton has policy ID 35. | 1625 // ShowHomeButton has policy ID 35. |
1577 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); | 1626 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); |
1578 // BookmarkBarEnabled has policy ID 82. | 1627 // BookmarkBarEnabled has policy ID 82. |
1579 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); | 1628 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); |
1580 } | 1629 } |
1581 | 1630 |
1582 } // namespace policy | 1631 } // namespace policy |
OLD | NEW |