| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 // Get the SupervisedUserInterstitial delegate. | 91 // Get the SupervisedUserInterstitial delegate. |
| 92 content::InterstitialPageDelegate* delegate = | 92 content::InterstitialPageDelegate* delegate = |
| 93 interstitial_page->GetDelegateForTesting(); | 93 interstitial_page->GetDelegateForTesting(); |
| 94 | 94 |
| 95 // Simulate the click on the "back" button. | 95 // Simulate the click on the "back" button. |
| 96 delegate->CommandReceived("\"back\""); | 96 delegate->CommandReceived("\"back\""); |
| 97 } | 97 } |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 virtual void SetUpOnMainThread() override { | 100 void SetUpOnMainThread() override { |
| 101 // Set up the SupervisedUserNavigationObserver manually since the profile | 101 // Set up the SupervisedUserNavigationObserver manually since the profile |
| 102 // was not supervised when the browser was created. | 102 // was not supervised when the browser was created. |
| 103 content::WebContents* web_contents = | 103 content::WebContents* web_contents = |
| 104 browser()->tab_strip_model()->GetActiveWebContents(); | 104 browser()->tab_strip_model()->GetActiveWebContents(); |
| 105 SupervisedUserNavigationObserver::CreateForWebContents(web_contents); | 105 SupervisedUserNavigationObserver::CreateForWebContents(web_contents); |
| 106 | 106 |
| 107 Profile* profile = browser()->profile(); | 107 Profile* profile = browser()->profile(); |
| 108 supervised_user_service_ = | 108 supervised_user_service_ = |
| 109 SupervisedUserServiceFactory::GetForProfile(profile); | 109 SupervisedUserServiceFactory::GetForProfile(profile); |
| 110 SupervisedUserSettingsService* supervised_user_settings_service = | 110 SupervisedUserSettingsService* supervised_user_settings_service = |
| 111 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 111 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
| 112 supervised_user_settings_service->SetLocalSettingForTesting( | 112 supervised_user_settings_service->SetLocalSettingForTesting( |
| 113 supervised_users::kContentPackDefaultFilteringBehavior, | 113 supervised_users::kContentPackDefaultFilteringBehavior, |
| 114 scoped_ptr<base::Value>( | 114 scoped_ptr<base::Value>( |
| 115 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK))); | 115 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK))); |
| 116 } | 116 } |
| 117 | 117 |
| 118 virtual void SetUpCommandLine(CommandLine* command_line) override { | 118 void SetUpCommandLine(CommandLine* command_line) override { |
| 119 // Enable the test server and remap all URLs to it. | 119 // Enable the test server and remap all URLs to it. |
| 120 ASSERT_TRUE(test_server()->Start()); | 120 ASSERT_TRUE(test_server()->Start()); |
| 121 std::string host_port = test_server()->host_port_pair().ToString(); | 121 std::string host_port = test_server()->host_port_pair().ToString(); |
| 122 command_line->AppendSwitchASCII(switches::kHostResolverRules, | 122 command_line->AppendSwitchASCII(switches::kHostResolverRules, |
| 123 "MAP *.example.com " + host_port + "," + | 123 "MAP *.example.com " + host_port + "," + |
| 124 "MAP *.new-example.com " + host_port + "," + | 124 "MAP *.new-example.com " + host_port + "," + |
| 125 "MAP *.a.com " + host_port); | 125 "MAP *.a.com " + host_port); |
| 126 | 126 |
| 127 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); | 127 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); |
| 128 } | 128 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); | 304 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); |
| 305 EXPECT_EQ( | 305 EXPECT_EQ( |
| 306 SupervisedUserService::MANUAL_ALLOW, | 306 SupervisedUserService::MANUAL_ALLOW, |
| 307 supervised_user_service_->GetManualBehaviorForHost(test_url.host())); | 307 supervised_user_service_->GetManualBehaviorForHost(test_url.host())); |
| 308 | 308 |
| 309 observer.Wait(); | 309 observer.Wait(); |
| 310 EXPECT_EQ(test_url, web_contents->GetURL()); | 310 EXPECT_EQ(test_url, web_contents->GetURL()); |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace | 313 } // namespace |
| OLD | NEW |