Chromium Code Reviews| 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 "extensions/features/features.h" | 10 #include "extensions/features/features.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 net::URLRequest* request) { | 166 net::URLRequest* request) { |
| 167 ForwardRequestStatus(REQUEST_DONE, request, profile_); | 167 ForwardRequestStatus(REQUEST_DONE, request, profile_); |
| 168 } | 168 } |
| 169 | 169 |
| 170 int ChromeExtensionsNetworkDelegateImpl::OnBeforeURLRequest( | 170 int ChromeExtensionsNetworkDelegateImpl::OnBeforeURLRequest( |
| 171 net::URLRequest* request, | 171 net::URLRequest* request, |
| 172 const net::CompletionCallback& callback, | 172 const net::CompletionCallback& callback, |
| 173 GURL* new_url) { | 173 GURL* new_url) { |
| 174 const content::ResourceRequestInfo* info = | 174 const content::ResourceRequestInfo* info = |
| 175 content::ResourceRequestInfo::ForRequest(request); | 175 content::ResourceRequestInfo::ForRequest(request); |
| 176 GURL url(request->url()); | 176 const GURL& url(request->url()); |
| 177 | 177 |
| 178 // Block top-level navigations to blob: or filesystem: URLs with extension | 178 // Block top-level navigations to blob: or filesystem: URLs with extension |
| 179 // origin from non-extension processes. See https://crbug.com/645028. | 179 // origin from non-extension processes. See https://crbug.com/645028. |
| 180 // | 180 // |
| 181 // TODO(alexmos): This check is redundant with the one in | 181 // TODO(alexmos): This check is redundant with the one in |
| 182 // ExtensionNavigationThrottle::WillStartRequest, which was introduced in | 182 // ExtensionNavigationThrottle::WillStartRequest, which was introduced in |
| 183 // M56. This check is reintroduced temporarily to tighten this blocking for | 183 // M56. This check is reintroduced temporarily to tighten this blocking for |
| 184 // apps with a "webview" permission on M55/54 (see https://crbug.com/656752). | 184 // apps with a "webview" permission on M55/54 (see https://crbug.com/656752). |
| 185 // It will be removed after it's merged. Unlike the check in | 185 // It will be removed after it's merged. Unlike the check in |
| 186 // ExtensionNavigationThrottle, this check is incompatible with PlzNavigate | 186 // ExtensionNavigationThrottle, this check is incompatible with PlzNavigate |
| 187 // and is disabled for that mode. | 187 // and is disabled for that mode. |
| 188 bool is_nested_url = url.SchemeIsFileSystem() || url.SchemeIsBlob(); | 188 bool is_nested_url = url.SchemeIsFileSystem() || url.SchemeIsBlob(); |
| 189 bool is_navigation = | 189 bool is_navigation = |
| 190 info && content::IsResourceTypeFrame(info->GetResourceType()); | 190 info && content::IsResourceTypeFrame(info->GetResourceType()); |
| 191 url::Origin origin(url); | 191 url::Origin origin; |
| 192 if (is_nested_url && is_navigation && info->IsMainFrame() && | 192 if (is_nested_url && is_navigation && info->IsMainFrame() && |
| 193 origin.scheme() == extensions::kExtensionScheme && | 193 (origin = url::Origin(url)).scheme() == extensions::kExtensionScheme && |
|
Randy Smith (Not in Mondays)
2016/12/06 16:09:20
Suggestion: I understand why you're doing this, an
Charlie Harrison
2016/12/06 18:23:38
Moved it to a nested conditional and added a justi
| |
| 194 !extension_info_map_->process_map().Contains(info->GetChildID()) && | 194 !extension_info_map_->process_map().Contains(info->GetChildID()) && |
| 195 !content::IsBrowserSideNavigationEnabled()) { | 195 !content::IsBrowserSideNavigationEnabled()) { |
| 196 // Relax this restriction for apps that use <webview>. See | 196 // Relax this restriction for apps that use <webview>. See |
| 197 // https://crbug.com/652077. | 197 // https://crbug.com/652077. |
| 198 const extensions::Extension* extension = | 198 const extensions::Extension* extension = |
| 199 extension_info_map_->extensions().GetByID(origin.host()); | 199 extension_info_map_->extensions().GetByID(origin.host()); |
| 200 bool has_webview_permission = | 200 bool has_webview_permission = |
| 201 extension && | 201 extension && |
| 202 extension->permissions_data()->HasAPIPermission( | 202 extension->permissions_data()->HasAPIPermission( |
| 203 extensions::APIPermission::kWebView); | 203 extensions::APIPermission::kWebView); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 } | 401 } |
| 402 | 402 |
| 403 net::NetworkDelegate::AuthRequiredResponse | 403 net::NetworkDelegate::AuthRequiredResponse |
| 404 ChromeExtensionsNetworkDelegate::OnAuthRequired( | 404 ChromeExtensionsNetworkDelegate::OnAuthRequired( |
| 405 net::URLRequest* request, | 405 net::URLRequest* request, |
| 406 const net::AuthChallengeInfo& auth_info, | 406 const net::AuthChallengeInfo& auth_info, |
| 407 const AuthCallback& callback, | 407 const AuthCallback& callback, |
| 408 net::AuthCredentials* credentials) { | 408 net::AuthCredentials* credentials) { |
| 409 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 409 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
| 410 } | 410 } |
| OLD | NEW |