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" | |
9 #include "chrome/common/extensions/extension_test_util.h" | 8 #include "chrome/common/extensions/extension_test_util.h" |
10 #include "chrome/test/base/testing_profile.h" | |
11 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
12 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
13 #include "extensions/browser/info_map.h" | 11 #include "extensions/browser/info_map.h" |
| 12 #include "extensions/common/constants.h" |
14 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
15 #include "net/base/request_priority.h" | 14 #include "net/base/request_priority.h" |
16 #include "net/url_request/url_request_test_util.h" | 15 #include "net/url_request/url_request_test_util.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 | 17 |
19 using content::ResourceRequestInfo; | 18 using content::ResourceRequestInfo; |
20 using content::ResourceType; | 19 using content::ResourceType; |
21 using extensions::Extension; | 20 using extensions::Extension; |
22 using extensions::Manifest; | 21 using extensions::Manifest; |
23 using extension_test_util::LoadManifestUnchecked; | 22 using extension_test_util::LoadManifestUnchecked; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 net::TestURLRequest sensitive_request( | 131 net::TestURLRequest sensitive_request( |
133 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); | 132 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); |
134 ResourceRequestInfo::AllocateForTesting(&sensitive_request, | 133 ResourceRequestInfo::AllocateForTesting(&sensitive_request, |
135 content::RESOURCE_TYPE_SCRIPT, | 134 content::RESOURCE_TYPE_SCRIPT, |
136 NULL, | 135 NULL, |
137 process_id, | 136 process_id, |
138 view_id, | 137 view_id, |
139 MSG_ROUTING_NONE, | 138 MSG_ROUTING_NONE, |
140 false); | 139 false); |
141 extension_info_map_->RegisterExtensionProcess( | 140 extension_info_map_->RegisterExtensionProcess( |
142 extension_misc::kWebStoreAppId, process_id, site_instance_id); | 141 extensions::kWebStoreAppId, process_id, site_instance_id); |
143 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(), | 142 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(), |
144 &sensitive_request)); | 143 &sensitive_request)); |
145 } | 144 } |
146 // If the process is the signin process, it becomes protected. | 145 // If the process is the signin process, it becomes protected. |
147 { | 146 { |
148 int process_id = kSigninProcessId; | 147 int process_id = kSigninProcessId; |
149 int view_id = 19; | 148 int view_id = 19; |
150 net::TestURLRequest sensitive_request( | 149 net::TestURLRequest sensitive_request( |
151 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); | 150 non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context); |
152 ResourceRequestInfo::AllocateForTesting(&sensitive_request, | 151 ResourceRequestInfo::AllocateForTesting(&sensitive_request, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 request.url(), | 183 request.url(), |
185 false /*crosses_incognito*/, | 184 false /*crosses_incognito*/, |
186 WebRequestPermissions::REQUIRE_HOST_PERMISSION)); | 185 WebRequestPermissions::REQUIRE_HOST_PERMISSION)); |
187 EXPECT_FALSE(WebRequestPermissions::CanExtensionAccessURL( | 186 EXPECT_FALSE(WebRequestPermissions::CanExtensionAccessURL( |
188 extension_info_map_.get(), | 187 extension_info_map_.get(), |
189 com_extension_->id(), | 188 com_extension_->id(), |
190 request.url(), | 189 request.url(), |
191 false /*crosses_incognito*/, | 190 false /*crosses_incognito*/, |
192 WebRequestPermissions::REQUIRE_ALL_URLS)); | 191 WebRequestPermissions::REQUIRE_ALL_URLS)); |
193 } | 192 } |
OLD | NEW |