diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 18:22:35 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 18:22:35 +0000 |
commit | e1d0303ebea1caddb079d71b63f39463d3944bad (patch) | |
tree | 9c9c1abb6d608889aa20d14c34036eb99ffe2c58 /chrome/browser/views | |
parent | d6b401bed87fa50d1fc0993c04ee7ee992dd6627 (diff) | |
download | chromium_src-e1d0303ebea1caddb079d71b63f39463d3944bad.zip chromium_src-e1d0303ebea1caddb079d71b63f39463d3944bad.tar.gz chromium_src-e1d0303ebea1caddb079d71b63f39463d3944bad.tar.bz2 |
Implement window.alert() and its cousins for extensions.
BUG=12126
TEST=put a window.prompt() in a background page, a browser action, and a page action.
Make sure it gets the result back correctly. Also make sure it still works when
called from a web page.
Review URL: http://codereview.chromium.org/341089
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/jsmessage_box_dialog.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/jsmessage_box_dialog.h | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/chrome/browser/views/jsmessage_box_dialog.cc b/chrome/browser/views/jsmessage_box_dialog.cc index 3fb70e0..b83242f 100644 --- a/chrome/browser/views/jsmessage_box_dialog.cc +++ b/chrome/browser/views/jsmessage_box_dialog.cc @@ -37,10 +37,15 @@ JavascriptMessageBoxDialog::~JavascriptMessageBoxDialog() { } void JavascriptMessageBoxDialog::ShowModalDialog() { - HWND root_hwnd = GetAncestor(tab_contents()->GetNativeView(), - GA_ROOT); - dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); - dialog_->Show(); + gfx::NativeWindow root_hwnd = client()->GetMessageBoxRootWindow(); + // GetMessageBoxRootWindow() will be NULL if there's no selected tab (e.g., + // during shutdown), in which case we simply skip showing this dialog. + if (!root_hwnd) { + Cancel(); + } else { + dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); + dialog_->Show(); + } } void JavascriptMessageBoxDialog::ActivateModalDialog() { @@ -72,13 +77,12 @@ int JavascriptMessageBoxDialog::GetDialogButtons() const { } std::wstring JavascriptMessageBoxDialog::GetWindowTitle() const { - return parent_->title();; + return parent_->title(); } void JavascriptMessageBoxDialog::WindowClosing() { dialog_ = NULL; - } void JavascriptMessageBoxDialog::DeleteDelegate() { diff --git a/chrome/browser/views/jsmessage_box_dialog.h b/chrome/browser/views/jsmessage_box_dialog.h index f709a50..92a2635 100644 --- a/chrome/browser/views/jsmessage_box_dialog.h +++ b/chrome/browser/views/jsmessage_box_dialog.h @@ -11,7 +11,7 @@ #include "views/window/dialog_delegate.h" class MessageBoxView; -class TabContents; +class JavaScriptMessageBoxClient; namespace views { class Window; } @@ -47,8 +47,8 @@ class JavascriptMessageBoxDialog : public views::DialogDelegate { virtual void OnClose(); private: - TabContents* tab_contents() { - return parent_->tab_contents(); + JavaScriptMessageBoxClient* client() { + return parent_->client(); } // A pointer to the AppModalDialog that owns us. |