| 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 4120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4131 IPC::Message* reply_msg) { | 4131 IPC::Message* reply_msg) { |
| 4132 // Suppress JavaScript dialogs when requested. Also suppress messages when | 4132 // Suppress JavaScript dialogs when requested. Also suppress messages when |
| 4133 // showing an interstitial as it's shown over the previous page and we don't | 4133 // showing an interstitial as it's shown over the previous page and we don't |
| 4134 // want the hidden page's dialogs to interfere with the interstitial. | 4134 // want the hidden page's dialogs to interfere with the interstitial. |
| 4135 bool suppress_this_message = | 4135 bool suppress_this_message = |
| 4136 ShowingInterstitialPage() || !delegate_ || | 4136 ShowingInterstitialPage() || !delegate_ || |
| 4137 delegate_->ShouldSuppressDialogs(this) || | 4137 delegate_->ShouldSuppressDialogs(this) || |
| 4138 !delegate_->GetJavaScriptDialogManager(this); | 4138 !delegate_->GetJavaScriptDialogManager(this); |
| 4139 | 4139 |
| 4140 if (!suppress_this_message) { | 4140 if (!suppress_this_message) { |
| 4141 is_showing_javascript_dialog_ = true; |
| 4141 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4142 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
| 4142 dialog_manager_->RunJavaScriptDialog( | 4143 dialog_manager_->RunJavaScriptDialog( |
| 4143 this, frame_url, javascript_message_type, message, default_prompt, | 4144 this, frame_url, javascript_message_type, message, default_prompt, |
| 4144 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4145 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
| 4145 render_frame_host->GetProcess()->GetID(), | 4146 render_frame_host->GetProcess()->GetID(), |
| 4146 render_frame_host->GetRoutingID(), reply_msg, false), | 4147 render_frame_host->GetRoutingID(), reply_msg, false), |
| 4147 &suppress_this_message); | 4148 &suppress_this_message); |
| 4148 } | 4149 } |
| 4149 | 4150 |
| 4150 if (suppress_this_message) { | 4151 if (suppress_this_message) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4181 is_showing_before_unload_dialog_ = true; | 4182 is_showing_before_unload_dialog_ = true; |
| 4182 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4183 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
| 4183 dialog_manager_->RunBeforeUnloadDialog( | 4184 dialog_manager_->RunBeforeUnloadDialog( |
| 4184 this, is_reload, | 4185 this, is_reload, |
| 4185 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4186 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
| 4186 render_frame_host->GetProcess()->GetID(), | 4187 render_frame_host->GetProcess()->GetID(), |
| 4187 render_frame_host->GetRoutingID(), reply_msg, | 4188 render_frame_host->GetRoutingID(), reply_msg, |
| 4188 false)); | 4189 false)); |
| 4189 } | 4190 } |
| 4190 | 4191 |
| 4192 bool WebContentsImpl::IsJavaScriptDialogShowing() const { |
| 4193 return is_showing_javascript_dialog_; |
| 4194 } |
| 4195 |
| 4191 void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host, | 4196 void WebContentsImpl::RunFileChooser(RenderFrameHost* render_frame_host, |
| 4192 const FileChooserParams& params) { | 4197 const FileChooserParams& params) { |
| 4193 if (delegate_) | 4198 if (delegate_) |
| 4194 delegate_->RunFileChooser(render_frame_host, params); | 4199 delegate_->RunFileChooser(render_frame_host, params); |
| 4195 } | 4200 } |
| 4196 | 4201 |
| 4197 WebContents* WebContentsImpl::GetAsWebContents() { | 4202 WebContents* WebContentsImpl::GetAsWebContents() { |
| 4198 return this; | 4203 return this; |
| 4199 } | 4204 } |
| 4200 | 4205 |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5056 // meantime. Do not reset the navigation state in that case. | 5061 // meantime. Do not reset the navigation state in that case. |
| 5057 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { | 5062 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { |
| 5058 rfh->frame_tree_node()->BeforeUnloadCanceled(); | 5063 rfh->frame_tree_node()->BeforeUnloadCanceled(); |
| 5059 controller_.DiscardNonCommittedEntries(); | 5064 controller_.DiscardNonCommittedEntries(); |
| 5060 } | 5065 } |
| 5061 | 5066 |
| 5062 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 5067 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 5063 BeforeUnloadDialogCancelled()); | 5068 BeforeUnloadDialogCancelled()); |
| 5064 } | 5069 } |
| 5065 | 5070 |
| 5071 is_showing_javascript_dialog_ = false; |
| 5066 is_showing_before_unload_dialog_ = false; | 5072 is_showing_before_unload_dialog_ = false; |
| 5067 if (rfh) { | 5073 if (rfh) { |
| 5068 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, | 5074 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, |
| 5069 dialog_was_suppressed); | 5075 dialog_was_suppressed); |
| 5070 } else { | 5076 } else { |
| 5071 // Don't leak the sync IPC reply if the RFH or process is gone. | 5077 // Don't leak the sync IPC reply if the RFH or process is gone. |
| 5072 delete reply_msg; | 5078 delete reply_msg; |
| 5073 } | 5079 } |
| 5074 } | 5080 } |
| 5075 | 5081 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5272 dialog_manager_ = dialog_manager; | 5278 dialog_manager_ = dialog_manager; |
| 5273 } | 5279 } |
| 5274 | 5280 |
| 5275 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5281 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
| 5276 auto it = binding_sets_.find(interface_name); | 5282 auto it = binding_sets_.find(interface_name); |
| 5277 if (it != binding_sets_.end()) | 5283 if (it != binding_sets_.end()) |
| 5278 binding_sets_.erase(it); | 5284 binding_sets_.erase(it); |
| 5279 } | 5285 } |
| 5280 | 5286 |
| 5281 } // namespace content | 5287 } // namespace content |
| OLD | NEW |