diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 02:09:49 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 02:09:49 +0000 |
commit | 9d6c803bf6b2c0f750f5113ff48de7f0c90647ee (patch) | |
tree | 70999a51fe0a70845cbdefb493e3073b3e95e16f /ui/views | |
parent | 854bfc1371e7eb0eb1a3d686504a27e7d0a8e557 (diff) | |
download | chromium_src-9d6c803bf6b2c0f750f5113ff48de7f0c90647ee.zip chromium_src-9d6c803bf6b2c0f750f5113ff48de7f0c90647ee.tar.gz chromium_src-9d6c803bf6b2c0f750f5113ff48de7f0c90647ee.tar.bz2 |
Fix the issue introduced by hooking window.onbeforeunload in WebDialogView which breaks the way WebDialogUI closing the dialog via "DialogClose" message from js. This is broken by my svn landed yesterday.
https://src.chromium.org/viewvc/chrome?view=rev&revision=179427
Since we fire window.onbeforeunload event in WebDialogView, which makes dialog closing async now, we can't have WebDialogUI calls WebDialogDelegate::OnDialogClosed directly in response to "DialogClose" message. I added a new callback WebDialogDelegate::OnDialogCloseFromWebUI to support this case.
While WebDialogDelegate is still used by WebDialogGtk, I provided a default WebDialogDelegate::OnDialogClosedFromWebUI implementation, which just calls WebDialogDelegate::OnDialogClosedFromWebUI, so that the gtk code flow should still work the same as before.
BUG=172067
Review URL: https://chromiumcodereview.appspot.com/12091075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/controls/webview/web_dialog_view.cc | 12 | ||||
-rw-r--r-- | ui/views/controls/webview/web_dialog_view.h | 9 |
2 files changed, 19 insertions, 2 deletions
diff --git a/ui/views/controls/webview/web_dialog_view.cc b/ui/views/controls/webview/web_dialog_view.cc index b717cbe..94d842e 100644 --- a/ui/views/controls/webview/web_dialog_view.cc +++ b/ui/views/controls/webview/web_dialog_view.cc @@ -49,7 +49,8 @@ WebDialogView::WebDialogView( delegate_(delegate), web_view_(new views::WebView(context)), is_attempting_close_dialog_(false), - before_unload_fired_(false) { + before_unload_fired_(false), + closed_via_webui_(false) { web_view_->set_allow_accelerators(true); AddChildView(web_view_); set_contents_view(web_view_); @@ -225,6 +226,13 @@ void WebDialogView::OnDialogClosed(const std::string& json_retval) { } } +void WebDialogView::OnDialogCloseFromWebUI(const std::string& json_retval) { + closed_via_webui_ = true; + dialog_close_retval_ = json_retval; + if (GetWidget()) + GetWidget()->Close(); +} + void WebDialogView::OnCloseContents(WebContents* source, bool* out_close_dialog) { if (delegate_) @@ -275,7 +283,7 @@ void WebDialogView::CloseContents(WebContents* source) { bool close_dialog = false; OnCloseContents(source, &close_dialog); if (close_dialog) - OnDialogClosed(std::string()); + OnDialogClosed(closed_via_webui_ ? dialog_close_retval_ : std::string()); } content::WebContents* WebDialogView::OpenURLFromTab( diff --git a/ui/views/controls/webview/web_dialog_view.h b/ui/views/controls/webview/web_dialog_view.h index a55717d..df6c8a9 100644 --- a/ui/views/controls/webview/web_dialog_view.h +++ b/ui/views/controls/webview/web_dialog_view.h @@ -86,6 +86,8 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView, content::WebUI* webui, content::RenderViewHost* render_view_host) OVERRIDE; virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; + virtual void OnDialogCloseFromWebUI( + const std::string& json_retval) OVERRIDE; virtual void OnCloseContents(content::WebContents* source, bool* out_close_dialog) OVERRIDE; virtual bool ShouldShowDialogTitle() const OVERRIDE; @@ -140,6 +142,13 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView, // beforeunload event. bool before_unload_fired_; + // Whether the dialog is closed from WebUI in response to a "DialogClose" + // message. + bool closed_via_webui_; + + // A json string returned to WebUI from a "DialogClosed" message. + std::string dialog_close_retval_; + DISALLOW_COPY_AND_ASSIGN(WebDialogView); }; |