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 3860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3871 render_frame_host->GetRoutingID(), reply_msg, | 3871 render_frame_host->GetRoutingID(), reply_msg, |
3872 true, false, base::string16()); | 3872 true, false, base::string16()); |
3873 } | 3873 } |
3874 | 3874 |
3875 // OnDialogClosed (two lines up) may have caused deletion of this object (see | 3875 // OnDialogClosed (two lines up) may have caused deletion of this object (see |
3876 // http://crbug.com/288961 ). The only safe thing to do here is return. | 3876 // http://crbug.com/288961 ). The only safe thing to do here is return. |
3877 } | 3877 } |
3878 | 3878 |
3879 void WebContentsImpl::RunBeforeUnloadConfirm( | 3879 void WebContentsImpl::RunBeforeUnloadConfirm( |
3880 RenderFrameHost* render_frame_host, | 3880 RenderFrameHost* render_frame_host, |
3881 const base::string16& message, | |
3882 bool is_reload, | 3881 bool is_reload, |
3883 IPC::Message* reply_msg) { | 3882 IPC::Message* reply_msg) { |
3884 RenderFrameHostImpl* rfhi = | 3883 RenderFrameHostImpl* rfhi = |
3885 static_cast<RenderFrameHostImpl*>(render_frame_host); | 3884 static_cast<RenderFrameHostImpl*>(render_frame_host); |
3886 if (delegate_) | 3885 if (delegate_) |
3887 delegate_->WillRunBeforeUnloadConfirm(); | 3886 delegate_->WillRunBeforeUnloadConfirm(); |
3888 | 3887 |
3889 bool suppress_this_message = | 3888 bool suppress_this_message = |
3890 rfhi->rfh_state() != RenderFrameHostImpl::STATE_DEFAULT || | 3889 rfhi->rfh_state() != RenderFrameHostImpl::STATE_DEFAULT || |
3891 ShowingInterstitialPage() || !delegate_ || | 3890 ShowingInterstitialPage() || !delegate_ || |
3892 delegate_->ShouldSuppressDialogs(this) || | 3891 delegate_->ShouldSuppressDialogs(this) || |
3893 !delegate_->GetJavaScriptDialogManager(this); | 3892 !delegate_->GetJavaScriptDialogManager(this); |
3894 if (suppress_this_message) { | 3893 if (suppress_this_message) { |
3895 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); | 3894 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); |
3896 return; | 3895 return; |
3897 } | 3896 } |
3898 | 3897 |
3899 is_showing_before_unload_dialog_ = true; | 3898 is_showing_before_unload_dialog_ = true; |
3900 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 3899 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
3901 dialog_manager_->RunBeforeUnloadDialog( | 3900 dialog_manager_->RunBeforeUnloadDialog( |
3902 this, message, is_reload, | 3901 this, is_reload, |
3903 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 3902 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
3904 render_frame_host->GetProcess()->GetID(), | 3903 render_frame_host->GetProcess()->GetID(), |
3905 render_frame_host->GetRoutingID(), reply_msg, | 3904 render_frame_host->GetRoutingID(), reply_msg, |
3906 false)); | 3905 false)); |
3907 } | 3906 } |
3908 | 3907 |
3909 WebContents* WebContentsImpl::GetAsWebContents() { | 3908 WebContents* WebContentsImpl::GetAsWebContents() { |
3910 return this; | 3909 return this; |
3911 } | 3910 } |
3912 | 3911 |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4854 else | 4853 else |
4855 WasHidden(); | 4854 WasHidden(); |
4856 } | 4855 } |
4857 | 4856 |
4858 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4857 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
4859 JavaScriptDialogManager* dialog_manager) { | 4858 JavaScriptDialogManager* dialog_manager) { |
4860 dialog_manager_ = dialog_manager; | 4859 dialog_manager_ = dialog_manager; |
4861 } | 4860 } |
4862 | 4861 |
4863 } // namespace content | 4862 } // namespace content |
OLD | NEW |