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

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

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Addressed all jam@ latest comments. 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 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"
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/navigation_data.h" 22 #include "content/public/browser/navigation_data.h"
23 #include "content/public/browser/resource_context.h" 23 #include "content/public/browser/resource_context.h"
24 #include "content/public/browser/resource_dispatcher_host_delegate.h" 24 #include "content/public/browser/resource_dispatcher_host_delegate.h"
25 #include "content/public/browser/resource_request_info.h" 25 #include "content/public/browser/resource_request_info.h"
26 #include "content/public/browser/ssl_status.h" 26 #include "content/public/browser/ssl_status.h"
27 #include "content/public/common/referrer.h" 27 #include "content/public/common/referrer.h"
28 #include "net/url_request/redirect_info.h" 28 #include "net/url_request/redirect_info.h"
29 #include "net/url_request/url_request.h" 29 #include "net/url_request/url_request.h"
30 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
31 #include "net/url_request/url_request_job_factory.h" 31 #include "net/url_request/url_request_job_factory.h"
32 #include "third_party/WebKit/public/platform/WebMixedContentContextType.h"
32 #include "ui/base/page_transition_types.h" 33 #include "ui/base/page_transition_types.h"
33 34
34 namespace content { 35 namespace content {
35 36
36 namespace { 37 namespace {
37 38
38 // Used in unit tests to make UI thread checks succeed even if there is no 39 // Used in unit tests to make UI thread checks succeed even if there is no
39 // NavigationHandle. 40 // NavigationHandle.
40 bool g_ui_checks_always_succeed = false; 41 bool g_ui_checks_always_succeed = false;
41 42
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 UIChecksPerformedCallback callback, 93 UIChecksPerformedCallback callback,
93 int render_process_id, 94 int render_process_id,
94 int render_frame_host_id, 95 int render_frame_host_id,
95 const std::string& method, 96 const std::string& method,
96 const scoped_refptr<content::ResourceRequestBodyImpl>& 97 const scoped_refptr<content::ResourceRequestBodyImpl>&
97 resource_request_body, 98 resource_request_body,
98 const Referrer& sanitized_referrer, 99 const Referrer& sanitized_referrer,
99 bool has_user_gesture, 100 bool has_user_gesture,
100 ui::PageTransition transition, 101 ui::PageTransition transition,
101 bool is_external_protocol, 102 bool is_external_protocol,
102 RequestContextType request_context_type) { 103 RequestContextType request_context_type,
104 blink::WebMixedContentContextType mixed_content_context_type) {
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); 105 DCHECK_CURRENTLY_ON(BrowserThread::UI);
104 NavigationHandleImpl* navigation_handle = 106 NavigationHandleImpl* navigation_handle =
105 FindNavigationHandle(render_process_id, render_frame_host_id, callback); 107 FindNavigationHandle(render_process_id, render_frame_host_id, callback);
106 if (!navigation_handle) 108 if (!navigation_handle)
107 return; 109 return;
108 110
109 navigation_handle->WillStartRequest( 111 navigation_handle->WillStartRequest(
110 method, resource_request_body, sanitized_referrer, has_user_gesture, 112 method, resource_request_body, sanitized_referrer, has_user_gesture,
111 transition, is_external_protocol, request_context_type, 113 transition, is_external_protocol, request_context_type,
114 mixed_content_context_type,
112 base::Bind(&SendCheckResultToIOThread, callback)); 115 base::Bind(&SendCheckResultToIOThread, callback));
113 } 116 }
114 117
115 void CheckWillRedirectRequestOnUIThread( 118 void CheckWillRedirectRequestOnUIThread(
116 UIChecksPerformedCallback callback, 119 UIChecksPerformedCallback callback,
117 int render_process_id, 120 int render_process_id,
118 int render_frame_host_id, 121 int render_frame_host_id,
119 const GURL& new_url, 122 const GURL& new_url,
120 const std::string& new_method, 123 const std::string& new_method,
121 const GURL& new_referrer_url, 124 const GURL& new_referrer_url,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 render_frame_host, headers, connection_info, ssl_status, request_id, 174 render_frame_host, headers, connection_info, ssl_status, request_id,
172 should_replace_current_entry, is_download, is_stream, transfer_callback, 175 should_replace_current_entry, is_download, is_stream, transfer_callback,
173 base::Bind(&SendCheckResultToIOThread, callback)); 176 base::Bind(&SendCheckResultToIOThread, callback));
174 } 177 }
175 178
176 } // namespace 179 } // namespace
177 180
178 NavigationResourceThrottle::NavigationResourceThrottle( 181 NavigationResourceThrottle::NavigationResourceThrottle(
179 net::URLRequest* request, 182 net::URLRequest* request,
180 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, 183 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate,
181 RequestContextType request_context_type) 184 RequestContextType request_context_type,
185 blink::WebMixedContentContextType mixed_content_context_type)
182 : request_(request), 186 : request_(request),
183 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), 187 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate),
184 request_context_type_(request_context_type), 188 request_context_type_(request_context_type),
189 mixed_content_context_type_(mixed_content_context_type),
185 in_cross_site_transition_(false), 190 in_cross_site_transition_(false),
186 on_transfer_done_result_(NavigationThrottle::DEFER), 191 on_transfer_done_result_(NavigationThrottle::DEFER),
187 weak_ptr_factory_(this) {} 192 weak_ptr_factory_(this) {}
188 193
189 NavigationResourceThrottle::~NavigationResourceThrottle() {} 194 NavigationResourceThrottle::~NavigationResourceThrottle() {}
190 195
191 void NavigationResourceThrottle::WillStartRequest(bool* defer) { 196 void NavigationResourceThrottle::WillStartRequest(bool* defer) {
192 DCHECK_CURRENTLY_ON(BrowserThread::IO); 197 DCHECK_CURRENTLY_ON(BrowserThread::IO);
193 const ResourceRequestInfoImpl* info = 198 const ResourceRequestInfoImpl* info =
194 ResourceRequestInfoImpl::ForRequest(request_); 199 ResourceRequestInfoImpl::ForRequest(request_);
(...skipping 12 matching lines...) Expand all
207 weak_ptr_factory_.GetWeakPtr()); 212 weak_ptr_factory_.GetWeakPtr());
208 DCHECK(request_->method() == "POST" || request_->method() == "GET"); 213 DCHECK(request_->method() == "POST" || request_->method() == "GET");
209 BrowserThread::PostTask( 214 BrowserThread::PostTask(
210 BrowserThread::UI, FROM_HERE, 215 BrowserThread::UI, FROM_HERE,
211 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, 216 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id,
212 render_frame_id, request_->method(), info->body(), 217 render_frame_id, request_->method(), info->body(),
213 Referrer::SanitizeForRequest( 218 Referrer::SanitizeForRequest(
214 request_->url(), Referrer(GURL(request_->referrer()), 219 request_->url(), Referrer(GURL(request_->referrer()),
215 info->GetReferrerPolicy())), 220 info->GetReferrerPolicy())),
216 info->HasUserGesture(), info->GetPageTransition(), 221 info->HasUserGesture(), info->GetPageTransition(),
217 is_external_protocol, request_context_type_)); 222 is_external_protocol, request_context_type_,
223 mixed_content_context_type_));
218 *defer = true; 224 *defer = true;
219 } 225 }
220 226
221 void NavigationResourceThrottle::WillRedirectRequest( 227 void NavigationResourceThrottle::WillRedirectRequest(
222 const net::RedirectInfo& redirect_info, 228 const net::RedirectInfo& redirect_info,
223 bool* defer) { 229 bool* defer) {
224 DCHECK_CURRENTLY_ON(BrowserThread::IO); 230 DCHECK_CURRENTLY_ON(BrowserThread::IO);
225 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); 231 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_);
226 if (!info) 232 if (!info)
227 return; 233 return;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 384
379 // If the results of the checks on the UI thread are known, unblock the 385 // If the results of the checks on the UI thread are known, unblock the
380 // navigation. Otherwise, wait until the callback has executed. 386 // navigation. Otherwise, wait until the callback has executed.
381 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { 387 if (on_transfer_done_result_ != NavigationThrottle::DEFER) {
382 OnUIChecksPerformed(on_transfer_done_result_); 388 OnUIChecksPerformed(on_transfer_done_result_);
383 on_transfer_done_result_ = NavigationThrottle::DEFER; 389 on_transfer_done_result_ = NavigationThrottle::DEFER;
384 } 390 }
385 } 391 }
386 392
387 } // namespace content 393 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698