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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2783723002: Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: fix content_browsertests with plznavigate and also remove now unnecessary unloadcontroller change Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/browser/frame_host/navigator_impl.h" 21 #include "content/browser/frame_host/navigator_impl.h"
22 #include "content/browser/frame_host/render_frame_host_impl.h" 22 #include "content/browser/frame_host/render_frame_host_impl.h"
23 #include "content/browser/loader/navigation_url_loader.h" 23 #include "content/browser/loader/navigation_url_loader.h"
24 #include "content/browser/renderer_host/render_process_host_impl.h" 24 #include "content/browser/renderer_host/render_process_host_impl.h"
25 #include "content/browser/service_worker/service_worker_context_wrapper.h" 25 #include "content/browser/service_worker/service_worker_context_wrapper.h"
26 #include "content/browser/service_worker/service_worker_navigation_handle.h" 26 #include "content/browser/service_worker/service_worker_navigation_handle.h"
27 #include "content/browser/site_instance_impl.h" 27 #include "content/browser/site_instance_impl.h"
28 #include "content/common/appcache_interfaces.h" 28 #include "content/common/appcache_interfaces.h"
29 #include "content/common/resource_request_body_impl.h" 29 #include "content/common/resource_request_body_impl.h"
30 #include "content/public/browser/browser_context.h" 30 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/content_browser_client.h" 32 #include "content/public/browser/content_browser_client.h"
32 #include "content/public/browser/global_request_id.h" 33 #include "content/public/browser/global_request_id.h"
33 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
34 #include "content/public/browser/navigation_data.h" 35 #include "content/public/browser/navigation_data.h"
35 #include "content/public/browser/navigation_ui_data.h" 36 #include "content/public/browser/navigation_ui_data.h"
36 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
37 #include "content/public/browser/storage_partition.h" 38 #include "content/public/browser/storage_partition.h"
38 #include "content/public/browser/stream_handle.h" 39 #include "content/public/browser/stream_handle.h"
39 #include "content/public/common/appcache_info.h" 40 #include "content/public/common/appcache_info.h"
40 #include "content/public/common/content_client.h" 41 #include "content/public/common/content_client.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 common_params_(common_params), 305 common_params_(common_params),
305 begin_params_(begin_params), 306 begin_params_(begin_params),
306 request_params_(request_params), 307 request_params_(request_params),
307 browser_initiated_(browser_initiated), 308 browser_initiated_(browser_initiated),
308 state_(NOT_STARTED), 309 state_(NOT_STARTED),
309 restore_type_(RestoreType::NONE), 310 restore_type_(RestoreType::NONE),
310 is_view_source_(false), 311 is_view_source_(false),
311 bindings_(NavigationEntryImpl::kInvalidBindings), 312 bindings_(NavigationEntryImpl::kInvalidBindings),
312 response_should_be_rendered_(true), 313 response_should_be_rendered_(true),
313 associated_site_instance_type_(AssociatedSiteInstanceType::NONE), 314 associated_site_instance_type_(AssociatedSiteInstanceType::NONE),
314 may_transfer_(may_transfer) { 315 may_transfer_(may_transfer),
316 weak_factory_(this) {
315 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); 317 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr));
316 318
317 // Sanitize the referrer. 319 // Sanitize the referrer.
318 common_params_.referrer = 320 common_params_.referrer =
319 Referrer::SanitizeForRequest(common_params_.url, common_params_.referrer); 321 Referrer::SanitizeForRequest(common_params_.url, common_params_.referrer);
320 322
321 if (may_transfer) { 323 if (may_transfer) {
322 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); 324 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node);
323 if (frame_entry) { 325 if (frame_entry) {
324 source_site_instance_ = frame_entry->source_site_instance(); 326 source_site_instance_ = frame_entry->source_site_instance();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 void NavigationRequest::OnStartChecksComplete( 658 void NavigationRequest::OnStartChecksComplete(
657 NavigationThrottle::ThrottleCheckResult result) { 659 NavigationThrottle::ThrottleCheckResult result) {
658 DCHECK(result != NavigationThrottle::DEFER); 660 DCHECK(result != NavigationThrottle::DEFER);
659 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); 661 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
660 662
661 if (on_start_checks_complete_closure_) 663 if (on_start_checks_complete_closure_)
662 on_start_checks_complete_closure_.Run(); 664 on_start_checks_complete_closure_.Run();
663 665
664 // Abort the request if needed. This will destroy the NavigationRequest. 666 // Abort the request if needed. This will destroy the NavigationRequest.
665 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 667 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
666 result == NavigationThrottle::CANCEL) { 668 result == NavigationThrottle::CANCEL ||
669 result == NavigationThrottle::BLOCK_REQUEST) {
667 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 670 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
668 OnRequestFailed(false, net::ERR_ABORTED); 671 int error_code = result == NavigationThrottle::BLOCK_REQUEST
672 ? net::ERR_BLOCKED_BY_CLIENT
673 : net::ERR_ABORTED;
674 // If the start checks completed synchronously, which could happen if there
675 // is no onbeforeunload handler, then this could cause reentrancy into
676 // NavigationController. So use a PostTask to avoid that.
677 BrowserThread::PostTask(
678 BrowserThread::UI, FROM_HERE,
679 base::Bind(&NavigationRequest::OnRequestFailed,
680 weak_factory_.GetWeakPtr(), false, error_code));
nasko 2017/03/29 23:31:26 Let's try to reason through this one, as it isn't
669 681
670 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 682 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
671 // destroyed the NavigationRequest. 683 // destroyed the NavigationRequest.
672 return;
673 }
674
675 if (result == NavigationThrottle::BLOCK_REQUEST) {
676 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
677
678 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
679 // destroyed the NavigationRequest.
680 return; 684 return;
681 } 685 }
682 686
683 // Use the SiteInstance of the navigating RenderFrameHost to get access to 687 // Use the SiteInstance of the navigating RenderFrameHost to get access to
684 // the StoragePartition. Using the url of the navigation will result in a 688 // the StoragePartition. Using the url of the navigation will result in a
685 // wrong StoragePartition being picked when a WebView is navigating. 689 // wrong StoragePartition being picked when a WebView is navigating.
686 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); 690 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_);
687 RenderFrameHostImpl* navigating_frame_host = 691 RenderFrameHostImpl* navigating_frame_host =
688 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE 692 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE
689 ? frame_tree_node_->render_manager()->speculative_frame_host() 693 ? frame_tree_node_->render_manager()->speculative_frame_host()
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 841 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
838 842
839 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 843 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
840 common_params_, request_params_, 844 common_params_, request_params_,
841 is_view_source_); 845 is_view_source_);
842 846
843 frame_tree_node_->ResetNavigationRequest(true, true); 847 frame_tree_node_->ResetNavigationRequest(true, true);
844 } 848 }
845 849
846 } // namespace content 850 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698