| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/views/jsmessage_box_dialog.h" | 5 #include "chrome/browser/views/jsmessage_box_dialog.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "base/keyboard_codes.h" | 9 #include "base/keyboard_codes.h" |
| 10 #include "chrome/browser/app_modal_dialog.h" | 10 #include "chrome/browser/app_modal_dialog.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 if (display_suppress_checkbox) { | 30 if (display_suppress_checkbox) { |
| 31 message_box_view_->SetCheckBoxLabel( | 31 message_box_view_->SetCheckBoxLabel( |
| 32 l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); | 32 l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 JavascriptMessageBoxDialog::~JavascriptMessageBoxDialog() { | 36 JavascriptMessageBoxDialog::~JavascriptMessageBoxDialog() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void JavascriptMessageBoxDialog::ShowModalDialog() { | 39 void JavascriptMessageBoxDialog::ShowModalDialog() { |
| 40 HWND root_hwnd = GetAncestor(tab_contents()->GetNativeView(), | 40 gfx::NativeWindow root_hwnd = client()->GetMessageBoxRootWindow(); |
| 41 GA_ROOT); | 41 // GetMessageBoxRootWindow() will be NULL if there's no selected tab (e.g., |
| 42 dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); | 42 // during shutdown), in which case we simply skip showing this dialog. |
| 43 dialog_->Show(); | 43 if (!root_hwnd) { |
| 44 Cancel(); |
| 45 } else { |
| 46 dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); |
| 47 dialog_->Show(); |
| 48 } |
| 44 } | 49 } |
| 45 | 50 |
| 46 void JavascriptMessageBoxDialog::ActivateModalDialog() { | 51 void JavascriptMessageBoxDialog::ActivateModalDialog() { |
| 47 // Ensure that the dialog is visible and at the top of the z-order. These | 52 // Ensure that the dialog is visible and at the top of the z-order. These |
| 48 // conditions may not be true if the dialog was opened on a different virtual | 53 // conditions may not be true if the dialog was opened on a different virtual |
| 49 // desktop to the one the browser window is on. | 54 // desktop to the one the browser window is on. |
| 50 dialog_->Show(); | 55 dialog_->Show(); |
| 51 dialog_->Activate(); | 56 dialog_->Activate(); |
| 52 } | 57 } |
| 53 | 58 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasOKButton) | 70 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasOKButton) |
| 66 dialog_buttons = MessageBoxFlags::DIALOGBUTTON_OK; | 71 dialog_buttons = MessageBoxFlags::DIALOGBUTTON_OK; |
| 67 | 72 |
| 68 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasCancelButton) | 73 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasCancelButton) |
| 69 dialog_buttons |= MessageBoxFlags::DIALOGBUTTON_CANCEL; | 74 dialog_buttons |= MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 70 | 75 |
| 71 return dialog_buttons; | 76 return dialog_buttons; |
| 72 } | 77 } |
| 73 | 78 |
| 74 std::wstring JavascriptMessageBoxDialog::GetWindowTitle() const { | 79 std::wstring JavascriptMessageBoxDialog::GetWindowTitle() const { |
| 75 return parent_->title();; | 80 return parent_->title(); |
| 76 } | 81 } |
| 77 | 82 |
| 78 | 83 |
| 79 void JavascriptMessageBoxDialog::WindowClosing() { | 84 void JavascriptMessageBoxDialog::WindowClosing() { |
| 80 dialog_ = NULL; | 85 dialog_ = NULL; |
| 81 | |
| 82 } | 86 } |
| 83 | 87 |
| 84 void JavascriptMessageBoxDialog::DeleteDelegate() { | 88 void JavascriptMessageBoxDialog::DeleteDelegate() { |
| 85 delete parent_; | 89 delete parent_; |
| 86 delete this; | 90 delete this; |
| 87 } | 91 } |
| 88 | 92 |
| 89 bool JavascriptMessageBoxDialog::Cancel() { | 93 bool JavascriptMessageBoxDialog::Cancel() { |
| 90 parent_->OnCancel(); | 94 parent_->OnCancel(); |
| 91 return true; | 95 return true; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 119 | 123 |
| 120 views::View* JavascriptMessageBoxDialog::GetContentsView() { | 124 views::View* JavascriptMessageBoxDialog::GetContentsView() { |
| 121 return message_box_view_; | 125 return message_box_view_; |
| 122 } | 126 } |
| 123 | 127 |
| 124 views::View* JavascriptMessageBoxDialog::GetInitiallyFocusedView() { | 128 views::View* JavascriptMessageBoxDialog::GetInitiallyFocusedView() { |
| 125 if (message_box_view_->text_box()) | 129 if (message_box_view_->text_box()) |
| 126 return message_box_view_->text_box(); | 130 return message_box_view_->text_box(); |
| 127 return views::DialogDelegate::GetInitiallyFocusedView(); | 131 return views::DialogDelegate::GetInitiallyFocusedView(); |
| 128 } | 132 } |
| OLD | NEW |