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

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

Issue 2194243002: Suppress JavaScript dialogs when a tab puts itself into fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content:: Created 4 years, 4 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 (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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 4051 matching lines...) Expand 10 before | Expand all | Expand 10 after
4062 void WebContentsImpl::RunJavaScriptMessage( 4062 void WebContentsImpl::RunJavaScriptMessage(
4063 RenderFrameHost* render_frame_host, 4063 RenderFrameHost* render_frame_host,
4064 const base::string16& message, 4064 const base::string16& message,
4065 const base::string16& default_prompt, 4065 const base::string16& default_prompt,
4066 const GURL& frame_url, 4066 const GURL& frame_url,
4067 JavaScriptMessageType javascript_message_type, 4067 JavaScriptMessageType javascript_message_type,
4068 IPC::Message* reply_msg) { 4068 IPC::Message* reply_msg) {
4069 // Suppress JavaScript dialogs when requested. Also suppress messages when 4069 // Suppress JavaScript dialogs when requested. Also suppress messages when
4070 // showing an interstitial as it's shown over the previous page and we don't 4070 // showing an interstitial as it's shown over the previous page and we don't
4071 // want the hidden page's dialogs to interfere with the interstitial. 4071 // want the hidden page's dialogs to interfere with the interstitial.
4072 bool suppress_this_message = 4072 bool suppress_this_message = ShowingInterstitialPage() || !delegate_ ||
4073 ShowingInterstitialPage() || !delegate_ || 4073 delegate_->ShouldSuppressDialogs(this, false) ||
4074 delegate_->ShouldSuppressDialogs(this) || 4074 !delegate_->GetJavaScriptDialogManager(this);
4075 !delegate_->GetJavaScriptDialogManager(this);
4076 4075
4077 if (!suppress_this_message) { 4076 if (!suppress_this_message) {
4078 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); 4077 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this);
4079 dialog_manager_->RunJavaScriptDialog( 4078 dialog_manager_->RunJavaScriptDialog(
4080 this, frame_url, javascript_message_type, message, default_prompt, 4079 this, frame_url, javascript_message_type, message, default_prompt,
4081 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), 4080 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
4082 render_frame_host->GetProcess()->GetID(), 4081 render_frame_host->GetProcess()->GetID(),
4083 render_frame_host->GetRoutingID(), reply_msg, false), 4082 render_frame_host->GetRoutingID(), reply_msg, false),
4084 &suppress_this_message); 4083 &suppress_this_message);
4085 } 4084 }
(...skipping 12 matching lines...) Expand all
4098 4097
4099 void WebContentsImpl::RunBeforeUnloadConfirm( 4098 void WebContentsImpl::RunBeforeUnloadConfirm(
4100 RenderFrameHost* render_frame_host, 4099 RenderFrameHost* render_frame_host,
4101 bool is_reload, 4100 bool is_reload,
4102 IPC::Message* reply_msg) { 4101 IPC::Message* reply_msg) {
4103 RenderFrameHostImpl* rfhi = 4102 RenderFrameHostImpl* rfhi =
4104 static_cast<RenderFrameHostImpl*>(render_frame_host); 4103 static_cast<RenderFrameHostImpl*>(render_frame_host);
4105 if (delegate_) 4104 if (delegate_)
4106 delegate_->WillRunBeforeUnloadConfirm(); 4105 delegate_->WillRunBeforeUnloadConfirm();
4107 4106
4108 bool suppress_this_message = 4107 bool suppress_this_message = !rfhi->is_active() ||
4109 !rfhi->is_active() || 4108 ShowingInterstitialPage() || !delegate_ ||
4110 ShowingInterstitialPage() || !delegate_ || 4109 delegate_->ShouldSuppressDialogs(this, true) ||
4111 delegate_->ShouldSuppressDialogs(this) || 4110 !delegate_->GetJavaScriptDialogManager(this);
4112 !delegate_->GetJavaScriptDialogManager(this);
4113 if (suppress_this_message) { 4111 if (suppress_this_message) {
4114 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); 4112 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true);
4115 return; 4113 return;
4116 } 4114 }
4117 4115
4118 is_showing_before_unload_dialog_ = true; 4116 is_showing_before_unload_dialog_ = true;
4119 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); 4117 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this);
4120 dialog_manager_->RunBeforeUnloadDialog( 4118 dialog_manager_->RunBeforeUnloadDialog(
4121 this, is_reload, 4119 this, is_reload,
4122 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), 4120 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
5153 for (RenderViewHost* render_view_host : render_view_host_set) 5151 for (RenderViewHost* render_view_host : render_view_host_set)
5154 render_view_host->OnWebkitPreferencesChanged(); 5152 render_view_host->OnWebkitPreferencesChanged();
5155 } 5153 }
5156 5154
5157 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5155 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5158 JavaScriptDialogManager* dialog_manager) { 5156 JavaScriptDialogManager* dialog_manager) {
5159 dialog_manager_ = dialog_manager; 5157 dialog_manager_ = dialog_manager;
5160 } 5158 }
5161 5159
5162 } // namespace content 5160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698