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

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

Issue 2803633004: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: 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"
32 #include "content/public/browser/content_browser_client.h" 31 #include "content/public/browser/content_browser_client.h"
33 #include "content/public/browser/global_request_id.h" 32 #include "content/public/browser/global_request_id.h"
34 #include "content/public/browser/navigation_controller.h" 33 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_data.h" 34 #include "content/public/browser/navigation_data.h"
36 #include "content/public/browser/navigation_ui_data.h" 35 #include "content/public/browser/navigation_ui_data.h"
37 #include "content/public/browser/render_view_host.h" 36 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/storage_partition.h" 37 #include "content/public/browser/storage_partition.h"
39 #include "content/public/browser/stream_handle.h" 38 #include "content/public/browser/stream_handle.h"
40 #include "content/public/common/appcache_info.h" 39 #include "content/public/common/appcache_info.h"
41 #include "content/public/common/content_client.h" 40 #include "content/public/common/content_client.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 common_params_(common_params), 304 common_params_(common_params),
306 begin_params_(begin_params), 305 begin_params_(begin_params),
307 request_params_(request_params), 306 request_params_(request_params),
308 browser_initiated_(browser_initiated), 307 browser_initiated_(browser_initiated),
309 state_(NOT_STARTED), 308 state_(NOT_STARTED),
310 restore_type_(RestoreType::NONE), 309 restore_type_(RestoreType::NONE),
311 is_view_source_(false), 310 is_view_source_(false),
312 bindings_(NavigationEntryImpl::kInvalidBindings), 311 bindings_(NavigationEntryImpl::kInvalidBindings),
313 response_should_be_rendered_(true), 312 response_should_be_rendered_(true),
314 associated_site_instance_type_(AssociatedSiteInstanceType::NONE), 313 associated_site_instance_type_(AssociatedSiteInstanceType::NONE),
315 may_transfer_(may_transfer), 314 may_transfer_(may_transfer) {
316 weak_factory_(this) {
317 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); 315 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr));
318 316
319 // Sanitize the referrer. 317 // Sanitize the referrer.
320 common_params_.referrer = 318 common_params_.referrer =
321 Referrer::SanitizeForRequest(common_params_.url, common_params_.referrer); 319 Referrer::SanitizeForRequest(common_params_.url, common_params_.referrer);
322 320
323 if (may_transfer) { 321 if (may_transfer) {
324 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); 322 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node);
325 if (frame_entry) { 323 if (frame_entry) {
326 source_site_instance_ = frame_entry->source_site_instance(); 324 source_site_instance_ = frame_entry->source_site_instance();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 void NavigationRequest::OnStartChecksComplete( 656 void NavigationRequest::OnStartChecksComplete(
659 NavigationThrottle::ThrottleCheckResult result) { 657 NavigationThrottle::ThrottleCheckResult result) {
660 DCHECK(result != NavigationThrottle::DEFER); 658 DCHECK(result != NavigationThrottle::DEFER);
661 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); 659 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
662 660
663 if (on_start_checks_complete_closure_) 661 if (on_start_checks_complete_closure_)
664 on_start_checks_complete_closure_.Run(); 662 on_start_checks_complete_closure_.Run();
665 663
666 // Abort the request if needed. This will destroy the NavigationRequest. 664 // Abort the request if needed. This will destroy the NavigationRequest.
667 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 665 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
668 result == NavigationThrottle::CANCEL || 666 result == NavigationThrottle::CANCEL) {
669 result == NavigationThrottle::BLOCK_REQUEST) {
670 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 667 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
671 int error_code = result == NavigationThrottle::BLOCK_REQUEST 668 OnRequestFailed(false, net::ERR_ABORTED);
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));
681 669
682 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 670 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
683 // destroyed the NavigationRequest. 671 // 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.
684 return; 680 return;
685 } 681 }
686 682
687 // Use the SiteInstance of the navigating RenderFrameHost to get access to 683 // Use the SiteInstance of the navigating RenderFrameHost to get access to
688 // the StoragePartition. Using the url of the navigation will result in a 684 // the StoragePartition. Using the url of the navigation will result in a
689 // wrong StoragePartition being picked when a WebView is navigating. 685 // wrong StoragePartition being picked when a WebView is navigating.
690 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); 686 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_);
691 RenderFrameHostImpl* navigating_frame_host = 687 RenderFrameHostImpl* navigating_frame_host =
692 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE 688 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE
693 ? frame_tree_node_->render_manager()->speculative_frame_host() 689 ? frame_tree_node_->render_manager()->speculative_frame_host()
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 837 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
842 838
843 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 839 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
844 common_params_, request_params_, 840 common_params_, request_params_,
845 is_view_source_); 841 is_view_source_);
846 842
847 frame_tree_node_->ResetNavigationRequest(true, true); 843 frame_tree_node_->ResetNavigationRequest(true, true);
848 } 844 }
849 845
850 } // namespace content 846 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698