diff options
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. |