OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/signin/chrome_signin_client.h" |
| 6 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
5 #include "chrome/browser/signin/signin_manager.h" | 7 #include "chrome/browser/signin/signin_manager.h" |
6 #include "chrome/browser/signin/signin_manager_factory.h" | 8 #include "chrome/browser/signin/signin_manager_factory.h" |
7 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
8 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
9 #include "chrome/test/base/testing_profile_manager.h" | 11 #include "chrome/test/base/testing_profile_manager.h" |
10 #include "content/public/test/mock_render_process_host.h" | 12 #include "content/public/test/mock_render_process_host.h" |
11 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
12 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
13 #include "extensions/common/extension_builder.h" | 15 #include "extensions/common/extension_builder.h" |
14 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #if !defined(OS_CHROMEOS) | 57 #if !defined(OS_CHROMEOS) |
56 // Tests that CanExecuteScriptOnPage returns false for the signin process, | 58 // Tests that CanExecuteScriptOnPage returns false for the signin process, |
57 // all else being equal. | 59 // all else being equal. |
58 TEST_F(BrowserPermissionsPolicyDelegateTest, CanExecuteScriptOnPage) { | 60 TEST_F(BrowserPermissionsPolicyDelegateTest, CanExecuteScriptOnPage) { |
59 GURL kSigninUrl( | 61 GURL kSigninUrl( |
60 "https://accounts.google.com/ServiceLogin?service=chromiumsync"); | 62 "https://accounts.google.com/ServiceLogin?service=chromiumsync"); |
61 ASSERT_TRUE(SigninManager::IsWebBasedSigninFlowURL(kSigninUrl)); | 63 ASSERT_TRUE(SigninManager::IsWebBasedSigninFlowURL(kSigninUrl)); |
62 | 64 |
63 content::MockRenderProcessHost signin_process(profile_); | 65 content::MockRenderProcessHost signin_process(profile_); |
64 content::MockRenderProcessHost normal_process(profile_); | 66 content::MockRenderProcessHost normal_process(profile_); |
65 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_); | 67 ChromeSigninClient* signin_client = |
66 ASSERT_TRUE(signin_manager); | 68 ChromeSigninClientFactory::GetForProfile(profile_); |
67 signin_manager->SetSigninProcess(signin_process.GetID()); | 69 ASSERT_TRUE(signin_client); |
| 70 signin_client->SetSigninProcess(signin_process.GetID()); |
68 | 71 |
69 scoped_refptr<const Extension> extension(CreateTestExtension("a")); | 72 scoped_refptr<const Extension> extension(CreateTestExtension("a")); |
70 std::string error; | 73 std::string error; |
71 | 74 |
72 // The same call should succeed with a normal process, but fail with a signin | 75 // The same call should succeed with a normal process, but fail with a signin |
73 // process. | 76 // process. |
74 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(extension.get(), | 77 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(extension.get(), |
75 kSigninUrl, | 78 kSigninUrl, |
76 kSigninUrl, | 79 kSigninUrl, |
77 -1, | 80 -1, |
78 NULL, | 81 NULL, |
79 normal_process.GetID(), | 82 normal_process.GetID(), |
80 &error)) << error; | 83 &error)) << error; |
81 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(extension.get(), | 84 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(extension.get(), |
82 kSigninUrl, | 85 kSigninUrl, |
83 kSigninUrl, | 86 kSigninUrl, |
84 -1, | 87 -1, |
85 NULL, | 88 NULL, |
86 signin_process.GetID(), | 89 signin_process.GetID(), |
87 &error)) << error; | 90 &error)) << error; |
88 } | 91 } |
89 #endif | 92 #endif |
90 | 93 |
91 } // namespace extensions | 94 } // namespace extensions |
OLD | NEW |