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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.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/frame_host/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include "base/debug/dump_without_crashing.h" 7 #include "base/debug/dump_without_crashing.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/browser/appcache/appcache_navigation_handle.h" 9 #include "content/browser/appcache/appcache_navigation_handle.h"
10 #include "content/browser/appcache/appcache_service_impl.h" 10 #include "content/browser/appcache/appcache_service_impl.h"
11 #include "content/browser/browsing_data/clear_site_data_throttle.h" 11 #include "content/browser/browsing_data/clear_site_data_throttle.h"
12 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 13 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
14 #include "content/browser/frame_host/ancestor_throttle.h" 14 #include "content/browser/frame_host/ancestor_throttle.h"
15 #include "content/browser/frame_host/debug_urls.h" 15 #include "content/browser/frame_host/debug_urls.h"
16 #include "content/browser/frame_host/frame_tree_node.h" 16 #include "content/browser/frame_host/frame_tree_node.h"
17 #include "content/browser/frame_host/mixed_content_navigation_throttle.h"
17 #include "content/browser/frame_host/navigator.h" 18 #include "content/browser/frame_host/navigator.h"
18 #include "content/browser/frame_host/navigator_delegate.h" 19 #include "content/browser/frame_host/navigator_delegate.h"
19 #include "content/browser/loader/resource_dispatcher_host_impl.h" 20 #include "content/browser/loader/resource_dispatcher_host_impl.h"
20 #include "content/browser/service_worker/service_worker_context_wrapper.h" 21 #include "content/browser/service_worker/service_worker_context_wrapper.h"
21 #include "content/browser/service_worker/service_worker_navigation_handle.h" 22 #include "content/browser/service_worker/service_worker_navigation_handle.h"
22 #include "content/common/frame_messages.h" 23 #include "content/common/frame_messages.h"
23 #include "content/common/resource_request_body_impl.h" 24 #include "content/common/resource_request_body_impl.h"
24 #include "content/common/site_isolation_policy.h" 25 #include "content/common/site_isolation_policy.h"
25 #include "content/public/browser/content_browser_client.h" 26 #include "content/public/browser/content_browser_client.h"
26 #include "content/public/browser/navigation_ui_data.h" 27 #include "content/public/browser/navigation_ui_data.h"
27 #include "content/public/browser/site_instance.h" 28 #include "content/public/browser/site_instance.h"
28 #include "content/public/common/browser_side_navigation_policy.h" 29 #include "content/public/common/browser_side_navigation_policy.h"
29 #include "content/public/common/content_client.h" 30 #include "content/public/common/content_client.h"
30 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
31 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
32 #include "net/url_request/redirect_info.h" 33 #include "net/url_request/redirect_info.h"
34 #include "third_party/WebKit/public/platform/WebMixedContentContextType.h"
33 #include "url/gurl.h" 35 #include "url/gurl.h"
34 #include "url/url_constants.h" 36 #include "url/url_constants.h"
35 37
36 namespace content { 38 namespace content {
37 39
38 namespace { 40 namespace {
39 41
40 void UpdateThrottleCheckResult( 42 void UpdateThrottleCheckResult(
41 NavigationThrottle::ThrottleCheckResult* to_update, 43 NavigationThrottle::ThrottleCheckResult* to_update,
42 NavigationThrottle::ThrottleCheckResult result) { 44 NavigationThrottle::ThrottleCheckResult result) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 was_redirected_(false), 87 was_redirected_(false),
86 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), 88 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN),
87 original_url_(url), 89 original_url_(url),
88 state_(INITIAL), 90 state_(INITIAL),
89 is_transferring_(false), 91 is_transferring_(false),
90 frame_tree_node_(frame_tree_node), 92 frame_tree_node_(frame_tree_node),
91 next_index_(0), 93 next_index_(0),
92 navigation_start_(navigation_start), 94 navigation_start_(navigation_start),
93 pending_nav_entry_id_(pending_nav_entry_id), 95 pending_nav_entry_id_(pending_nav_entry_id),
94 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), 96 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED),
97 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable),
95 should_replace_current_entry_(false), 98 should_replace_current_entry_(false),
96 is_download_(false), 99 is_download_(false),
97 is_stream_(false), 100 is_stream_(false),
98 started_from_context_menu_(started_from_context_menu), 101 started_from_context_menu_(started_from_context_menu),
99 weak_factory_(this) { 102 weak_factory_(this) {
100 DCHECK(!navigation_start.is_null()); 103 DCHECK(!navigation_start.is_null());
101 redirect_chain_.push_back(url); 104 redirect_chain_.push_back(url);
102 105
103 starting_site_instance_ = 106 starting_site_instance_ =
104 frame_tree_node_->current_frame_host()->GetSiteInstance(); 107 frame_tree_node_->current_frame_host()->GetSiteInstance();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 method = "POST"; 311 method = "POST";
309 312
310 std::string body = "test=body"; 313 std::string body = "test=body";
311 resource_request_body = new ResourceRequestBodyImpl(); 314 resource_request_body = new ResourceRequestBodyImpl();
312 resource_request_body->AppendBytes(body.data(), body.size()); 315 resource_request_body->AppendBytes(body.data(), body.size());
313 } 316 }
314 317
315 WillStartRequest(method, resource_request_body, sanitized_referrer, 318 WillStartRequest(method, resource_request_body, sanitized_referrer,
316 has_user_gesture, transition, is_external_protocol, 319 has_user_gesture, transition, is_external_protocol,
317 REQUEST_CONTEXT_TYPE_LOCATION, 320 REQUEST_CONTEXT_TYPE_LOCATION,
321 blink::WebMixedContentContextType::Blockable,
318 base::Bind(&UpdateThrottleCheckResult, &result)); 322 base::Bind(&UpdateThrottleCheckResult, &result));
319 323
320 // Reset the callback to ensure it will not be called later. 324 // Reset the callback to ensure it will not be called later.
321 complete_callback_.Reset(); 325 complete_callback_.Reset();
322 return result; 326 return result;
323 } 327 }
324 328
325 NavigationThrottle::ThrottleCheckResult 329 NavigationThrottle::ThrottleCheckResult
326 NavigationHandleImpl::CallWillRedirectRequestForTesting( 330 NavigationHandleImpl::CallWillRedirectRequestForTesting(
327 const GURL& new_url, 331 const GURL& new_url,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 419 }
416 420
417 void NavigationHandleImpl::WillStartRequest( 421 void NavigationHandleImpl::WillStartRequest(
418 const std::string& method, 422 const std::string& method,
419 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, 423 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body,
420 const Referrer& sanitized_referrer, 424 const Referrer& sanitized_referrer,
421 bool has_user_gesture, 425 bool has_user_gesture,
422 ui::PageTransition transition, 426 ui::PageTransition transition,
423 bool is_external_protocol, 427 bool is_external_protocol,
424 RequestContextType request_context_type, 428 RequestContextType request_context_type,
429 blink::WebMixedContentContextType mixed_content_context_type,
425 const ThrottleChecksFinishedCallback& callback) { 430 const ThrottleChecksFinishedCallback& callback) {
426 if (method != "POST") 431 if (method != "POST")
427 DCHECK(!resource_request_body); 432 DCHECK(!resource_request_body);
428 433
429 // Update the navigation parameters. 434 // Update the navigation parameters.
430 method_ = method; 435 method_ = method;
431 if (method_ == "POST") 436 if (method_ == "POST")
432 resource_request_body_ = resource_request_body; 437 resource_request_body_ = resource_request_body;
433 sanitized_referrer_ = sanitized_referrer; 438 sanitized_referrer_ = sanitized_referrer;
434 has_user_gesture_ = has_user_gesture; 439 has_user_gesture_ = has_user_gesture;
435 transition_ = transition; 440 transition_ = transition;
436 is_external_protocol_ = is_external_protocol; 441 is_external_protocol_ = is_external_protocol;
437 request_context_type_ = request_context_type; 442 request_context_type_ = request_context_type;
443 mixed_content_context_type_ = mixed_content_context_type;
438 state_ = WILL_SEND_REQUEST; 444 state_ = WILL_SEND_REQUEST;
439 complete_callback_ = callback; 445 complete_callback_ = callback;
440 446
441 RegisterNavigationThrottles(); 447 RegisterNavigationThrottles();
442 448
443 if (IsBrowserSideNavigationEnabled()) 449 if (IsBrowserSideNavigationEnabled())
444 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); 450 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this);
445 451
446 // Notify each throttle of the request. 452 // Notify each throttle of the request.
447 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); 453 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 782
777 // No code after running the callback, as it might have resulted in our 783 // No code after running the callback, as it might have resulted in our
778 // destruction. 784 // destruction.
779 } 785 }
780 786
781 void NavigationHandleImpl::RegisterNavigationThrottles() { 787 void NavigationHandleImpl::RegisterNavigationThrottles() {
782 // Register the navigation throttles. The ScopedVector returned by 788 // Register the navigation throttles. The ScopedVector returned by
783 // GetNavigationThrottles is not assigned to throttles_ directly because it 789 // GetNavigationThrottles is not assigned to throttles_ directly because it
784 // would overwrite any throttle previously added with 790 // would overwrite any throttle previously added with
785 // RegisterThrottleForTesting. 791 // RegisterThrottleForTesting.
792 if (IsBrowserSideNavigationEnabled()) {
793 throttles_.insert(throttles_.end(),
794 new MixedContentNavigationThrottle(this));
795 }
786 ScopedVector<NavigationThrottle> throttles_to_register = 796 ScopedVector<NavigationThrottle> throttles_to_register =
787 GetDelegate()->CreateThrottlesForNavigation(this); 797 GetDelegate()->CreateThrottlesForNavigation(this);
788 std::unique_ptr<NavigationThrottle> devtools_throttle = 798 std::unique_ptr<NavigationThrottle> devtools_throttle =
789 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); 799 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this);
790 if (devtools_throttle) 800 if (devtools_throttle)
791 throttles_to_register.push_back(std::move(devtools_throttle)); 801 throttles_to_register.push_back(std::move(devtools_throttle));
792 802
793 std::unique_ptr<NavigationThrottle> clear_site_data_throttle = 803 std::unique_ptr<NavigationThrottle> clear_site_data_throttle =
794 ClearSiteDataThrottle::CreateThrottleForNavigation(this); 804 ClearSiteDataThrottle::CreateThrottleForNavigation(this);
795 if (clear_site_data_throttle) 805 if (clear_site_data_throttle)
796 throttles_to_register.push_back(std::move(clear_site_data_throttle)); 806 throttles_to_register.push_back(std::move(clear_site_data_throttle));
797 807
798 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = 808 std::unique_ptr<content::NavigationThrottle> ancestor_throttle =
799 content::AncestorThrottle::MaybeCreateThrottleFor(this); 809 content::AncestorThrottle::MaybeCreateThrottleFor(this);
800 if (ancestor_throttle) 810 if (ancestor_throttle)
801 throttles_.push_back(std::move(ancestor_throttle)); 811 throttles_.push_back(std::move(ancestor_throttle));
802 812
803 if (throttles_to_register.size() > 0) { 813 if (throttles_to_register.size() > 0) {
804 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), 814 throttles_.insert(throttles_.begin(), throttles_to_register.begin(),
805 throttles_to_register.end()); 815 throttles_to_register.end());
806 throttles_to_register.weak_clear(); 816 throttles_to_register.weak_clear();
807 } 817 }
808 } 818 }
809 819
810 } // namespace content 820 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698