summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/jsmessage_box_dialog.cc
diff options
context:
space:
mode:
authorpam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 04:08:54 +0000
committerpam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 04:08:54 +0000
commitbeb440cea06ba40683a755d14dd5dbf9d11baadf (patch)
tree79b805ed76621b38c5682033a3fbab9dc0a6f8a8 /chrome/browser/views/jsmessage_box_dialog.cc
parentda3b971ec3cababd149b5cd6a7a9d021bfdd96b4 (diff)
downloadchromium_src-beb440cea06ba40683a755d14dd5dbf9d11baadf.zip
chromium_src-beb440cea06ba40683a755d14dd5dbf9d11baadf.tar.gz
chromium_src-beb440cea06ba40683a755d14dd5dbf9d11baadf.tar.bz2
Implement window.alert() and its cousins for extensions.
Second try, now with fixed observer. 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/373006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/jsmessage_box_dialog.cc')
-rw-r--r--chrome/browser/views/jsmessage_box_dialog.cc16
1 files changed, 10 insertions, 6 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() {