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 "chrome/browser/extensions/api/web_request/web_request_permissions.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/common/extensions/extension_constants.h" | 8 #include "chrome/common/extensions/extension_constants.h" |
9 #include "chrome/common/extensions/extension_test_util.h" | 9 #include "chrome/common/extensions/extension_test_util.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); | 124 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); |
125 EXPECT_FALSE(WebRequestPermissions::HideRequest(extension_info_map_.get(), | 125 EXPECT_FALSE(WebRequestPermissions::HideRequest(extension_info_map_.get(), |
126 &non_sensitive_request)); | 126 &non_sensitive_request)); |
127 // If the origin is labeled by the WebStoreAppId, it becomes protected. | 127 // If the origin is labeled by the WebStoreAppId, it becomes protected. |
128 { | 128 { |
129 int process_id = 42; | 129 int process_id = 42; |
130 int site_instance_id = 23; | 130 int site_instance_id = 23; |
131 int view_id = 17; | 131 int view_id = 17; |
132 net::TestURLRequest sensitive_request( | 132 net::TestURLRequest sensitive_request( |
133 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); | 133 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); |
134 ResourceRequestInfo::AllocateForTesting( | 134 ResourceRequestInfo::AllocateForTesting(&sensitive_request, |
135 &sensitive_request, ResourceType::SCRIPT, NULL, | 135 content::RESOURCE_TYPE_SCRIPT, |
136 process_id, view_id, MSG_ROUTING_NONE, false); | 136 NULL, |
| 137 process_id, |
| 138 view_id, |
| 139 MSG_ROUTING_NONE, |
| 140 false); |
137 extension_info_map_->RegisterExtensionProcess( | 141 extension_info_map_->RegisterExtensionProcess( |
138 extension_misc::kWebStoreAppId, process_id, site_instance_id); | 142 extension_misc::kWebStoreAppId, process_id, site_instance_id); |
139 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(), | 143 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(), |
140 &sensitive_request)); | 144 &sensitive_request)); |
141 } | 145 } |
142 // If the process is the signin process, it becomes protected. | 146 // If the process is the signin process, it becomes protected. |
143 { | 147 { |
144 int process_id = kSigninProcessId; | 148 int process_id = kSigninProcessId; |
145 int view_id = 19; | 149 int view_id = 19; |
146 net::TestURLRequest sensitive_request( | 150 net::TestURLRequest sensitive_request( |
147 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); | 151 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); |
148 ResourceRequestInfo::AllocateForTesting( | 152 ResourceRequestInfo::AllocateForTesting(&sensitive_request, |
149 &sensitive_request, ResourceType::SCRIPT, NULL, | 153 content::RESOURCE_TYPE_SCRIPT, |
150 process_id, view_id, MSG_ROUTING_NONE, false); | 154 NULL, |
| 155 process_id, |
| 156 view_id, |
| 157 MSG_ROUTING_NONE, |
| 158 false); |
151 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(), | 159 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(), |
152 &sensitive_request)); | 160 &sensitive_request)); |
153 } | 161 } |
154 } | 162 } |
155 | 163 |
156 TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest, | 164 TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest, |
157 TestCanExtensionAccessURL_HostPermissions) { | 165 TestCanExtensionAccessURL_HostPermissions) { |
158 net::TestURLRequest request( | 166 net::TestURLRequest request( |
159 GURL("http://example.com"), net::DEFAULT_PRIORITY, NULL, &context); | 167 GURL("http://example.com"), net::DEFAULT_PRIORITY, NULL, &context); |
160 | 168 |
(...skipping 15 matching lines...) Expand all Loading... |
176 request.url(), | 184 request.url(), |
177 false /*crosses_incognito*/, | 185 false /*crosses_incognito*/, |
178 WebRequestPermissions::REQUIRE_HOST_PERMISSION)); | 186 WebRequestPermissions::REQUIRE_HOST_PERMISSION)); |
179 EXPECT_FALSE(WebRequestPermissions::CanExtensionAccessURL( | 187 EXPECT_FALSE(WebRequestPermissions::CanExtensionAccessURL( |
180 extension_info_map_.get(), | 188 extension_info_map_.get(), |
181 com_extension_->id(), | 189 com_extension_->id(), |
182 request.url(), | 190 request.url(), |
183 false /*crosses_incognito*/, | 191 false /*crosses_incognito*/, |
184 WebRequestPermissions::REQUIRE_ALL_URLS)); | 192 WebRequestPermissions::REQUIRE_ALL_URLS)); |
185 } | 193 } |
OLD | NEW |