OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/net/chrome_extensions_network_delegate.h" | 5 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 | 11 |
12 #if defined(ENABLE_EXTENSIONS) | 12 #if defined(ENABLE_EXTENSIONS) |
13 #include "base/debug/dump_without_crashing.h" | |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/extensions/api/proxy/proxy_api.h" | 15 #include "chrome/browser/extensions/api/proxy/proxy_api.h" |
15 #include "chrome/browser/extensions/event_router_forwarder.h" | 16 #include "chrome/browser/extensions/event_router_forwarder.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" | 18 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/child_process_security_policy.h" | |
19 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/resource_request_info.h" | 22 #include "content/public/browser/resource_request_info.h" |
21 #include "content/public/common/browser_side_navigation_policy.h" | 23 #include "content/public/common/browser_side_navigation_policy.h" |
22 #include "extensions/browser/api/web_request/web_request_api.h" | 24 #include "extensions/browser/api/web_request/web_request_api.h" |
23 #include "extensions/browser/extension_navigation_ui_data.h" | 25 #include "extensions/browser/extension_navigation_ui_data.h" |
24 #include "extensions/browser/info_map.h" | 26 #include "extensions/browser/info_map.h" |
25 #include "extensions/browser/process_manager.h" | 27 #include "extensions/browser/process_manager.h" |
26 #include "extensions/common/permissions/api_permission.h" | 28 #include "extensions/common/permissions/api_permission.h" |
27 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
28 | 30 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 !extension_info_map_->process_map().Contains(info->GetChildID()) && | 204 !extension_info_map_->process_map().Contains(info->GetChildID()) && |
203 !content::IsBrowserSideNavigationEnabled()) { | 205 !content::IsBrowserSideNavigationEnabled()) { |
204 // Relax this restriction for apps that use <webview>. See | 206 // Relax this restriction for apps that use <webview>. See |
205 // https://crbug.com/652077. | 207 // https://crbug.com/652077. |
206 const extensions::Extension* extension = | 208 const extensions::Extension* extension = |
207 extension_info_map_->extensions().GetByID(origin.host()); | 209 extension_info_map_->extensions().GetByID(origin.host()); |
208 bool has_webview_permission = | 210 bool has_webview_permission = |
209 extension && | 211 extension && |
210 extension->permissions_data()->HasAPIPermission( | 212 extension->permissions_data()->HasAPIPermission( |
211 extensions::APIPermission::kWebView); | 213 extensions::APIPermission::kWebView); |
212 if (!has_webview_permission) | 214 // Check whether the request is coming from a <webview> guest process via |
215 // ChildProcessSecurityPolicy. A guest process should have already been | |
216 // granted permission to request |origin| when its WebContents was created. | |
217 // See https://crbug.com/656752. | |
218 auto* policy = content::ChildProcessSecurityPolicy::GetInstance(); | |
219 bool from_guest = | |
220 policy->HasSpecificPermissionForOrigin(info->GetChildID(), origin); | |
ncarter (slow)
2016/10/20 17:46:50
Does correctness here depend on my fix for the too
alexmos
2016/10/20 18:40:23
I think this is independent. The affected test fo
| |
221 if (!has_webview_permission || !from_guest) { | |
222 // TODO(alexmos): Temporary instrumentation to find any regressions for | |
223 // this blocking. Remove after verifying that this is not breaking any | |
224 // legitimate use cases. | |
ncarter (slow)
2016/10/20 17:46:50
I recommend:
base::debug::Alias(&origin);
base::d
alexmos
2016/10/20 18:40:23
Done. Good idea.
| |
225 base::debug::DumpWithoutCrashing(); | |
ncarter (slow)
2016/10/20 17:46:50
There is some risk of ddos from really prolific DW
alexmos
2016/10/20 18:40:23
That sounds good. We'll definitely want enough ba
ncarter (slow)
2016/10/20 19:05:56
Good, we are on the same page. The DWOC should be
| |
213 return net::ERR_ABORTED; | 226 return net::ERR_ABORTED; |
227 } | |
214 } | 228 } |
215 | 229 |
216 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( | 230 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( |
217 profile_, extension_info_map_.get(), | 231 profile_, extension_info_map_.get(), |
218 GetExtensionNavigationUIData(request), request, callback, new_url); | 232 GetExtensionNavigationUIData(request), request, callback, new_url); |
219 } | 233 } |
220 | 234 |
221 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction( | 235 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction( |
222 net::URLRequest* request, | 236 net::URLRequest* request, |
223 const net::CompletionCallback& callback, | 237 const net::CompletionCallback& callback, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 } | 415 } |
402 | 416 |
403 net::NetworkDelegate::AuthRequiredResponse | 417 net::NetworkDelegate::AuthRequiredResponse |
404 ChromeExtensionsNetworkDelegate::OnAuthRequired( | 418 ChromeExtensionsNetworkDelegate::OnAuthRequired( |
405 net::URLRequest* request, | 419 net::URLRequest* request, |
406 const net::AuthChallengeInfo& auth_info, | 420 const net::AuthChallengeInfo& auth_info, |
407 const AuthCallback& callback, | 421 const AuthCallback& callback, |
408 net::AuthCredentials* credentials) { | 422 net::AuthCredentials* credentials) { |
409 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 423 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
410 } | 424 } |
OLD | NEW |