Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc

Issue 2635693002: [WebView] initial webview-side implementation of safebrowsing (Closed)
Patch Set: rename lock, add crbug comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/url_constants.h" 17 #include "android_webview/common/url_constants.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "components/navigation_interception/intercept_navigation_delegate.h" 19 #include "components/navigation_interception/intercept_navigation_delegate.h"
20 #include "components/safe_browsing/base_resource_throttle.h"
21 #include "components/safe_browsing_db/safe_browsing_api_handler.h"
20 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h" 22 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h"
21 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/resource_dispatcher_host.h" 24 #include "content/public/browser/resource_dispatcher_host.h"
23 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 25 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
24 #include "content/public/browser/resource_request_info.h" 26 #include "content/public/browser/resource_request_info.h"
25 #include "content/public/browser/resource_throttle.h" 27 #include "content/public/browser/resource_throttle.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "net/base/load_flags.h" 29 #include "net/base/load_flags.h"
28 #include "net/base/net_errors.h" 30 #include "net/base/net_errors.h"
29 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return false; 249 return false;
248 } 250 }
249 251
250 // static 252 // static
251 void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() { 253 void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() {
252 content::ResourceDispatcherHost::Get()->SetDelegate( 254 content::ResourceDispatcherHost::Get()->SetDelegate(
253 &g_webview_resource_dispatcher_host_delegate.Get()); 255 &g_webview_resource_dispatcher_host_delegate.Get());
254 } 256 }
255 257
256 AwResourceDispatcherHostDelegate::AwResourceDispatcherHostDelegate() 258 AwResourceDispatcherHostDelegate::AwResourceDispatcherHostDelegate()
257 : content::ResourceDispatcherHostDelegate() { 259 : content::ResourceDispatcherHostDelegate() {}
258 }
259 260
260 AwResourceDispatcherHostDelegate::~AwResourceDispatcherHostDelegate() { 261 AwResourceDispatcherHostDelegate::~AwResourceDispatcherHostDelegate() {
261 } 262 }
262 263
263 void AwResourceDispatcherHostDelegate::RequestBeginning( 264 void AwResourceDispatcherHostDelegate::RequestBeginning(
264 net::URLRequest* request, 265 net::URLRequest* request,
265 content::ResourceContext* resource_context, 266 content::ResourceContext* resource_context,
266 content::AppCacheService* appcache_service, 267 content::AppCacheService* appcache_service,
267 ResourceType resource_type, 268 ResourceType resource_type,
268 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { 269 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) {
269 AddExtraHeadersIfNeeded(request, resource_context); 270 AddExtraHeadersIfNeeded(request, resource_context);
270 271
271 const content::ResourceRequestInfo* request_info = 272 const content::ResourceRequestInfo* request_info =
272 content::ResourceRequestInfo::ForRequest(request); 273 content::ResourceRequestInfo::ForRequest(request);
273 274
275 if (safe_browsing::SafeBrowsingApiHandler::GetInstance()) {
276 content::ResourceThrottle* throttle =
277 safe_browsing::BaseResourceThrottle::MaybeCreate(
278 request, resource_type,
279 AwBrowserContext::GetDefault()->GetSafeBrowsingDBManager(),
280 AwBrowserContext::GetDefault()->GetSafeBrowsingUIManager());
281 if (throttle == nullptr) {
282 // Should not happen
283 DLOG(WARNING) << "Failed creating safebrowsing throttle";
284 } else {
285 throttles->push_back(base::WrapUnique(throttle));
286 }
287 }
288
274 // We always push the throttles here. Checking the existence of io_client 289 // 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 290 // is racy when a popup window is created. That is because RequestBeginning
276 // is called whether or not requests are blocked via BlockRequestForRoute() 291 // 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 292 // however io_client may or may not be ready at the time depending on whether
278 // webcontents is created. 293 // webcontents is created.
279 throttles->push_back(base::MakeUnique<IoThreadClientThrottle>( 294 throttles->push_back(base::MakeUnique<IoThreadClientThrottle>(
280 request_info->GetChildID(), request_info->GetRenderFrameID(), request)); 295 request_info->GetChildID(), request_info->GetRenderFrameID(), request));
281 296
282 bool is_main_frame = resource_type == content::RESOURCE_TYPE_MAIN_FRAME; 297 bool is_main_frame = resource_type == content::RESOURCE_TYPE_MAIN_FRAME;
283 if (!is_main_frame) 298 if (!is_main_frame)
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 net::HttpRequestHeaders headers; 491 net::HttpRequestHeaders headers;
477 headers.AddHeadersFromString(extra_headers); 492 headers.AddHeadersFromString(extra_headers);
478 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { 493 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) {
479 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); 494 request->SetExtraRequestHeaderByName(it.name(), it.value(), false);
480 } 495 }
481 } 496 }
482 } 497 }
483 } 498 }
484 499
485 } // namespace android_webview 500 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698