OLD | NEW |
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 4074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4085 void WebContentsImpl::RunJavaScriptMessage( | 4085 void WebContentsImpl::RunJavaScriptMessage( |
4086 RenderFrameHost* render_frame_host, | 4086 RenderFrameHost* render_frame_host, |
4087 const base::string16& message, | 4087 const base::string16& message, |
4088 const base::string16& default_prompt, | 4088 const base::string16& default_prompt, |
4089 const GURL& frame_url, | 4089 const GURL& frame_url, |
4090 JavaScriptMessageType javascript_message_type, | 4090 JavaScriptMessageType javascript_message_type, |
4091 IPC::Message* reply_msg) { | 4091 IPC::Message* reply_msg) { |
4092 // Suppress JavaScript dialogs when requested. Also suppress messages when | 4092 // Suppress JavaScript dialogs when requested. Also suppress messages when |
4093 // showing an interstitial as it's shown over the previous page and we don't | 4093 // showing an interstitial as it's shown over the previous page and we don't |
4094 // want the hidden page's dialogs to interfere with the interstitial. | 4094 // want the hidden page's dialogs to interfere with the interstitial. |
4095 bool suppress_this_message = | 4095 bool suppress_this_message = ShowingInterstitialPage() || !delegate_ || |
4096 ShowingInterstitialPage() || !delegate_ || | 4096 delegate_->ShouldSuppressDialogs(this, false) || |
4097 delegate_->ShouldSuppressDialogs(this) || | 4097 !delegate_->GetJavaScriptDialogManager(this); |
4098 !delegate_->GetJavaScriptDialogManager(this); | |
4099 | 4098 |
4100 if (!suppress_this_message) { | 4099 if (!suppress_this_message) { |
4101 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4100 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
4102 dialog_manager_->RunJavaScriptDialog( | 4101 dialog_manager_->RunJavaScriptDialog( |
4103 this, frame_url, javascript_message_type, message, default_prompt, | 4102 this, frame_url, javascript_message_type, message, default_prompt, |
4104 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4103 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
4105 render_frame_host->GetProcess()->GetID(), | 4104 render_frame_host->GetProcess()->GetID(), |
4106 render_frame_host->GetRoutingID(), reply_msg, false), | 4105 render_frame_host->GetRoutingID(), reply_msg, false), |
4107 &suppress_this_message); | 4106 &suppress_this_message); |
4108 } | 4107 } |
(...skipping 12 matching lines...) Expand all Loading... |
4121 | 4120 |
4122 void WebContentsImpl::RunBeforeUnloadConfirm( | 4121 void WebContentsImpl::RunBeforeUnloadConfirm( |
4123 RenderFrameHost* render_frame_host, | 4122 RenderFrameHost* render_frame_host, |
4124 bool is_reload, | 4123 bool is_reload, |
4125 IPC::Message* reply_msg) { | 4124 IPC::Message* reply_msg) { |
4126 RenderFrameHostImpl* rfhi = | 4125 RenderFrameHostImpl* rfhi = |
4127 static_cast<RenderFrameHostImpl*>(render_frame_host); | 4126 static_cast<RenderFrameHostImpl*>(render_frame_host); |
4128 if (delegate_) | 4127 if (delegate_) |
4129 delegate_->WillRunBeforeUnloadConfirm(); | 4128 delegate_->WillRunBeforeUnloadConfirm(); |
4130 | 4129 |
4131 bool suppress_this_message = | 4130 bool suppress_this_message = !rfhi->is_active() || |
4132 !rfhi->is_active() || | 4131 ShowingInterstitialPage() || !delegate_ || |
4133 ShowingInterstitialPage() || !delegate_ || | 4132 delegate_->ShouldSuppressDialogs(this, true) || |
4134 delegate_->ShouldSuppressDialogs(this) || | 4133 !delegate_->GetJavaScriptDialogManager(this); |
4135 !delegate_->GetJavaScriptDialogManager(this); | |
4136 if (suppress_this_message) { | 4134 if (suppress_this_message) { |
4137 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); | 4135 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); |
4138 return; | 4136 return; |
4139 } | 4137 } |
4140 | 4138 |
4141 is_showing_before_unload_dialog_ = true; | 4139 is_showing_before_unload_dialog_ = true; |
4142 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4140 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
4143 dialog_manager_->RunBeforeUnloadDialog( | 4141 dialog_manager_->RunBeforeUnloadDialog( |
4144 this, is_reload, | 4142 this, is_reload, |
4145 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4143 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5232 for (RenderViewHost* render_view_host : render_view_host_set) | 5230 for (RenderViewHost* render_view_host : render_view_host_set) |
5233 render_view_host->OnWebkitPreferencesChanged(); | 5231 render_view_host->OnWebkitPreferencesChanged(); |
5234 } | 5232 } |
5235 | 5233 |
5236 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5234 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5237 JavaScriptDialogManager* dialog_manager) { | 5235 JavaScriptDialogManager* dialog_manager) { |
5238 dialog_manager_ = dialog_manager; | 5236 dialog_manager_ = dialog_manager; |
5239 } | 5237 } |
5240 | 5238 |
5241 } // namespace content | 5239 } // namespace content |
OLD | NEW |