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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/managed_mode/managed_user_service.h" | 8 #include "chrome/browser/managed_mode/managed_user_service.h" |
9 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 9 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 ManagedUserService* managed_user_service_; | 34 ManagedUserService* managed_user_service_; |
35 }; | 35 }; |
36 | 36 |
37 void ManagedModeResourceThrottleTest::SetUpOnMainThread() { | 37 void ManagedModeResourceThrottleTest::SetUpOnMainThread() { |
38 Profile* profile = browser()->profile(); | 38 Profile* profile = browser()->profile(); |
39 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); | 39 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); |
40 profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); | 40 profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); |
41 managed_user_service_->Init(); | 41 managed_user_service_->Init(); |
42 } | 42 } |
43 | 43 |
44 // Tests that showing the blocking interstitial for a WebContents without a | 44 // Tests that blocking a request for a WebContents without a |
45 // ManagedModeNavigationObserver doesn't crash. | 45 // ManagedModeNavigationObserver doesn't crash. |
46 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, NoNavigationObserver) { | 46 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, NoNavigationObserver) { |
47 scoped_ptr<WebContents> web_contents( | 47 scoped_ptr<WebContents> web_contents( |
48 WebContents::Create(WebContents::CreateParams(browser()->profile()))); | 48 WebContents::Create(WebContents::CreateParams(browser()->profile()))); |
49 NavigationController& controller = web_contents->GetController(); | 49 NavigationController& controller = web_contents->GetController(); |
50 content::TestNavigationObserver observer( | 50 content::TestNavigationObserver observer( |
51 content::Source<NavigationController>(&controller), 1); | 51 content::Source<NavigationController>(&controller), 1); |
52 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), | 52 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), |
53 content::PAGE_TRANSITION_TYPED, std::string()); | 53 content::PAGE_TRANSITION_TYPED, std::string()); |
54 observer.Wait(); | 54 observer.Wait(); |
55 content::NavigationEntry* entry = controller.GetActiveEntry(); | |
56 ASSERT_TRUE(entry); | |
57 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType()); | |
58 } | 55 } |
OLD | NEW |