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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 88503002: Have the unload event execute in background on cross-site navigations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Charlie's comments Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 2708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 2719
2720 void WebContentsImpl::RemoveBrowserPluginEmbedder() { 2720 void WebContentsImpl::RemoveBrowserPluginEmbedder() {
2721 if (browser_plugin_embedder_) 2721 if (browser_plugin_embedder_)
2722 browser_plugin_embedder_.reset(); 2722 browser_plugin_embedder_.reset();
2723 } 2723 }
2724 2724
2725 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { 2725 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) {
2726 // Don't send notifications if we are just creating a swapped-out RVH for 2726 // Don't send notifications if we are just creating a swapped-out RVH for
2727 // the opener chain. These won't be used for view-source or WebUI, so it's 2727 // the opener chain. These won't be used for view-source or WebUI, so it's
2728 // ok to return early. 2728 // ok to return early.
2729 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) 2729 if (static_cast<RenderViewHostImpl*>(render_view_host)->IsSwappedOut())
2730 return; 2730 return;
2731 2731
2732 if (delegate_) 2732 if (delegate_)
2733 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); 2733 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent());
2734 2734
2735 NotificationService::current()->Notify( 2735 NotificationService::current()->Notify(
2736 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 2736 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
2737 Source<WebContents>(this), 2737 Source<WebContents>(this),
2738 Details<RenderViewHost>(render_view_host)); 2738 Details<RenderViewHost>(render_view_host));
2739 2739
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 3140
3141 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, 3141 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh,
3142 const GURL& url, 3142 const GURL& url,
3143 const Referrer& referrer, 3143 const Referrer& referrer,
3144 WindowOpenDisposition disposition, 3144 WindowOpenDisposition disposition,
3145 int64 source_frame_id, 3145 int64 source_frame_id,
3146 bool should_replace_current_entry, 3146 bool should_replace_current_entry,
3147 bool user_gesture) { 3147 bool user_gesture) {
3148 // If this came from a swapped out RenderViewHost, we only allow the request 3148 // If this came from a swapped out RenderViewHost, we only allow the request
3149 // if we are still in the same BrowsingInstance. 3149 // if we are still in the same BrowsingInstance.
3150 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && 3150 if (static_cast<RenderViewHostImpl*>(rvh)->IsSwappedOut() &&
3151 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { 3151 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) {
3152 return; 3152 return;
3153 } 3153 }
3154 3154
3155 // Delegate to RequestTransferURL because this is just the generic 3155 // Delegate to RequestTransferURL because this is just the generic
3156 // case where |old_request_id| is empty. 3156 // case where |old_request_id| is empty.
3157 // TODO(creis): Pass the redirect_chain into this method to support client 3157 // TODO(creis): Pass the redirect_chain into this method to support client
3158 // redirects. http://crbug.com/311721. 3158 // redirects. http://crbug.com/311721.
3159 std::vector<GURL> redirect_chain; 3159 std::vector<GURL> redirect_chain;
3160 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, 3160 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3310 const base::string16& message, 3310 const base::string16& message,
3311 const base::string16& default_prompt, 3311 const base::string16& default_prompt,
3312 const GURL& frame_url, 3312 const GURL& frame_url,
3313 JavaScriptMessageType javascript_message_type, 3313 JavaScriptMessageType javascript_message_type,
3314 IPC::Message* reply_msg, 3314 IPC::Message* reply_msg,
3315 bool* did_suppress_message) { 3315 bool* did_suppress_message) {
3316 // Suppress JavaScript dialogs when requested. Also suppress messages when 3316 // Suppress JavaScript dialogs when requested. Also suppress messages when
3317 // showing an interstitial as it's shown over the previous page and we don't 3317 // showing an interstitial as it's shown over the previous page and we don't
3318 // want the hidden page's dialogs to interfere with the interstitial. 3318 // want the hidden page's dialogs to interfere with the interstitial.
3319 bool suppress_this_message = 3319 bool suppress_this_message =
3320 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || 3320 static_cast<RenderViewHostImpl*>(rvh)->IsSwappedOut() ||
3321 ShowingInterstitialPage() || 3321 ShowingInterstitialPage() ||
3322 !delegate_ || 3322 !delegate_ ||
3323 delegate_->ShouldSuppressDialogs() || 3323 delegate_->ShouldSuppressDialogs() ||
3324 !delegate_->GetJavaScriptDialogManager(); 3324 !delegate_->GetJavaScriptDialogManager();
3325 3325
3326 if (!suppress_this_message) { 3326 if (!suppress_this_message) {
3327 std::string accept_lang = GetContentClient()->browser()-> 3327 std::string accept_lang = GetContentClient()->browser()->
3328 GetAcceptLangs(GetBrowserContext()); 3328 GetAcceptLangs(GetBrowserContext());
3329 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); 3329 dialog_manager_ = delegate_->GetJavaScriptDialogManager();
3330 dialog_manager_->RunJavaScriptDialog( 3330 dialog_manager_->RunJavaScriptDialog(
(...skipping 24 matching lines...) Expand all
3355 3355
3356 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, 3356 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh,
3357 const base::string16& message, 3357 const base::string16& message,
3358 bool is_reload, 3358 bool is_reload,
3359 IPC::Message* reply_msg) { 3359 IPC::Message* reply_msg) {
3360 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); 3360 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
3361 if (delegate_) 3361 if (delegate_)
3362 delegate_->WillRunBeforeUnloadConfirm(); 3362 delegate_->WillRunBeforeUnloadConfirm();
3363 3363
3364 bool suppress_this_message = 3364 bool suppress_this_message =
3365 rvhi->is_swapped_out() || 3365 rvhi->rvh_state() != RenderViewHostImpl::STATE_DEFAULT ||
3366 !delegate_ || 3366 !delegate_ ||
3367 delegate_->ShouldSuppressDialogs() || 3367 delegate_->ShouldSuppressDialogs() ||
3368 !delegate_->GetJavaScriptDialogManager(); 3368 !delegate_->GetJavaScriptDialogManager();
3369 if (suppress_this_message) { 3369 if (suppress_this_message) {
3370 // The reply must be sent to the RVH that sent the request. 3370 // The reply must be sent to the RVH that sent the request.
3371 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); 3371 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16());
3372 return; 3372 return;
3373 } 3373 }
3374 3374
3375 is_showing_before_unload_dialog_ = true; 3375 is_showing_before_unload_dialog_ = true;
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 } 3739 }
3740 3740
3741 void WebContentsImpl::OnFrameRemoved( 3741 void WebContentsImpl::OnFrameRemoved(
3742 RenderViewHostImpl* render_view_host, 3742 RenderViewHostImpl* render_view_host,
3743 int64 frame_id) { 3743 int64 frame_id) {
3744 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3744 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3745 FrameDetached(render_view_host, frame_id)); 3745 FrameDetached(render_view_host, frame_id));
3746 } 3746 }
3747 3747
3748 } // namespace content 3748 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698