Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc

Issue 23376002: Move ManagedModePolicyProvider functionality to ManagedUserSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/managed_mode/managed_user_constants.h"
9 #include "chrome/browser/managed_mode/managed_user_service.h" 10 #include "chrome/browser/managed_mode/managed_user_service.h"
10 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 11 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
11 #include "chrome/browser/policy/managed_mode_policy_provider.h" 12 #include "chrome/browser/managed_mode/managed_user_settings_sync_service.h"
12 #include "chrome/browser/policy/profile_policy_connector.h" 13 #include "chrome/browser/managed_mode/managed_user_settings_sync_service_factory .h"
13 #include "chrome/browser/policy/profile_policy_connector_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/page_type.h" 20 #include "content/public/common/page_type.h"
21 #include "content/public/test/test_navigation_observer.h" 21 #include "content/public/test/test_navigation_observer.h"
22 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
23 #include "content/public/test/test_utils.h" 23 #include "content/public/test/test_utils.h"
24 #include "policy/policy_constants.h"
25 24
26 using content::MessageLoopRunner; 25 using content::MessageLoopRunner;
27 using content::NavigationController; 26 using content::NavigationController;
28 using content::WebContents; 27 using content::WebContents;
29 28
30 class ManagedModeResourceThrottleTest : public InProcessBrowserTest { 29 class ManagedModeResourceThrottleTest : public InProcessBrowserTest {
31 protected: 30 protected:
32 ManagedModeResourceThrottleTest() : managed_user_service_(NULL) {} 31 ManagedModeResourceThrottleTest() : managed_user_service_(NULL) {}
33 virtual ~ManagedModeResourceThrottleTest() {} 32 virtual ~ManagedModeResourceThrottleTest() {}
34 33
35 private: 34 private:
36 virtual void SetUpOnMainThread() OVERRIDE; 35 virtual void SetUpOnMainThread() OVERRIDE;
37 36
38 ManagedUserService* managed_user_service_; 37 ManagedUserService* managed_user_service_;
39 }; 38 };
40 39
41 void ManagedModeResourceThrottleTest::SetUpOnMainThread() { 40 void ManagedModeResourceThrottleTest::SetUpOnMainThread() {
42 managed_user_service_ = 41 managed_user_service_ =
43 ManagedUserServiceFactory::GetForProfile(browser()->profile()); 42 ManagedUserServiceFactory::GetForProfile(browser()->profile());
44 managed_user_service_->InitForTesting(); 43 managed_user_service_->InitForTesting();
45 } 44 }
46 45
47 // Tests that showing the blocking interstitial for a WebContents without a 46 // Tests that showing the blocking interstitial for a WebContents without a
48 // ManagedModeNavigationObserver doesn't crash. 47 // ManagedModeNavigationObserver doesn't crash.
49 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, 48 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest,
50 NoNavigationObserverBlock) { 49 NoNavigationObserverBlock) {
51 Profile* profile = browser()->profile(); 50 Profile* profile = browser()->profile();
52 policy::ProfilePolicyConnector* connector = 51 ManagedUserSettingsService* managed_user_settings_service =
53 policy::ProfilePolicyConnectorFactory::GetForProfile(profile); 52 ManagedUserSettingsServiceFactory::GetForProfile(profile);
54 policy::ManagedModePolicyProvider* policy_provider = 53 managed_user_settings_service->SetLocalSettingForTesting(
55 connector->managed_mode_policy_provider(); 54 managed_users::kContentPackDefaultFilteringBehavior,
56 policy_provider->SetLocalPolicyForTesting(
57 policy::key::kContentPackDefaultFilteringBehavior,
58 scoped_ptr<base::Value>( 55 scoped_ptr<base::Value>(
59 new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); 56 new base::FundamentalValue(ManagedModeURLFilter::BLOCK)));
60 base::RunLoop().RunUntilIdle();
61 57
62 scoped_ptr<WebContents> web_contents( 58 scoped_ptr<WebContents> web_contents(
63 WebContents::Create(WebContents::CreateParams(profile))); 59 WebContents::Create(WebContents::CreateParams(profile)));
64 NavigationController& controller = web_contents->GetController(); 60 NavigationController& controller = web_contents->GetController();
65 content::TestNavigationObserver observer(web_contents.get()); 61 content::TestNavigationObserver observer(web_contents.get());
66 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), 62 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(),
67 content::PAGE_TRANSITION_TYPED, std::string()); 63 content::PAGE_TRANSITION_TYPED, std::string());
68 observer.Wait(); 64 observer.Wait();
69 content::NavigationEntry* entry = controller.GetActiveEntry(); 65 content::NavigationEntry* entry = controller.GetActiveEntry();
70 ASSERT_TRUE(entry); 66 ASSERT_TRUE(entry);
71 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType()); 67 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType());
72 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698