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

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

Issue 24228003: Upstream ShouldOverrideUrlLoading changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 <string> 7 #include <string>
8 8
9 #include "android_webview/browser/aw_contents_io_thread_client.h" 9 #include "android_webview/browser/aw_contents_io_thread_client.h"
10 #include "android_webview/browser/aw_login_delegate.h" 10 #include "android_webview/browser/aw_login_delegate.h"
11 #include "android_webview/common/url_constants.h" 11 #include "android_webview/common/url_constants.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "components/auto_login_parser/auto_login_parser.h" 14 #include "components/auto_login_parser/auto_login_parser.h"
15 #include "components/navigation_interception/intercept_navigation_delegate.h"
16 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/resource_controller.h" 16 #include "content/public/browser/resource_controller.h"
18 #include "content/public/browser/resource_dispatcher_host.h" 17 #include "content/public/browser/resource_dispatcher_host.h"
19 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 18 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
20 #include "content/public/browser/resource_request_info.h" 19 #include "content/public/browser/resource_request_info.h"
21 #include "content/public/browser/resource_throttle.h" 20 #include "content/public/browser/resource_throttle.h"
22 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
23 #include "net/base/load_flags.h" 22 #include "net/base/load_flags.h"
24 #include "net/http/http_response_headers.h" 23 #include "net/http/http_response_headers.h"
25 #include "net/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
26 25
27 using android_webview::AwContentsIoThreadClient; 26 using android_webview::AwContentsIoThreadClient;
28 using content::BrowserThread; 27 using content::BrowserThread;
29 using navigation_interception::InterceptNavigationDelegate;
30 28
31 namespace { 29 namespace {
32 30
33 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> 31 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate>
34 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER; 32 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER;
35 33
36 void SetCacheControlFlag( 34 void SetCacheControlFlag(
37 net::URLRequest* request, int flag) { 35 net::URLRequest* request, int flag) {
38 const int all_cache_control_flags = net::LOAD_BYPASS_CACHE | 36 const int all_cache_control_flags = net::LOAD_BYPASS_CACHE |
39 net::LOAD_VALIDATE_CACHE | 37 net::LOAD_VALIDATE_CACHE |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // destroyed, so do not do anything to the request. Conversely if the 213 // destroyed, so do not do anything to the request. Conversely if the
216 // request relates to a not-yet-created popup window, then the client will 214 // request relates to a not-yet-created popup window, then the client will
217 // be non-NULL but PopupPendingAssociation() will be set. 215 // be non-NULL but PopupPendingAssociation() will be set.
218 scoped_ptr<AwContentsIoThreadClient> io_client = 216 scoped_ptr<AwContentsIoThreadClient> io_client =
219 AwContentsIoThreadClient::FromID(child_id, route_id); 217 AwContentsIoThreadClient::FromID(child_id, route_id);
220 if (!io_client) 218 if (!io_client)
221 return; 219 return;
222 220
223 throttles->push_back(new IoThreadClientThrottle( 221 throttles->push_back(new IoThreadClientThrottle(
224 child_id, route_id, request)); 222 child_id, route_id, request));
225
226 bool allow_intercepting =
227 // We allow intercepting navigations within subframes, but only if the
228 // scheme other than http or https. This is because the embedder
229 // can't distinguish main frame and subframe callbacks (which could lead
230 // to broken content if the embedder decides to not ignore the main frame
231 // navigation, but ignores the subframe navigation).
232 // The reason this is supported at all is that certain JavaScript-based
233 // frameworks use iframe navigation as a form of communication with the
234 // embedder.
235 (resource_type == ResourceType::MAIN_FRAME ||
236 (resource_type == ResourceType::SUB_FRAME &&
237 !request->url().SchemeIs(content::kHttpScheme) &&
238 !request->url().SchemeIs(content::kHttpsScheme)));
239 if (allow_intercepting) {
240 throttles->push_back(InterceptNavigationDelegate::CreateThrottleFor(
241 request));
242 }
243 } 223 }
244 224
245 void AwResourceDispatcherHostDelegate::DownloadStarting( 225 void AwResourceDispatcherHostDelegate::DownloadStarting(
246 net::URLRequest* request, 226 net::URLRequest* request,
247 content::ResourceContext* resource_context, 227 content::ResourceContext* resource_context,
248 int child_id, 228 int child_id,
249 int route_id, 229 int route_id,
250 int request_id, 230 int request_id,
251 bool is_content_initiated, 231 bool is_content_initiated,
252 bool must_download, 232 bool must_download,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ChildRouteIDPair(new_child_id, new_route_id)); 366 ChildRouteIDPair(new_child_id, new_route_id));
387 367
388 if (it != pending_throttles_.end()) { 368 if (it != pending_throttles_.end()) {
389 IoThreadClientThrottle* throttle = it->second; 369 IoThreadClientThrottle* throttle = it->second;
390 throttle->OnIoThreadClientReady(new_child_id, new_route_id); 370 throttle->OnIoThreadClientReady(new_child_id, new_route_id);
391 pending_throttles_.erase(it); 371 pending_throttles_.erase(it);
392 } 372 }
393 } 373 }
394 374
395 } // namespace android_webview 375 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698