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