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

Side by Side Diff: content/browser/loader/navigation_resource_throttle.cc

Issue 2321543002: Merge CrossSiteResourceHandler and NavigationResourceThrottle (Closed)
Patch Set: Change to android fix + compile error Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/loader/navigation_resource_throttle.h" 5 #include "content/browser/loader/navigation_resource_throttle.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "content/browser/frame_host/navigation_handle_impl.h" 14 #include "content/browser/frame_host/navigation_handle_impl.h"
15 #include "content/browser/frame_host/render_frame_host_impl.h" 15 #include "content/browser/frame_host/render_frame_host_impl.h"
16 #include "content/browser/loader/navigation_resource_handler.h" 16 #include "content/browser/loader/navigation_resource_handler.h"
17 #include "content/browser/loader/resource_dispatcher_host_impl.h"
18 #include "content/browser/loader/resource_loader.h"
17 #include "content/browser/loader/resource_request_info_impl.h" 19 #include "content/browser/loader/resource_request_info_impl.h"
18 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_data.h" 21 #include "content/public/browser/navigation_data.h"
20 #include "content/public/browser/resource_context.h" 22 #include "content/public/browser/resource_context.h"
21 #include "content/public/browser/resource_controller.h" 23 #include "content/public/browser/resource_controller.h"
22 #include "content/public/browser/resource_dispatcher_host_delegate.h" 24 #include "content/public/browser/resource_dispatcher_host_delegate.h"
23 #include "content/public/browser/resource_request_info.h" 25 #include "content/public/browser/resource_request_info.h"
24 #include "content/public/browser/ssl_status.h" 26 #include "content/public/browser/ssl_status.h"
25 #include "content/public/common/referrer.h" 27 #include "content/public/common/referrer.h"
26 #include "net/url_request/redirect_info.h" 28 #include "net/url_request/redirect_info.h"
27 #include "net/url_request/url_request.h" 29 #include "net/url_request/url_request.h"
28 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
29 #include "net/url_request/url_request_job_factory.h" 31 #include "net/url_request/url_request_job_factory.h"
30 #include "ui/base/page_transition_types.h" 32 #include "ui/base/page_transition_types.h"
31 33
32 namespace content { 34 namespace content {
33 35
34 namespace { 36 namespace {
37
38 // Used in unit tests to make UI checks succeed even if there is no
39 // NavigationHandle and to transfer all navigations.
40 bool g_ui_checks_always_succeed = false;
41 bool g_force_transfer = false;
42
35 typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)> 43 typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)>
36 UIChecksPerformedCallback; 44 UIChecksPerformedCallback;
37 45
38 void SendCheckResultToIOThread(UIChecksPerformedCallback callback, 46 void SendCheckResultToIOThread(UIChecksPerformedCallback callback,
39 NavigationThrottle::ThrottleCheckResult result) { 47 NavigationThrottle::ThrottleCheckResult result) {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 48 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 DCHECK_NE(result, NavigationThrottle::DEFER); 49 DCHECK_NE(result, NavigationThrottle::DEFER);
42 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 50 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
43 base::Bind(callback, result)); 51 base::Bind(callback, result));
44 } 52 }
45 53
46 void CheckWillStartRequestOnUIThread( 54 void CheckWillStartRequestOnUIThread(
47 UIChecksPerformedCallback callback, 55 UIChecksPerformedCallback callback,
48 int render_process_id, 56 int render_process_id,
49 int render_frame_host_id, 57 int render_frame_host_id,
50 const std::string& method, 58 const std::string& method,
51 const scoped_refptr<content::ResourceRequestBodyImpl>& 59 const scoped_refptr<content::ResourceRequestBodyImpl>&
52 resource_request_body, 60 resource_request_body,
53 const Referrer& sanitized_referrer, 61 const Referrer& sanitized_referrer,
54 bool has_user_gesture, 62 bool has_user_gesture,
55 ui::PageTransition transition, 63 ui::PageTransition transition,
56 bool is_external_protocol, 64 bool is_external_protocol,
57 RequestContextType request_context_type) { 65 RequestContextType request_context_type,
66 bool proceed_if_handle_not_found) {
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); 67 DCHECK_CURRENTLY_ON(BrowserThread::UI);
59 RenderFrameHostImpl* render_frame_host = 68 RenderFrameHostImpl* render_frame_host =
60 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id); 69 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
70 if (g_ui_checks_always_succeed) {
71 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
72 return;
73 }
74
61 if (!render_frame_host) { 75 if (!render_frame_host) {
62 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED); 76 if (proceed_if_handle_not_found)
77 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
78 else
79 SendCheckResultToIOThread(callback, NavigationThrottle::CANCEL);
63 return; 80 return;
64 } 81 }
65 82
66 NavigationHandleImpl* navigation_handle = 83 NavigationHandleImpl* navigation_handle =
67 render_frame_host->navigation_handle(); 84 render_frame_host->navigation_handle();
68 if (!navigation_handle) { 85 if (!navigation_handle) {
69 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED); 86 if (proceed_if_handle_not_found)
87 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
88 else
89 SendCheckResultToIOThread(callback, NavigationThrottle::CANCEL);
70 return; 90 return;
71 } 91 }
72 92
73 navigation_handle->WillStartRequest( 93 navigation_handle->WillStartRequest(
74 method, resource_request_body, sanitized_referrer, has_user_gesture, 94 method, resource_request_body, sanitized_referrer, has_user_gesture,
75 transition, is_external_protocol, request_context_type, 95 transition, is_external_protocol, request_context_type,
76 base::Bind(&SendCheckResultToIOThread, callback)); 96 base::Bind(&SendCheckResultToIOThread, callback));
77 } 97 }
78 98
79 void CheckWillRedirectRequestOnUIThread( 99 void CheckWillRedirectRequestOnUIThread(
80 UIChecksPerformedCallback callback, 100 UIChecksPerformedCallback callback,
81 int render_process_id, 101 int render_process_id,
82 int render_frame_host_id, 102 int render_frame_host_id,
83 const GURL& new_url, 103 const GURL& new_url,
84 const std::string& new_method, 104 const std::string& new_method,
85 const GURL& new_referrer_url, 105 const GURL& new_referrer_url,
86 bool new_is_external_protocol, 106 bool new_is_external_protocol,
87 scoped_refptr<net::HttpResponseHeaders> headers) { 107 scoped_refptr<net::HttpResponseHeaders> headers) {
88 DCHECK_CURRENTLY_ON(BrowserThread::UI); 108 DCHECK_CURRENTLY_ON(BrowserThread::UI);
89 RenderFrameHostImpl* render_frame_host = 109 RenderFrameHostImpl* render_frame_host =
90 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id); 110 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
111 if (g_ui_checks_always_succeed) {
112 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
113 return;
114 }
115
91 if (!render_frame_host) { 116 if (!render_frame_host) {
92 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED); 117 SendCheckResultToIOThread(callback, NavigationThrottle::CANCEL);
93 return; 118 return;
94 } 119 }
95 120
96 NavigationHandleImpl* navigation_handle = 121 NavigationHandleImpl* navigation_handle =
97 render_frame_host->navigation_handle(); 122 render_frame_host->navigation_handle();
98 if (!navigation_handle) { 123 if (!navigation_handle) {
99 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED); 124 SendCheckResultToIOThread(callback, NavigationThrottle::CANCEL);
100 return; 125 return;
101 } 126 }
102 127
103 GURL new_validated_url(new_url); 128 GURL new_validated_url(new_url);
104 RenderProcessHost::FromID(render_process_id) 129 RenderProcessHost::FromID(render_process_id)
105 ->FilterURL(false, &new_validated_url); 130 ->FilterURL(false, &new_validated_url);
106 navigation_handle->WillRedirectRequest( 131 navigation_handle->WillRedirectRequest(
107 new_validated_url, new_method, new_referrer_url, new_is_external_protocol, 132 new_validated_url, new_method, new_referrer_url, new_is_external_protocol,
108 headers, base::Bind(&SendCheckResultToIOThread, callback)); 133 headers, base::Bind(&SendCheckResultToIOThread, callback));
109 } 134 }
110 135
111 void WillProcessResponseOnUIThread( 136 void WillProcessResponseOnUIThread(
112 UIChecksPerformedCallback callback, 137 UIChecksPerformedCallback callback,
113 int render_process_id, 138 int render_process_id,
114 int render_frame_host_id, 139 int render_frame_host_id,
115 scoped_refptr<net::HttpResponseHeaders> headers, 140 scoped_refptr<net::HttpResponseHeaders> headers,
116 const SSLStatus& ssl_status, 141 const SSLStatus& ssl_status,
117 std::unique_ptr<NavigationData> navigation_data) { 142 const GlobalRequestID& request_id,
143 bool should_replace_current_entry,
144 bool is_download,
145 bool is_stream,
146 const base::Closure& transfer_callback,
147 std::unique_ptr<NavigationData> navigation_data,
148 bool proceed_if_handle_not_found) {
Charlie Reis 2016/09/21 16:47:08 This needs some documentation somewhere. I don't
clamy 2016/09/22 16:27:23 Actually this is limited to interstitials: it's be
nasko 2016/09/22 22:44:55 I am not a fan of this approach either. Putting al
Charlie Reis 2016/09/23 05:46:55 Let's avoid using the parameters that are meant fo
clamy 2016/09/26 12:20:32 The fix for interstitials has been moved to https:
118 DCHECK_CURRENTLY_ON(BrowserThread::UI); 149 DCHECK_CURRENTLY_ON(BrowserThread::UI);
119 RenderFrameHostImpl* render_frame_host = 150 RenderFrameHostImpl* render_frame_host =
120 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id); 151 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
152 if (g_force_transfer) {
153 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback);
154 }
mmenke 2016/09/21 17:10:24 nit: Remove braces/
clamy 2016/09/26 12:20:32 This code was moved in https://codereview.chromium
155
156 if (g_ui_checks_always_succeed) {
157 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
158 return;
159 }
160
121 if (!render_frame_host) { 161 if (!render_frame_host) {
nasko 2016/09/22 22:44:55 I don't quite understand this. In the case of inte
clamy 2016/09/26 12:20:32 The fix for interstitials has been moved to https:
122 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED); 162 if (proceed_if_handle_not_found)
163 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
164 else
165 SendCheckResultToIOThread(callback, NavigationThrottle::CANCEL);
123 return; 166 return;
124 } 167 }
125 168
126 NavigationHandleImpl* navigation_handle = 169 NavigationHandleImpl* navigation_handle =
127 render_frame_host->navigation_handle(); 170 render_frame_host->navigation_handle();
128 if (!navigation_handle) { 171 if (!navigation_handle) {
129 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED); 172 if (proceed_if_handle_not_found)
173 SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
174 else
175 SendCheckResultToIOThread(callback, NavigationThrottle::CANCEL);
130 return; 176 return;
131 } 177 }
132 178
133 if (navigation_data) 179 if (navigation_data)
134 navigation_handle->set_navigation_data(std::move(navigation_data)); 180 navigation_handle->set_navigation_data(std::move(navigation_data));
135 181
136 navigation_handle->WillProcessResponse( 182 navigation_handle->WillProcessResponse(
137 render_frame_host, headers, ssl_status, 183 render_frame_host, headers, ssl_status, request_id,
184 should_replace_current_entry, is_download, is_stream, transfer_callback,
138 base::Bind(&SendCheckResultToIOThread, callback)); 185 base::Bind(&SendCheckResultToIOThread, callback));
139 } 186 }
140 187
141 } // namespace 188 } // namespace
142 189
143 NavigationResourceThrottle::NavigationResourceThrottle( 190 NavigationResourceThrottle::NavigationResourceThrottle(
144 net::URLRequest* request, 191 net::URLRequest* request,
145 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, 192 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate,
146 RequestContextType request_context_type) 193 RequestContextType request_context_type)
147 : request_(request), 194 : request_(request),
148 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), 195 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate),
149 request_context_type_(request_context_type), 196 request_context_type_(request_context_type),
197 in_cross_site_transition_(false),
198 on_transfer_done_result_(NavigationThrottle::DEFER),
150 weak_ptr_factory_(this) {} 199 weak_ptr_factory_(this) {}
151 200
152 NavigationResourceThrottle::~NavigationResourceThrottle() {} 201 NavigationResourceThrottle::~NavigationResourceThrottle() {}
153 202
154 void NavigationResourceThrottle::WillStartRequest(bool* defer) { 203 void NavigationResourceThrottle::WillStartRequest(bool* defer) {
155 DCHECK_CURRENTLY_ON(BrowserThread::IO); 204 DCHECK_CURRENTLY_ON(BrowserThread::IO);
156 const ResourceRequestInfoImpl* info = 205 const ResourceRequestInfoImpl* info =
157 ResourceRequestInfoImpl::ForRequest(request_); 206 ResourceRequestInfoImpl::ForRequest(request_);
158 if (!info) 207 if (!info)
159 return; 208 return;
(...skipping 10 matching lines...) Expand all
170 weak_ptr_factory_.GetWeakPtr()); 219 weak_ptr_factory_.GetWeakPtr());
171 DCHECK(request_->method() == "POST" || request_->method() == "GET"); 220 DCHECK(request_->method() == "POST" || request_->method() == "GET");
172 BrowserThread::PostTask( 221 BrowserThread::PostTask(
173 BrowserThread::UI, FROM_HERE, 222 BrowserThread::UI, FROM_HERE,
174 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, 223 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id,
175 render_frame_id, request_->method(), info->body(), 224 render_frame_id, request_->method(), info->body(),
176 Referrer::SanitizeForRequest( 225 Referrer::SanitizeForRequest(
177 request_->url(), Referrer(GURL(request_->referrer()), 226 request_->url(), Referrer(GURL(request_->referrer()),
178 info->GetReferrerPolicy())), 227 info->GetReferrerPolicy())),
179 info->HasUserGesture(), info->GetPageTransition(), 228 info->HasUserGesture(), info->GetPageTransition(),
180 is_external_protocol, request_context_type_)); 229 is_external_protocol, request_context_type_,
230 request_->url().SchemeIs(url::kDataScheme)));
181 *defer = true; 231 *defer = true;
182 } 232 }
183 233
184 void NavigationResourceThrottle::WillRedirectRequest( 234 void NavigationResourceThrottle::WillRedirectRequest(
185 const net::RedirectInfo& redirect_info, 235 const net::RedirectInfo& redirect_info,
186 bool* defer) { 236 bool* defer) {
187 DCHECK_CURRENTLY_ON(BrowserThread::IO); 237 DCHECK_CURRENTLY_ON(BrowserThread::IO);
188 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); 238 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_);
189 if (!info) 239 if (!info)
190 return; 240 return;
(...skipping 27 matching lines...) Expand all
218 BrowserThread::UI, FROM_HERE, 268 BrowserThread::UI, FROM_HERE,
219 base::Bind(&CheckWillRedirectRequestOnUIThread, callback, 269 base::Bind(&CheckWillRedirectRequestOnUIThread, callback,
220 render_process_id, render_frame_id, redirect_info.new_url, 270 render_process_id, render_frame_id, redirect_info.new_url,
221 redirect_info.new_method, GURL(redirect_info.new_referrer), 271 redirect_info.new_method, GURL(redirect_info.new_referrer),
222 new_is_external_protocol, response_headers)); 272 new_is_external_protocol, response_headers));
223 *defer = true; 273 *defer = true;
224 } 274 }
225 275
226 void NavigationResourceThrottle::WillProcessResponse(bool* defer) { 276 void NavigationResourceThrottle::WillProcessResponse(bool* defer) {
227 DCHECK_CURRENTLY_ON(BrowserThread::IO); 277 DCHECK_CURRENTLY_ON(BrowserThread::IO);
228 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); 278 const ResourceRequestInfoImpl* info =
279 ResourceRequestInfoImpl::ForRequest(request_);
229 if (!info) 280 if (!info)
230 return; 281 return;
231 282
232 int render_process_id, render_frame_id; 283 int render_process_id, render_frame_id;
233 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) 284 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id))
234 return; 285 return;
235 286
236 // Send a copy of the response headers to the NavigationHandle on the UI 287 // Send a copy of the response headers to the NavigationHandle on the UI
237 // thread. 288 // thread.
238 scoped_refptr<net::HttpResponseHeaders> response_headers; 289 scoped_refptr<net::HttpResponseHeaders> response_headers;
239 if (request_->response_headers()) { 290 if (request_->response_headers()) {
240 response_headers = new net::HttpResponseHeaders( 291 response_headers = new net::HttpResponseHeaders(
241 request_->response_headers()->raw_headers()); 292 request_->response_headers()->raw_headers());
242 } 293 }
243 294
244 std::unique_ptr<NavigationData> cloned_data; 295 std::unique_ptr<NavigationData> cloned_data;
245 if (resource_dispatcher_host_delegate_) { 296 if (resource_dispatcher_host_delegate_) {
246 // Ask the embedder for a NavigationData instance. 297 // Ask the embedder for a NavigationData instance.
247 NavigationData* navigation_data = 298 NavigationData* navigation_data =
248 resource_dispatcher_host_delegate_->GetNavigationData(request_); 299 resource_dispatcher_host_delegate_->GetNavigationData(request_);
249 300
250 // Clone the embedder's NavigationData before moving it to the UI thread. 301 // Clone the embedder's NavigationData before moving it to the UI thread.
251 if (navigation_data) 302 if (navigation_data)
252 cloned_data = navigation_data->Clone(); 303 cloned_data = navigation_data->Clone();
253 } 304 }
254 305
255 UIChecksPerformedCallback callback = 306 UIChecksPerformedCallback callback =
256 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, 307 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed,
257 weak_ptr_factory_.GetWeakPtr()); 308 weak_ptr_factory_.GetWeakPtr());
309 base::Closure transfer_callback =
310 base::Bind(&NavigationResourceThrottle::InitiateTransfer,
311 weak_ptr_factory_.GetWeakPtr());
258 312
259 SSLStatus ssl_status; 313 SSLStatus ssl_status;
260 if (request_->ssl_info().cert.get()) { 314 if (request_->ssl_info().cert.get()) {
261 NavigationResourceHandler::GetSSLStatusForRequest( 315 NavigationResourceHandler::GetSSLStatusForRequest(
262 request_->url(), request_->ssl_info(), info->GetChildID(), &ssl_status); 316 request_->url(), request_->ssl_info(), info->GetChildID(), &ssl_status);
263 } 317 }
264 318
265 BrowserThread::PostTask( 319 BrowserThread::PostTask(
266 BrowserThread::UI, FROM_HERE, 320 BrowserThread::UI, FROM_HERE,
267 base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id, 321 base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id,
268 render_frame_id, response_headers, ssl_status, 322 render_frame_id, response_headers, ssl_status,
269 base::Passed(&cloned_data))); 323 info->GetGlobalRequestID(),
324 info->should_replace_current_entry(), info->IsDownload(),
325 info->is_stream(), transfer_callback,
326 base::Passed(&cloned_data),
327 request_->url().SchemeIs(url::kDataScheme)));
270 *defer = true; 328 *defer = true;
271 } 329 }
272 330
273 const char* NavigationResourceThrottle::GetNameForLogging() const { 331 const char* NavigationResourceThrottle::GetNameForLogging() const {
274 return "NavigationResourceThrottle"; 332 return "NavigationResourceThrottle";
275 } 333 }
276 334
335 void NavigationResourceThrottle::SetUIChecksAlwaysSucceedForTesting(
336 bool ui_checks_always_succeed) {
337 g_ui_checks_always_succeed = ui_checks_always_succeed;
338 }
339
340 void NavigationResourceThrottle::SetForceTransferForTesting(
341 bool force_transfer) {
342 g_force_transfer = force_transfer;
343 }
344
277 void NavigationResourceThrottle::OnUIChecksPerformed( 345 void NavigationResourceThrottle::OnUIChecksPerformed(
278 NavigationThrottle::ThrottleCheckResult result) { 346 NavigationThrottle::ThrottleCheckResult result) {
279 DCHECK_CURRENTLY_ON(BrowserThread::IO); 347 DCHECK_CURRENTLY_ON(BrowserThread::IO);
348 DCHECK_NE(NavigationThrottle::DEFER, result);
349 if (in_cross_site_transition_) {
350 on_transfer_done_result_ = result;
351 return;
352 }
353
280 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { 354 if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
281 controller()->CancelAndIgnore(); 355 controller()->CancelAndIgnore();
282 } else if (result == NavigationThrottle::CANCEL) { 356 } else if (result == NavigationThrottle::CANCEL) {
283 controller()->Cancel(); 357 controller()->Cancel();
284 } else if (result == NavigationThrottle::BLOCK_REQUEST) { 358 } else if (result == NavigationThrottle::BLOCK_REQUEST) {
285 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT); 359 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT);
286 } else { 360 } else {
287 controller()->Resume(); 361 controller()->Resume();
288 } 362 }
289 } 363 }
290 364
365 void NavigationResourceThrottle::InitiateTransfer() {
366 DCHECK_CURRENTLY_ON(BrowserThread::IO);
367 in_cross_site_transition_ = true;
368 ResourceRequestInfoImpl* info =
369 ResourceRequestInfoImpl::ForRequest(request_);
370 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation(
371 info->GetGlobalRequestID(),
372 base::Bind(&NavigationResourceThrottle::OnTransferComplete,
373 weak_ptr_factory_.GetWeakPtr()));
374 }
375
376 void NavigationResourceThrottle::OnTransferComplete() {
377 DCHECK_CURRENTLY_ON(BrowserThread::IO);
378 DCHECK(in_cross_site_transition_);
379 in_cross_site_transition_ = false;
380
381 // If the results of the checks on the UI thread are known, unblock the
382 // navigation. Otherwise, wait until the callback has executed.
383 if (on_transfer_done_result_ != NavigationThrottle::DEFER) {
384 OnUIChecksPerformed(on_transfer_done_result_);
385 on_transfer_done_result_ = NavigationThrottle::DEFER;
386 }
387 }
388
291 } // namespace content 389 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698