| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/managed_mode/managed_mode_resource_throttle.h" | 5 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/managed_mode/managed_user_constants.h" | 10 #include "chrome/browser/managed_mode/managed_user_constants.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 ManagedUserService* managed_user_service_; | 40 ManagedUserService* managed_user_service_; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 void ManagedModeResourceThrottleTest::SetUpOnMainThread() { | 43 void ManagedModeResourceThrottleTest::SetUpOnMainThread() { |
| 44 managed_user_service_ = | 44 managed_user_service_ = |
| 45 ManagedUserServiceFactory::GetForProfile(browser()->profile()); | 45 ManagedUserServiceFactory::GetForProfile(browser()->profile()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ManagedModeResourceThrottleTest::SetUpCommandLine( | 48 void ManagedModeResourceThrottleTest::SetUpCommandLine( |
| 49 CommandLine* command_line) { | 49 CommandLine* command_line) { |
| 50 command_line->AppendSwitchASCII(switches::kManagedUserId, "asdf"); | 50 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Tests that showing the blocking interstitial for a WebContents without a | 53 // Tests that showing the blocking interstitial for a WebContents without a |
| 54 // ManagedModeNavigationObserver doesn't crash. | 54 // ManagedModeNavigationObserver doesn't crash. |
| 55 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, | 55 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, |
| 56 NoNavigationObserverBlock) { | 56 NoNavigationObserverBlock) { |
| 57 Profile* profile = browser()->profile(); | 57 Profile* profile = browser()->profile(); |
| 58 ManagedUserSettingsService* managed_user_settings_service = | 58 ManagedUserSettingsService* managed_user_settings_service = |
| 59 ManagedUserSettingsServiceFactory::GetForProfile(profile); | 59 ManagedUserSettingsServiceFactory::GetForProfile(profile); |
| 60 managed_user_settings_service->SetLocalSettingForTesting( | 60 managed_user_settings_service->SetLocalSettingForTesting( |
| 61 managed_users::kContentPackDefaultFilteringBehavior, | 61 managed_users::kContentPackDefaultFilteringBehavior, |
| 62 scoped_ptr<base::Value>( | 62 scoped_ptr<base::Value>( |
| 63 new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); | 63 new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); |
| 64 | 64 |
| 65 scoped_ptr<WebContents> web_contents( | 65 scoped_ptr<WebContents> web_contents( |
| 66 WebContents::Create(WebContents::CreateParams(profile))); | 66 WebContents::Create(WebContents::CreateParams(profile))); |
| 67 NavigationController& controller = web_contents->GetController(); | 67 NavigationController& controller = web_contents->GetController(); |
| 68 content::TestNavigationObserver observer(web_contents.get()); | 68 content::TestNavigationObserver observer(web_contents.get()); |
| 69 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), | 69 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), |
| 70 content::PAGE_TRANSITION_TYPED, std::string()); | 70 content::PAGE_TRANSITION_TYPED, std::string()); |
| 71 observer.Wait(); | 71 observer.Wait(); |
| 72 content::NavigationEntry* entry = controller.GetActiveEntry(); | 72 content::NavigationEntry* entry = controller.GetActiveEntry(); |
| 73 ASSERT_TRUE(entry); | 73 ASSERT_TRUE(entry); |
| 74 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType()); | 74 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType()); |
| 75 } | 75 } |
| OLD | NEW |