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

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

Issue 2812743002: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: manual merge 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 common_params_(common_params), 307 common_params_(common_params),
309 begin_params_(begin_params), 308 begin_params_(begin_params),
310 request_params_(request_params), 309 request_params_(request_params),
311 browser_initiated_(browser_initiated), 310 browser_initiated_(browser_initiated),
312 state_(NOT_STARTED), 311 state_(NOT_STARTED),
313 restore_type_(RestoreType::NONE), 312 restore_type_(RestoreType::NONE),
314 is_view_source_(false), 313 is_view_source_(false),
315 bindings_(NavigationEntryImpl::kInvalidBindings), 314 bindings_(NavigationEntryImpl::kInvalidBindings),
316 response_should_be_rendered_(true), 315 response_should_be_rendered_(true),
317 associated_site_instance_type_(AssociatedSiteInstanceType::NONE), 316 associated_site_instance_type_(AssociatedSiteInstanceType::NONE),
318 may_transfer_(may_transfer), 317 may_transfer_(may_transfer) {
319 weak_factory_(this) {
320 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); 318 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr));
321 319
322 // Sanitize the referrer. 320 // Sanitize the referrer.
323 common_params_.referrer = 321 common_params_.referrer =
324 Referrer::SanitizeForRequest(common_params_.url, common_params_.referrer); 322 Referrer::SanitizeForRequest(common_params_.url, common_params_.referrer);
325 323
326 if (may_transfer) { 324 if (may_transfer) {
327 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); 325 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node);
328 if (frame_entry) { 326 if (frame_entry) {
329 source_site_instance_ = frame_entry->source_site_instance(); 327 source_site_instance_ = frame_entry->source_site_instance();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 void NavigationRequest::OnStartChecksComplete( 659 void NavigationRequest::OnStartChecksComplete(
662 NavigationThrottle::ThrottleCheckResult result) { 660 NavigationThrottle::ThrottleCheckResult result) {
663 DCHECK(result != NavigationThrottle::DEFER); 661 DCHECK(result != NavigationThrottle::DEFER);
664 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); 662 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
665 663
666 if (on_start_checks_complete_closure_) 664 if (on_start_checks_complete_closure_)
667 on_start_checks_complete_closure_.Run(); 665 on_start_checks_complete_closure_.Run();
668 666
669 // Abort the request if needed. This will destroy the NavigationRequest. 667 // Abort the request if needed. This will destroy the NavigationRequest.
670 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 668 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
671 result == NavigationThrottle::CANCEL || 669 result == NavigationThrottle::CANCEL) {
672 result == NavigationThrottle::BLOCK_REQUEST) {
673 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 670 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
674 int error_code = result == NavigationThrottle::BLOCK_REQUEST 671 OnRequestFailed(false, net::ERR_ABORTED);
675 ? net::ERR_BLOCKED_BY_CLIENT
676 : net::ERR_ABORTED;
677 // If the start checks completed synchronously, which could happen if there
678 // is no onbeforeunload handler, then this could cause reentrancy into
679 // NavigationController. So use a PostTask to avoid that.
680 BrowserThread::PostTask(
681 BrowserThread::UI, FROM_HERE,
682 base::Bind(&NavigationRequest::OnRequestFailed,
683 weak_factory_.GetWeakPtr(), false, error_code));
684 672
685 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 673 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
686 // destroyed the NavigationRequest. 674 // destroyed the NavigationRequest.
675 return;
676 }
677
678 if (result == NavigationThrottle::BLOCK_REQUEST) {
679 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
680
681 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
682 // destroyed the NavigationRequest.
687 return; 683 return;
688 } 684 }
689 685
690 // Use the SiteInstance of the navigating RenderFrameHost to get access to 686 // Use the SiteInstance of the navigating RenderFrameHost to get access to
691 // the StoragePartition. Using the url of the navigation will result in a 687 // the StoragePartition. Using the url of the navigation will result in a
692 // wrong StoragePartition being picked when a WebView is navigating. 688 // wrong StoragePartition being picked when a WebView is navigating.
693 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); 689 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_);
694 RenderFrameHostImpl* navigating_frame_host = 690 RenderFrameHostImpl* navigating_frame_host =
695 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE 691 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE
696 ? frame_tree_node_->render_manager()->speculative_frame_host() 692 ? frame_tree_node_->render_manager()->speculative_frame_host()
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 840 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
845 841
846 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 842 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
847 common_params_, request_params_, 843 common_params_, request_params_,
848 is_view_source_); 844 is_view_source_);
849 845
850 frame_tree_node_->ResetNavigationRequest(true, true); 846 frame_tree_node_->ResetNavigationRequest(true, true);
851 } 847 }
852 848
853 } // namespace content 849 } // 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