Chromium Code Reviews| 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 "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 5 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| 11 #include "android_webview/browser/aw_contents_client_bridge_base.h" | 11 #include "android_webview/browser/aw_contents_client_bridge_base.h" |
| 12 #include "android_webview/browser/aw_contents_io_thread_client.h" | 12 #include "android_webview/browser/aw_contents_io_thread_client.h" |
| 13 #include "android_webview/browser/aw_login_delegate.h" | 13 #include "android_webview/browser/aw_login_delegate.h" |
| 14 #include "android_webview/browser/aw_resource_context.h" | 14 #include "android_webview/browser/aw_resource_context.h" |
| 15 #include "android_webview/browser/net/aw_web_resource_request.h" | 15 #include "android_webview/browser/net/aw_web_resource_request.h" |
| 16 #include "android_webview/browser/renderer_host/auto_login_parser.h" | 16 #include "android_webview/browser/renderer_host/auto_login_parser.h" |
| 17 #include "android_webview/common/aw_switches.h" | |
| 17 #include "android_webview/common/url_constants.h" | 18 #include "android_webview/common/url_constants.h" |
| 19 #include "base/command_line.h" | |
|
sgurun-gerrit only
2017/01/16 15:11:19
see the note below, remove.
| |
| 18 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
| 19 #include "components/navigation_interception/intercept_navigation_delegate.h" | 21 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 22 #include "components/safe_browsing/base_resource_throttle.h" | |
| 20 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h" | 23 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h" |
| 21 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/resource_dispatcher_host.h" | 25 #include "content/public/browser/resource_dispatcher_host.h" |
| 23 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 26 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
| 24 #include "content/public/browser/resource_request_info.h" | 27 #include "content/public/browser/resource_request_info.h" |
| 25 #include "content/public/browser/resource_throttle.h" | 28 #include "content/public/browser/resource_throttle.h" |
| 26 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 27 #include "net/base/load_flags.h" | 30 #include "net/base/load_flags.h" |
| 28 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 29 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 return false; | 250 return false; |
| 248 } | 251 } |
| 249 | 252 |
| 250 // static | 253 // static |
| 251 void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() { | 254 void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() { |
| 252 content::ResourceDispatcherHost::Get()->SetDelegate( | 255 content::ResourceDispatcherHost::Get()->SetDelegate( |
| 253 &g_webview_resource_dispatcher_host_delegate.Get()); | 256 &g_webview_resource_dispatcher_host_delegate.Get()); |
| 254 } | 257 } |
| 255 | 258 |
| 256 AwResourceDispatcherHostDelegate::AwResourceDispatcherHostDelegate() | 259 AwResourceDispatcherHostDelegate::AwResourceDispatcherHostDelegate() |
| 257 : content::ResourceDispatcherHostDelegate() { | 260 : content::ResourceDispatcherHostDelegate(), |
| 258 } | 261 safebrowsing_support_enabled( |
|
sgurun-gerrit only
2017/01/16 15:11:19
see the note below, remove.
| |
| 262 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 263 ::switches::kWebViewEnableSafeBrowsingSupport)) {} | |
| 259 | 264 |
| 260 AwResourceDispatcherHostDelegate::~AwResourceDispatcherHostDelegate() { | 265 AwResourceDispatcherHostDelegate::~AwResourceDispatcherHostDelegate() { |
| 261 } | 266 } |
| 262 | 267 |
| 263 void AwResourceDispatcherHostDelegate::RequestBeginning( | 268 void AwResourceDispatcherHostDelegate::RequestBeginning( |
| 264 net::URLRequest* request, | 269 net::URLRequest* request, |
| 265 content::ResourceContext* resource_context, | 270 content::ResourceContext* resource_context, |
| 266 content::AppCacheService* appcache_service, | 271 content::AppCacheService* appcache_service, |
| 267 ResourceType resource_type, | 272 ResourceType resource_type, |
| 268 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { | 273 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { |
| 269 AddExtraHeadersIfNeeded(request, resource_context); | 274 AddExtraHeadersIfNeeded(request, resource_context); |
| 270 | 275 |
| 271 const content::ResourceRequestInfo* request_info = | 276 const content::ResourceRequestInfo* request_info = |
| 272 content::ResourceRequestInfo::ForRequest(request); | 277 content::ResourceRequestInfo::ForRequest(request); |
| 273 | 278 |
| 279 if (safebrowsing_support_enabled) { | |
|
sgurun-gerrit only
2017/01/16 15:11:19
you are already checking for this in AwBrowserCont
timvolodine
2017/01/16 18:58:57
Without this guard we'll add a safebrowsing thrott
timvolodine
2017/01/16 19:01:56
Oh hold on, you probably meant throttle should be
| |
| 280 content::ResourceThrottle* throttle = | |
| 281 safe_browsing::BaseResourceThrottle::MaybeCreate( | |
| 282 request, resource_type, | |
| 283 AwBrowserContext::GetDefault()->GetSafeBrowsingDBManager(), | |
| 284 AwBrowserContext::GetDefault()->GetSafeBrowsingUIManager()); | |
| 285 if (throttle == nullptr) { | |
| 286 // TODO(timvolodine) perhaps just DLOG | |
| 287 LOG(WARNING) << "Failed creating safebrowsing throttle"; | |
|
sgurun-gerrit only
2017/01/16 15:11:19
do a DLOG as this is expected fail mode for AOSP
timvolodine
2017/01/16 18:58:57
Done.
timvolodine
2017/01/16 22:42:00
Actually don't think this will be the fail mode on
| |
| 288 } else { | |
| 289 throttles->push_back(base::WrapUnique(throttle)); | |
| 290 } | |
| 291 } | |
| 292 | |
| 274 // We always push the throttles here. Checking the existence of io_client | 293 // We always push the throttles here. Checking the existence of io_client |
| 275 // is racy when a popup window is created. That is because RequestBeginning | 294 // is racy when a popup window is created. That is because RequestBeginning |
| 276 // is called whether or not requests are blocked via BlockRequestForRoute() | 295 // is called whether or not requests are blocked via BlockRequestForRoute() |
| 277 // however io_client may or may not be ready at the time depending on whether | 296 // however io_client may or may not be ready at the time depending on whether |
| 278 // webcontents is created. | 297 // webcontents is created. |
| 279 throttles->push_back(base::MakeUnique<IoThreadClientThrottle>( | 298 throttles->push_back(base::MakeUnique<IoThreadClientThrottle>( |
| 280 request_info->GetChildID(), request_info->GetRenderFrameID(), request)); | 299 request_info->GetChildID(), request_info->GetRenderFrameID(), request)); |
| 281 | 300 |
| 282 bool is_main_frame = resource_type == content::RESOURCE_TYPE_MAIN_FRAME; | 301 bool is_main_frame = resource_type == content::RESOURCE_TYPE_MAIN_FRAME; |
| 283 if (!is_main_frame) | 302 if (!is_main_frame) |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 net::HttpRequestHeaders headers; | 495 net::HttpRequestHeaders headers; |
| 477 headers.AddHeadersFromString(extra_headers); | 496 headers.AddHeadersFromString(extra_headers); |
| 478 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { | 497 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { |
| 479 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); | 498 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); |
| 480 } | 499 } |
| 481 } | 500 } |
| 482 } | 501 } |
| 483 } | 502 } |
| 484 | 503 |
| 485 } // namespace android_webview | 504 } // namespace android_webview |
| OLD | NEW |