| 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 "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/common/cancelable_request.h" | 10 #include "chrome/browser/common/cancelable_request.h" | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 100  protected: | 100  protected: | 
| 101   virtual void SetUpOnMainThread() OVERRIDE { | 101   virtual void SetUpOnMainThread() OVERRIDE { | 
| 102     // Set up the ManagedModeNavigationObserver manually since the profile was | 102     // Set up the ManagedModeNavigationObserver manually since the profile was | 
| 103     // not managed when the browser was created. | 103     // not managed when the browser was created. | 
| 104     content::WebContents* web_contents = | 104     content::WebContents* web_contents = | 
| 105         browser()->tab_strip_model()->GetActiveWebContents(); | 105         browser()->tab_strip_model()->GetActiveWebContents(); | 
| 106     ManagedModeNavigationObserver::CreateForWebContents(web_contents); | 106     ManagedModeNavigationObserver::CreateForWebContents(web_contents); | 
| 107 | 107 | 
| 108     Profile* profile = browser()->profile(); | 108     Profile* profile = browser()->profile(); | 
| 109     managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); | 109     managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); | 
| 110     managed_user_service_->InitForTesting(); |  | 
| 111     ManagedUserSettingsService* managed_user_settings_service = | 110     ManagedUserSettingsService* managed_user_settings_service = | 
| 112         ManagedUserSettingsServiceFactory::GetForProfile(profile); | 111         ManagedUserSettingsServiceFactory::GetForProfile(profile); | 
| 113     managed_user_settings_service->SetLocalSettingForTesting( | 112     managed_user_settings_service->SetLocalSettingForTesting( | 
| 114         managed_users::kContentPackDefaultFilteringBehavior, | 113         managed_users::kContentPackDefaultFilteringBehavior, | 
| 115         scoped_ptr<base::Value>( | 114         scoped_ptr<base::Value>( | 
| 116             new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); | 115             new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); | 
| 117   } | 116   } | 
| 118 | 117 | 
| 119   virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 118   virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 
| 120     // Enable the test server and remap all URLs to it. | 119     // Enable the test server and remap all URLs to it. | 
| 121     ASSERT_TRUE(test_server()->Start()); | 120     ASSERT_TRUE(test_server()->Start()); | 
| 122     std::string host_port = test_server()->host_port_pair().ToString(); | 121     std::string host_port = test_server()->host_port_pair().ToString(); | 
| 123     command_line->AppendSwitchASCII(switches::kHostResolverRules, | 122     command_line->AppendSwitchASCII(switches::kHostResolverRules, | 
| 124         "MAP *.example.com " + host_port + "," + | 123         "MAP *.example.com " + host_port + "," + | 
| 125         "MAP *.new-example.com " + host_port + "," + | 124         "MAP *.new-example.com " + host_port + "," + | 
| 126         "MAP *.a.com " + host_port); | 125         "MAP *.a.com " + host_port); | 
|  | 126 | 
|  | 127     command_line->AppendSwitch(switches::kNewProfileIsSupervised); | 
| 127   } | 128   } | 
| 128 | 129 | 
| 129   // Acts like a synchronous call to history's QueryHistory. Modified from | 130   // Acts like a synchronous call to history's QueryHistory. Modified from | 
| 130   // history_querying_unittest.cc. | 131   // history_querying_unittest.cc. | 
| 131   void QueryHistory(HistoryService* history_service, | 132   void QueryHistory(HistoryService* history_service, | 
| 132                     const std::string& text_query, | 133                     const std::string& text_query, | 
| 133                     const history::QueryOptions& options, | 134                     const history::QueryOptions& options, | 
| 134                     history::QueryResults* results) { | 135                     history::QueryResults* results) { | 
| 135     CancelableRequestConsumer history_request_consumer; | 136     CancelableRequestConsumer history_request_consumer; | 
| 136     base::RunLoop run_loop; | 137     base::RunLoop run_loop; | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 254       managed_users::kContentPackManualBehaviorHosts, dict.PassAs<Value>()); | 255       managed_users::kContentPackManualBehaviorHosts, dict.PassAs<Value>()); | 
| 255   EXPECT_EQ( | 256   EXPECT_EQ( | 
| 256       ManagedUserService::MANUAL_ALLOW, | 257       ManagedUserService::MANUAL_ALLOW, | 
| 257       managed_user_service_->GetManualBehaviorForHost(test_url.host())); | 258       managed_user_service_->GetManualBehaviorForHost(test_url.host())); | 
| 258 | 259 | 
| 259   observer.Wait(); | 260   observer.Wait(); | 
| 260   EXPECT_EQ(test_url, web_contents->GetURL()); | 261   EXPECT_EQ(test_url, web_contents->GetURL()); | 
| 261 } | 262 } | 
| 262 | 263 | 
| 263 }  // namespace | 264 }  // namespace | 
| OLD | NEW | 
|---|