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

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

Issue 1890203002: Implement Web Restrictions in WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix final nits Created 4 years, 4 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_contents_io_thread_client.h" 11 #include "android_webview/browser/aw_contents_io_thread_client.h"
11 #include "android_webview/browser/aw_login_delegate.h" 12 #include "android_webview/browser/aw_login_delegate.h"
12 #include "android_webview/browser/aw_resource_context.h" 13 #include "android_webview/browser/aw_resource_context.h"
13 #include "android_webview/common/url_constants.h" 14 #include "android_webview/common/url_constants.h"
14 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
15 #include "components/auto_login_parser/auto_login_parser.h" 16 #include "components/auto_login_parser/auto_login_parser.h"
16 #include "components/navigation_interception/intercept_navigation_delegate.h" 17 #include "components/navigation_interception/intercept_navigation_delegate.h"
18 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/resource_controller.h" 20 #include "content/public/browser/resource_controller.h"
19 #include "content/public/browser/resource_dispatcher_host.h" 21 #include "content/public/browser/resource_dispatcher_host.h"
20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 22 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
21 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
22 #include "content/public/browser/resource_throttle.h" 24 #include "content/public/browser/resource_throttle.h"
23 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
24 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
25 #include "net/http/http_response_headers.h" 27 #include "net/http/http_response_headers.h"
26 #include "net/url_request/url_request.h" 28 #include "net/url_request/url_request.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 content::ResourceRequestInfo::ForRequest(request); 223 content::ResourceRequestInfo::ForRequest(request);
222 224
223 // We always push the throttles here. Checking the existence of io_client 225 // We always push the throttles here. Checking the existence of io_client
224 // is racy when a popup window is created. That is because RequestBeginning 226 // is racy when a popup window is created. That is because RequestBeginning
225 // is called whether or not requests are blocked via BlockRequestForRoute() 227 // is called whether or not requests are blocked via BlockRequestForRoute()
226 // however io_client may or may not be ready at the time depending on whether 228 // however io_client may or may not be ready at the time depending on whether
227 // webcontents is created. 229 // webcontents is created.
228 throttles->push_back(new IoThreadClientThrottle( 230 throttles->push_back(new IoThreadClientThrottle(
229 request_info->GetChildID(), request_info->GetRenderFrameID(), request)); 231 request_info->GetChildID(), request_info->GetRenderFrameID(), request));
230 232
231 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) 233 bool is_main_frame = resource_type == content::RESOURCE_TYPE_MAIN_FRAME;
234 if (!is_main_frame)
232 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); 235 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request);
236 throttles->push_back(new web_restrictions::WebRestrictionsResourceThrottle(
237 AwBrowserContext::GetDefault()->GetWebRestrictionProvider(),
238 request->url(), is_main_frame));
233 } 239 }
234 240
235 void AwResourceDispatcherHostDelegate::OnRequestRedirected( 241 void AwResourceDispatcherHostDelegate::OnRequestRedirected(
236 const GURL& redirect_url, 242 const GURL& redirect_url,
237 net::URLRequest* request, 243 net::URLRequest* request,
238 content::ResourceContext* resource_context, 244 content::ResourceContext* resource_context,
239 content::ResourceResponse* response) { 245 content::ResourceResponse* response) {
240 AddExtraHeadersIfNeeded(request, resource_context); 246 AddExtraHeadersIfNeeded(request, resource_context);
241 } 247 }
242 248
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 net::HttpRequestHeaders headers; 443 net::HttpRequestHeaders headers;
438 headers.AddHeadersFromString(extra_headers); 444 headers.AddHeadersFromString(extra_headers);
439 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { 445 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) {
440 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); 446 request->SetExtraRequestHeaderByName(it.name(), it.value(), false);
441 } 447 }
442 } 448 }
443 } 449 }
444 } 450 }
445 451
446 } // namespace android_webview 452 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/renderer_host/aw_render_view_host_ext.cc ('k') | android_webview/renderer/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698