summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 22:31:47 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 22:31:47 +0000
commit7f1a907d93ee0f7ac527424a70e245343ce0539a (patch)
treef2676a17b23d23c9c044dd64bde0b6601dc256d1
parent806aeb954d302328cc75bda71331474d8634675b (diff)
downloadchromium_src-7f1a907d93ee0f7ac527424a70e245343ce0539a.zip
chromium_src-7f1a907d93ee0f7ac527424a70e245343ce0539a.tar.gz
chromium_src-7f1a907d93ee0f7ac527424a70e245343ce0539a.tar.bz2
Revert "Refactor DialogDelegate so the DialogButton enum is in cross platform"
This reverts commit r14146. MessageBox is redefined to MessageBoxW by windows. I need to rename the class. Review URL: http://codereview.chromium.org/87064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14147 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc16
-rw-r--r--chrome/browser/download/download_request_dialog_delegate_win.cc6
-rw-r--r--chrome/browser/download/download_request_dialog_delegate_win.h5
-rw-r--r--chrome/browser/login_prompt.cc5
-rw-r--r--chrome/browser/task_manager.cc2
-rw-r--r--chrome/browser/unload_uitest.cc10
-rw-r--r--chrome/browser/views/about_chrome_view.cc24
-rw-r--r--chrome/browser/views/about_chrome_view.h8
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc10
-rw-r--r--chrome/browser/views/bookmark_editor_view.h4
-rw-r--r--chrome/browser/views/bug_report_view.cc9
-rw-r--r--chrome/browser/views/bug_report_view.h2
-rw-r--r--chrome/browser/views/clear_browsing_data.cc13
-rw-r--r--chrome/browser/views/clear_browsing_data.h5
-rw-r--r--chrome/browser/views/edit_keyword_controller.cc9
-rw-r--r--chrome/browser/views/edit_keyword_controller.h3
-rw-r--r--chrome/browser/views/external_protocol_dialog.cc10
-rw-r--r--chrome/browser/views/external_protocol_dialog.h4
-rw-r--r--chrome/browser/views/first_run_customize_view.cc2
-rw-r--r--chrome/browser/views/first_run_view.cc2
-rw-r--r--chrome/browser/views/first_run_view_base.cc5
-rw-r--r--chrome/browser/views/first_run_view_base.h2
-rw-r--r--chrome/browser/views/frame/browser_view.cc8
-rw-r--r--chrome/browser/views/hung_renderer_view.cc8
-rw-r--r--chrome/browser/views/importer_lock_view.cc6
-rw-r--r--chrome/browser/views/importer_lock_view.h3
-rw-r--r--chrome/browser/views/importer_view.cc6
-rw-r--r--chrome/browser/views/importer_view.h3
-rw-r--r--chrome/browser/views/importing_progress_view.cc6
-rw-r--r--chrome/browser/views/importing_progress_view.h2
-rw-r--r--chrome/browser/views/input_window.cc8
-rw-r--r--chrome/browser/views/jsmessage_box_dialog.cc10
-rw-r--r--chrome/browser/views/jsmessage_box_dialog.h3
-rw-r--r--chrome/browser/views/keyword_editor_view.cc2
-rw-r--r--chrome/browser/views/new_profile_dialog.cc8
-rw-r--r--chrome/browser/views/new_profile_dialog.h3
-rw-r--r--chrome/browser/views/options/advanced_page_view.cc9
-rw-r--r--chrome/browser/views/options/cookies_view.h2
-rw-r--r--chrome/browser/views/options/options_window_view.cc2
-rw-r--r--chrome/browser/views/options/passwords_exceptions_window_view.cc2
-rw-r--r--chrome/browser/views/page_info_window.cc2
-rw-r--r--chrome/browser/views/repost_form_warning_view.cc6
-rw-r--r--chrome/browser/views/repost_form_warning_view.h3
-rw-r--r--chrome/browser/views/restart_message_box.cc8
-rw-r--r--chrome/browser/views/restart_message_box.h2
-rw-r--r--chrome/browser/views/select_profile_dialog.cc4
-rw-r--r--chrome/browser/views/select_profile_dialog.h1
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc12
-rw-r--r--chrome/browser/views/shelf_item_dialog.h5
-rw-r--r--chrome/browser/views/uninstall_dialog.cc4
-rw-r--r--chrome/browser/views/uninstall_dialog.h1
-rw-r--r--chrome/browser/views/user_data_dir_dialog.cc11
-rw-r--r--chrome/browser/views/user_data_dir_dialog.h4
-rw-r--r--chrome/common/message_box_flags.h7
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc10
-rw-r--r--chrome/test/automation/automation_proxy.cc14
-rw-r--r--chrome/test/automation/automation_proxy.h14
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc23
-rw-r--r--chrome/views/view_unittest.cc6
-rw-r--r--chrome/views/window/dialog_client_view.cc48
-rw-r--r--chrome/views/window/dialog_delegate.cc16
-rw-r--r--chrome/views/window/dialog_delegate.h35
62 files changed, 260 insertions, 223 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 02a0a9e..8383feb 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -28,7 +28,6 @@
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/message_box_flags.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/platform_util.h"
#include "chrome/common/pref_service.h"
@@ -47,6 +46,7 @@
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/location_bar_view.h"
+#include "chrome/views/window/dialog_delegate.h"
#include "chrome/views/window/window.h"
#endif // defined(OS_WIN)
@@ -1297,6 +1297,9 @@ void AutomationProvider::GetBrowserWindowCount(int* window_count) {
*window_count = static_cast<int>(BrowserList::size());
}
+#if defined(OS_WIN)
+// TODO(port): Move the views::DialogDelegate::DialogButton enum out into a
+// common place then remove the OS_WIN guard.
void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog,
int* dialog_button) {
AppModalDialog* dialog_delegate = AppModalDialogQueue::active_dialog();
@@ -1304,7 +1307,7 @@ void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog,
if (*showing_dialog)
*dialog_button = dialog_delegate->GetDialogButtons();
else
- *dialog_button = MessageBox::DIALOGBUTTON_NONE;
+ *dialog_button = views::DialogDelegate::DIALOGBUTTON_NONE;
}
void AutomationProvider::ClickAppModalDialogButton(int button, bool* success) {
@@ -1313,19 +1316,20 @@ void AutomationProvider::ClickAppModalDialogButton(int button, bool* success) {
AppModalDialog* dialog_delegate = AppModalDialogQueue::active_dialog();
if (dialog_delegate &&
(dialog_delegate->GetDialogButtons() & button) == button) {
- if ((button & MessageBox::DIALOGBUTTON_OK) ==
- MessageBox::DIALOGBUTTON_OK) {
+ if ((button & views::DialogDelegate::DIALOGBUTTON_OK) ==
+ views::DialogDelegate::DIALOGBUTTON_OK) {
dialog_delegate->AcceptWindow();
*success = true;
}
- if ((button & MessageBox::DIALOGBUTTON_CANCEL) ==
- MessageBox::DIALOGBUTTON_CANCEL) {
+ if ((button & views::DialogDelegate::DIALOGBUTTON_CANCEL) ==
+ views::DialogDelegate::DIALOGBUTTON_CANCEL) {
DCHECK(!*success) << "invalid param, OK and CANCEL specified";
dialog_delegate->CancelWindow();
*success = true;
}
}
}
+#endif
void AutomationProvider::GetBrowserWindow(int index, int* handle) {
*handle = 0;
diff --git a/chrome/browser/download/download_request_dialog_delegate_win.cc b/chrome/browser/download/download_request_dialog_delegate_win.cc
index 767bfee..3f359ca 100644
--- a/chrome/browser/download/download_request_dialog_delegate_win.cc
+++ b/chrome/browser/download/download_request_dialog_delegate_win.cc
@@ -46,10 +46,10 @@ views::View* DownloadRequestDialogDelegateWin::GetContentsView() {
}
std::wstring DownloadRequestDialogDelegateWin::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_MULTI_DOWNLOAD_WARNING_ALLOW);
- if (button == MessageBox::DIALOGBUTTON_CANCEL)
+ if (button == DIALOGBUTTON_CANCEL)
return l10n_util::GetString(IDS_MULTI_DOWNLOAD_WARNING_DENY);
return std::wstring();
}
diff --git a/chrome/browser/download/download_request_dialog_delegate_win.h b/chrome/browser/download/download_request_dialog_delegate_win.h
index df3dd01..7e5f83f 100644
--- a/chrome/browser/download/download_request_dialog_delegate_win.h
+++ b/chrome/browser/download/download_request_dialog_delegate_win.h
@@ -32,10 +32,9 @@ class DownloadRequestDialogDelegateWin : public DownloadRequestDialogDelegate,
virtual bool Cancel();
virtual bool Accept();
virtual views::View* GetContentsView();
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual int GetDefaultDialogButton() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
virtual void DeleteDelegate();
diff --git a/chrome/browser/login_prompt.cc b/chrome/browser/login_prompt.cc
index f60a2b6..c7b30c9 100644
--- a/chrome/browser/login_prompt.cc
+++ b/chrome/browser/login_prompt.cc
@@ -128,9 +128,8 @@ class LoginHandlerImpl : public LoginHandler,
}
// views::DialogDelegate methods:
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL);
return DialogDelegate::GetDialogButtonLabel(button);
}
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 2535d56..c0f189b 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -1079,7 +1079,7 @@ std::wstring TaskManager::GetWindowName() const {
}
int TaskManager::GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_NONE;
+ return DIALOGBUTTON_NONE;
}
void TaskManager::WindowClosing() {
diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc
index 3a692be..a0e5a24 100644
--- a/chrome/browser/unload_uitest.cc
+++ b/chrome/browser/unload_uitest.cc
@@ -136,9 +136,9 @@ class UnloadTest : public UITest {
EXPECT_TRUE(CloseBrowser(browser.get(), &application_closed));
}
- void ClickModalDialogButton(MessageBox::DialogButton button) {
+ void ClickModalDialogButton(views::DialogDelegate::DialogButton button) {
bool modal_dialog_showing = false;
- MessageBox::DialogButton available_buttons;
+ views::DialogDelegate::DialogButton available_buttons;
EXPECT_TRUE(automation()->WaitForAppModalDialog(3000));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&available_buttons));
@@ -221,7 +221,7 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload");
CloseBrowserAsync(browser.get());
- ClickModalDialogButton(MessageBox::DIALOGBUTTON_OK);
+ ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK);
WaitForBrowserClosed();
EXPECT_FALSE(IsBrowserRunning());
}
@@ -233,12 +233,12 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload");
CloseBrowserAsync(browser.get());
- ClickModalDialogButton(MessageBox::DIALOGBUTTON_CANCEL);
+ ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_CANCEL);
WaitForBrowserClosed();
EXPECT_TRUE(IsBrowserRunning());
CloseBrowserAsync(browser.get());
- ClickModalDialogButton(MessageBox::DIALOGBUTTON_OK);
+ ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK);
WaitForBrowserClosed();
EXPECT_FALSE(IsBrowserRunning());
}
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index 88bf4d9..df605ab 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -603,11 +603,15 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add,
////////////////////////////////////////////////////////////////////////////////
// AboutChromeView, views::DialogDelegate implementation:
+int AboutChromeView::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
std::wstring AboutChromeView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
return l10n_util::GetString(IDS_ABOUT_CHROME_UPDATE_CHECK);
- } else if (button == MessageBox::DIALOGBUTTON_CANCEL) {
+ } else if (button == DIALOGBUTTON_CANCEL) {
// The OK button (which is the default button) has been re-purposed to be
// 'Check for Updates' so we want the Cancel button should have the label
// OK but act like a Cancel button in all other ways.
@@ -618,22 +622,16 @@ std::wstring AboutChromeView::GetDialogButtonLabel(
return L"";
}
-bool AboutChromeView::IsDialogButtonEnabled(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK &&
- check_button_status_ != CHECKBUTTON_ENABLED) {
+bool AboutChromeView::IsDialogButtonEnabled(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK && check_button_status_ != CHECKBUTTON_ENABLED)
return false;
- }
return true;
}
-bool AboutChromeView::IsDialogButtonVisible(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK &&
- check_button_status_ == CHECKBUTTON_HIDDEN) {
+bool AboutChromeView::IsDialogButtonVisible(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK && check_button_status_ == CHECKBUTTON_HIDDEN)
return false;
- }
return true;
}
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index 44bdeacd..2118e76 100644
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -47,10 +47,10 @@ class AboutChromeView : public views::View,
views::View* child);
// Overridden from views::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
- virtual bool IsDialogButtonVisible(MessageBox::DialogButton button) const;
+ virtual int GetDialogButtons() const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
+ virtual bool IsDialogButtonVisible(DialogButton button) const;
virtual bool CanResize() const;
virtual bool CanMaximize() const;
virtual bool IsAlwaysOnTop() const;
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index b2d8c79..b5a2f6d 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -80,9 +80,8 @@ void BookmarkEditorView::Show(HWND parent_hwnd,
editor->Show(parent_hwnd);
}
-bool BookmarkEditorView::IsDialogButtonEnabled(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+bool BookmarkEditorView::IsDialogButtonEnabled(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
const GURL url(GetInputURL());
return bb_model_->IsLoaded() && url.is_valid();
}
@@ -97,7 +96,7 @@ std::wstring BookmarkEditorView::GetWindowTitle() const {
}
bool BookmarkEditorView::Accept() {
- if (!IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK)) {
+ if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) {
// The url is invalid, focus the url field.
url_tf_.SelectAll();
url_tf_.RequestFocus();
@@ -108,8 +107,7 @@ bool BookmarkEditorView::Accept() {
return true;
}
-bool BookmarkEditorView::AreAcceleratorsEnabled(
- MessageBox::DialogButton button) {
+bool BookmarkEditorView::AreAcceleratorsEnabled(DialogButton button) {
return !show_tree_ || !tree_view_->GetEditingNode();
}
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 6b24aa4..a307277 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -86,11 +86,11 @@ class BookmarkEditorView : public views::View,
Handler* handler);
// DialogDelegate methods:
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual bool IsModal() const;
virtual std::wstring GetWindowTitle() const;
virtual bool Accept();
- virtual bool AreAcceleratorsEnabled(MessageBox::DialogButton button);
+ virtual bool AreAcceleratorsEnabled(DialogButton button);
virtual views::View* GetContentsView();
// View methods.
diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc
index ae313f2..647dfc1 100644
--- a/chrome/browser/views/bug_report_view.cc
+++ b/chrome/browser/views/bug_report_view.cc
@@ -266,9 +266,8 @@ bool BugReportView::HandleKeystroke(views::TextField* sender,
return false;
}
-std::wstring BugReportView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+std::wstring BugReportView::GetDialogButtonLabel(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
if (problem_type_ == BugReportComboBoxModel::PHISHING_PAGE)
return l10n_util::GetString(IDS_BUGREPORT_SEND_PHISHING_REPORT);
else
@@ -279,7 +278,7 @@ std::wstring BugReportView::GetDialogButtonLabel(
}
int BugReportView::GetDefaultDialogButton() const {
- return MessageBox::DIALOGBUTTON_NONE;
+ return DIALOGBUTTON_NONE;
}
bool BugReportView::CanResize() const {
@@ -307,7 +306,7 @@ std::wstring BugReportView::GetWindowTitle() const {
}
bool BugReportView::Accept() {
- if (IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK)) {
+ if (IsDialogButtonEnabled(DIALOGBUTTON_OK)) {
if (problem_type_ == BugReportComboBoxModel::PHISHING_PAGE)
ReportPhishing();
else
diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h
index 5e8e1f2..22a2c42 100644
--- a/chrome/browser/views/bug_report_view.h
+++ b/chrome/browser/views/bug_report_view.h
@@ -61,7 +61,7 @@ class BugReportView : public views::View,
int new_index);
// Overridden from views::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual int GetDefaultDialogButton() const;
virtual bool CanResize() const;
virtual bool CanMaximize() const;
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc
index d27c5b0..5a0df99 100644
--- a/chrome/browser/views/clear_browsing_data.cc
+++ b/chrome/browser/views/clear_browsing_data.cc
@@ -236,22 +236,21 @@ void ClearBrowsingDataView::ViewHierarchyChanged(bool is_add,
// ClearBrowsingDataView, views::DialogDelegate implementation:
std::wstring ClearBrowsingDataView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
return l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_COMMIT);
- } else if (button == MessageBox::DIALOGBUTTON_CANCEL) {
+ } else if (button == DIALOGBUTTON_CANCEL) {
return l10n_util::GetString(IDS_CLOSE);
} else {
return std::wstring();
}
}
-bool ClearBrowsingDataView::IsDialogButtonEnabled(
- MessageBox::DialogButton button) const {
+bool ClearBrowsingDataView::IsDialogButtonEnabled(DialogButton button) const {
if (delete_in_progress_)
return false;
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ if (button == DIALOGBUTTON_OK) {
return del_history_checkbox_->checked() ||
del_downloads_checkbox_->checked() ||
del_cache_checkbox_->checked() ||
@@ -288,7 +287,7 @@ std::wstring ClearBrowsingDataView::GetWindowTitle() const {
}
bool ClearBrowsingDataView::Accept() {
- if (!IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK)) {
+ if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) {
return false;
}
diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h
index 77b9bd5..18912fc 100644
--- a/chrome/browser/views/clear_browsing_data.h
+++ b/chrome/browser/views/clear_browsing_data.h
@@ -50,9 +50,8 @@ class ClearBrowsingDataView : public views::View,
views::View* child);
// Overridden from views::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual bool CanResize() const;
virtual bool CanMaximize() const;
virtual bool IsAlwaysOnTop() const;
diff --git a/chrome/browser/views/edit_keyword_controller.cc b/chrome/browser/views/edit_keyword_controller.cc
index e0d5ad3..1463777d 100644
--- a/chrome/browser/views/edit_keyword_controller.cc
+++ b/chrome/browser/views/edit_keyword_controller.cc
@@ -77,9 +77,12 @@ std::wstring EditKeywordController::GetWindowTitle() const {
IDS_SEARCH_ENGINES_EDITOR_NEW_WINDOW_TITLE);
}
-bool EditKeywordController::IsDialogButtonEnabled(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+int EditKeywordController::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
+bool EditKeywordController::IsDialogButtonEnabled(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
return (IsKeywordValid() && !title_tf_->GetText().empty() && IsURLValid());
}
return true;
diff --git a/chrome/browser/views/edit_keyword_controller.h b/chrome/browser/views/edit_keyword_controller.h
index b9b846f..00a76fe 100644
--- a/chrome/browser/views/edit_keyword_controller.h
+++ b/chrome/browser/views/edit_keyword_controller.h
@@ -44,7 +44,8 @@ class EditKeywordController : public views::TextField::Controller,
// DialogDelegate overrides.
virtual bool IsModal() const;
virtual std::wstring GetWindowTitle() const;
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
+ virtual int GetDialogButtons() const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual void DeleteDelegate();
virtual bool Cancel();
virtual bool Accept();
diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc
index e80fe99..50cdce3 100644
--- a/chrome/browser/views/external_protocol_dialog.cc
+++ b/chrome/browser/views/external_protocol_dialog.cc
@@ -43,13 +43,17 @@ ExternalProtocolDialog::~ExternalProtocolDialog() {
//////////////////////////////////////////////////////////////////////////////
// ExternalProtocolDialog, views::DialogDelegate implementation:
+int ExternalProtocolDialog::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
int ExternalProtocolDialog::GetDefaultDialogButton() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
std::wstring ExternalProtocolDialog::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT);
// Set the button to have a default name.
diff --git a/chrome/browser/views/external_protocol_dialog.h b/chrome/browser/views/external_protocol_dialog.h
index 5c0c6a7..3936556 100644
--- a/chrome/browser/views/external_protocol_dialog.h
+++ b/chrome/browser/views/external_protocol_dialog.h
@@ -35,9 +35,9 @@ class ExternalProtocolDialog : public views::DialogDelegate {
virtual ~ExternalProtocolDialog();
// views::DialogDelegate Methods:
+ virtual int GetDialogButtons() const;
virtual int GetDefaultDialogButton() const;
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual std::wstring GetWindowTitle() const;
virtual void DeleteDelegate();
virtual bool Accept();
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
index 8495cc9..1d0b469 100644
--- a/chrome/browser/views/first_run_customize_view.cc
+++ b/chrome/browser/views/first_run_customize_view.cc
@@ -178,7 +178,7 @@ views::View* FirstRunCustomizeView::GetContentsView() {
}
bool FirstRunCustomizeView::Accept() {
- if (!IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK))
+ if (!IsDialogButtonEnabled(DIALOGBUTTON_OK))
return false;
DisableButtons();
diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc
index fb988d1..24f5e11 100644
--- a/chrome/browser/views/first_run_view.cc
+++ b/chrome/browser/views/first_run_view.cc
@@ -171,7 +171,7 @@ views::View* FirstRunView::GetContentsView() {
}
bool FirstRunView::Accept() {
- if (!IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK))
+ if (!IsDialogButtonEnabled(DIALOGBUTTON_OK))
return false;
DisableButtons();
diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc
index 2115d65..c3df0e2 100644
--- a/chrome/browser/views/first_run_view_base.cc
+++ b/chrome/browser/views/first_run_view_base.cc
@@ -151,9 +151,8 @@ bool FirstRunViewBase::HasAlwaysOnTopMenu() const {
return false;
}
-std::wstring FirstRunViewBase::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (MessageBox::DIALOGBUTTON_OK == button)
+std::wstring FirstRunViewBase::GetDialogButtonLabel(DialogButton button) const {
+ if (DIALOGBUTTON_OK == button)
return l10n_util::GetString(IDS_FIRSTRUN_DLG_OK);
// The other buttons get the default text.
return std::wstring();
diff --git a/chrome/browser/views/first_run_view_base.h b/chrome/browser/views/first_run_view_base.h
index 7d16b9b7..d4a08f7 100644
--- a/chrome/browser/views/first_run_view_base.h
+++ b/chrome/browser/views/first_run_view_base.h
@@ -39,7 +39,7 @@ class FirstRunViewBase : public views::View,
virtual bool HasAlwaysOnTopMenu() const;
// Overridden from views::DialogDelegate.
- std::wstring GetDialogButtonLabel(MessageBox::DialogButton button) const;
+ std::wstring GetDialogButtonLabel(DialogButton button) const;
protected:
// Returns the items that the first run process is required to import
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index c9650f3..6cee57d 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -221,14 +221,14 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate,
// DialogDelegate implementation:
virtual int GetDefaultDialogButton() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
- virtual std::wstring GetDialogButtonLabel(MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
- DCHECK_EQ(MessageBox::DIALOGBUTTON_CANCEL, button);
+ DCHECK_EQ(DIALOGBUTTON_CANCEL, button);
return l10n_util::GetString(
IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
}
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index 330c883..9d239e4 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -126,7 +126,7 @@ class HungRendererWarningView : public views::View,
virtual void WindowClosing();
virtual int GetDialogButtons() const;
virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ views::DialogDelegate::DialogButton button) const;
virtual views::View* GetExtraView();
virtual bool Accept(bool window_closing);
virtual views::View* GetContentsView();
@@ -272,12 +272,12 @@ int HungRendererWarningView::GetDialogButtons() const {
// the OK button to wait for responsiveness (and close the dialog) and our
// additional button (which we create) to kill the process (which will result
// in the dialog being destroyed).
- return MessageBox::DIALOGBUTTON_OK;
+ return DIALOGBUTTON_OK;
}
std::wstring HungRendererWarningView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+ views::DialogDelegate::DialogButton button) const {
+ if (button == DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_BROWSER_HANGMONITOR_RENDERER_WAIT);
return std::wstring();
}
diff --git a/chrome/browser/views/importer_lock_view.cc b/chrome/browser/views/importer_lock_view.cc
index 8b4fa99..7c6b809 100644
--- a/chrome/browser/views/importer_lock_view.cc
+++ b/chrome/browser/views/importer_lock_view.cc
@@ -46,10 +46,10 @@ void ImporterLockView::Layout() {
}
std::wstring ImporterLockView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
return l10n_util::GetString(IDS_IMPORTER_LOCK_OK);
- } else if (button == MessageBox::DIALOGBUTTON_CANCEL) {
+ } else if (button == DIALOGBUTTON_CANCEL) {
return l10n_util::GetString(IDS_IMPORTER_LOCK_CANCEL);
}
return std::wstring();
diff --git a/chrome/browser/views/importer_lock_view.h b/chrome/browser/views/importer_lock_view.h
index 1f91cb9..e513bd4 100644
--- a/chrome/browser/views/importer_lock_view.h
+++ b/chrome/browser/views/importer_lock_view.h
@@ -28,8 +28,7 @@ class ImporterLockView : public views::View,
virtual void Layout();
// Overridden from views::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual bool IsModal() const;
virtual std::wstring GetWindowTitle() const;
virtual bool Accept();
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc
index 46f3576..c3dbbf0 100644
--- a/chrome/browser/views/importer_view.cc
+++ b/chrome/browser/views/importer_view.cc
@@ -99,8 +99,8 @@ void ImporterView::Layout() {
}
std::wstring ImporterView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
return l10n_util::GetString(IDS_IMPORT_COMMIT);
} else {
return std::wstring();
@@ -116,7 +116,7 @@ std::wstring ImporterView::GetWindowTitle() const {
}
bool ImporterView::Accept() {
- if (!IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK)) {
+ if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) {
return false;
}
diff --git a/chrome/browser/views/importer_view.h b/chrome/browser/views/importer_view.h
index 422b5f9..9c6e7a8 100644
--- a/chrome/browser/views/importer_view.h
+++ b/chrome/browser/views/importer_view.h
@@ -37,8 +37,7 @@ class ImporterView : public views::View,
virtual void Layout();
// Overridden from views::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual bool IsModal() const;
virtual std::wstring GetWindowTitle() const;
virtual bool Accept();
diff --git a/chrome/browser/views/importing_progress_view.cc b/chrome/browser/views/importing_progress_view.cc
index dc97d8e..d7dcf81 100644
--- a/chrome/browser/views/importing_progress_view.cc
+++ b/chrome/browser/views/importing_progress_view.cc
@@ -182,12 +182,12 @@ void ImportingProgressView::ViewHierarchyChanged(bool is_add,
// ImportingProgressView, views::DialogDelegate implementation:
int ImportingProgressView::GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
std::wstring ImportingProgressView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- DCHECK(button == MessageBox::DIALOGBUTTON_CANCEL);
+ DialogButton button) const {
+ DCHECK(button == DIALOGBUTTON_CANCEL);
return l10n_util::GetString(IDS_IMPORT_PROGRESS_STATUS_CANCEL);
}
diff --git a/chrome/browser/views/importing_progress_view.h b/chrome/browser/views/importing_progress_view.h
index 77ee4a8..3ff77a5 100644
--- a/chrome/browser/views/importing_progress_view.h
+++ b/chrome/browser/views/importing_progress_view.h
@@ -39,7 +39,7 @@ class ImportingProgressView : public views::View,
// Overridden from views::DialogDelegate:
virtual int GetDialogButtons() const;
- virtual std::wstring GetDialogButtonLabel(MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual bool IsModal() const;
virtual std::wstring GetWindowTitle() const;
virtual bool Cancel();
diff --git a/chrome/browser/views/input_window.cc b/chrome/browser/views/input_window.cc
index a038f09..8d8c24f 100644
--- a/chrome/browser/views/input_window.cc
+++ b/chrome/browser/views/input_window.cc
@@ -33,7 +33,7 @@ class ContentView : public views::View,
}
// views::DialogDelegate overrides:
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual bool Accept();
virtual bool Cancel();
virtual void WindowClosing();
@@ -77,11 +77,9 @@ class ContentView : public views::View,
///////////////////////////////////////////////////////////////////////////////
// ContentView, views::DialogDelegate implementation:
-bool ContentView::IsDialogButtonEnabled(MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK &&
- !delegate_->IsValid(text_field_->GetText())) {
+bool ContentView::IsDialogButtonEnabled(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK && !delegate_->IsValid(text_field_->GetText()))
return false;
- }
return true;
}
diff --git a/chrome/browser/views/jsmessage_box_dialog.cc b/chrome/browser/views/jsmessage_box_dialog.cc
index 028d46b..bd0c7f2 100644
--- a/chrome/browser/views/jsmessage_box_dialog.cc
+++ b/chrome/browser/views/jsmessage_box_dialog.cc
@@ -60,10 +60,10 @@ void JavascriptMessageBoxDialog::CloseModalDialog() {
int JavascriptMessageBoxDialog::GetDialogButtons() const {
int dialog_buttons = 0;
if (parent_->dialog_flags() & MessageBox::kFlagHasOKButton)
- dialog_buttons = MessageBox::DIALOGBUTTON_OK;
+ dialog_buttons = DIALOGBUTTON_OK;
if (parent_->dialog_flags() & MessageBox::kFlagHasCancelButton)
- dialog_buttons |= MessageBox::DIALOGBUTTON_CANCEL;
+ dialog_buttons |= DIALOGBUTTON_CANCEL;
return dialog_buttons;
}
@@ -96,11 +96,11 @@ bool JavascriptMessageBoxDialog::Accept() {
}
std::wstring JavascriptMessageBoxDialog::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
+ DialogButton button) const {
if (parent_->is_before_unload_dialog()) {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ if (button == DialogDelegate::DIALOGBUTTON_OK) {
return l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL);
- } else if (button == MessageBox::DIALOGBUTTON_CANCEL) {
+ } else if (button == DialogDelegate::DIALOGBUTTON_CANCEL) {
return l10n_util::GetString(
IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL);
}
diff --git a/chrome/browser/views/jsmessage_box_dialog.h b/chrome/browser/views/jsmessage_box_dialog.h
index 2fac473..7195904 100644
--- a/chrome/browser/views/jsmessage_box_dialog.h
+++ b/chrome/browser/views/jsmessage_box_dialog.h
@@ -37,8 +37,7 @@ class JavascriptMessageBoxDialog : public views::DialogDelegate {
virtual void DeleteDelegate();
virtual bool Cancel();
virtual bool Accept();
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
// views::WindowDelegate Methods:
virtual bool IsModal() const { return true; }
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index 7effbaf..4a4f064 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -444,7 +444,7 @@ std::wstring KeywordEditorView::GetWindowTitle() const {
}
int KeywordEditorView::GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
bool KeywordEditorView::Accept() {
diff --git a/chrome/browser/views/new_profile_dialog.cc b/chrome/browser/views/new_profile_dialog.cc
index 5b4b903..fbb9c8e 100644
--- a/chrome/browser/views/new_profile_dialog.cc
+++ b/chrome/browser/views/new_profile_dialog.cc
@@ -46,6 +46,10 @@ NewProfileDialog::NewProfileDialog() {
NewProfileDialog::~NewProfileDialog() {
}
+int NewProfileDialog::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
views::View* NewProfileDialog::GetInitiallyFocusedView() {
views::TextField* text_box = message_box_view_->text_box();
DCHECK(text_box);
@@ -53,8 +57,8 @@ views::View* NewProfileDialog::GetInitiallyFocusedView() {
}
bool NewProfileDialog::IsDialogButtonEnabled(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK) {
+ DialogButton button) const {
+ if (button == DIALOGBUTTON_OK) {
std::wstring profile_name = message_box_view_->GetInputText();
// TODO(munjal): Refactor the function ReplaceIllegalCharacters in
// file_util to something that just checks if there are illegal chars
diff --git a/chrome/browser/views/new_profile_dialog.h b/chrome/browser/views/new_profile_dialog.h
index d4d25e1..868480e 100644
--- a/chrome/browser/views/new_profile_dialog.h
+++ b/chrome/browser/views/new_profile_dialog.h
@@ -30,8 +30,9 @@ class NewProfileDialog : public views::DialogDelegate,
// views::DialogDelegate methods.
virtual bool Accept();
+ virtual int GetDialogButtons() const;
virtual views::View* GetInitiallyFocusedView();
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual std::wstring GetWindowTitle() const;
virtual void DeleteDelegate();
diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc
index 6a249a9..fcf083b 100644
--- a/chrome/browser/views/options/advanced_page_view.cc
+++ b/chrome/browser/views/options/advanced_page_view.cc
@@ -36,11 +36,14 @@ class ResetDefaultsConfirmBox : public views::DialogDelegate {
protected:
// views::DialogDelegate
- virtual std::wstring GetDialogButtonLabel(MessageBox::DialogButton button) const {
+ virtual int GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+ }
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const {
switch (button) {
- case MessageBox::DIALOGBUTTON_OK:
+ case DIALOGBUTTON_OK:
return l10n_util::GetString(IDS_OPTIONS_RESET_OKLABEL);
- case MessageBox::DIALOGBUTTON_CANCEL:
+ case DIALOGBUTTON_CANCEL:
return l10n_util::GetString(IDS_OPTIONS_RESET_CANCELLABEL);
default:
break;
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index 58d04cb..2baed44 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -55,7 +55,7 @@ class CookiesView : public views::View,
UINT flags);
// views::WindowDelegate implementation:
- virtual int GetDialogButtons() const { return MessageBox::DIALOGBUTTON_CANCEL; }
+ virtual int GetDialogButtons() const { return DIALOGBUTTON_CANCEL; }
virtual views::View* GetInitiallyFocusedView() {
return search_field_;
}
diff --git a/chrome/browser/views/options/options_window_view.cc b/chrome/browser/views/options/options_window_view.cc
index d2b324b..f7f492f 100644
--- a/chrome/browser/views/options/options_window_view.cc
+++ b/chrome/browser/views/options/options_window_view.cc
@@ -42,7 +42,7 @@ class OptionsWindowView : public views::View,
void ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group);
// views::DialogDelegate implementation:
- virtual int GetDialogButtons() const { return MessageBox::DIALOGBUTTON_CANCEL; }
+ virtual int GetDialogButtons() const { return DIALOGBUTTON_CANCEL; }
virtual std::wstring GetWindowTitle() const;
virtual void WindowClosing();
virtual bool Cancel();
diff --git a/chrome/browser/views/options/passwords_exceptions_window_view.cc b/chrome/browser/views/options/passwords_exceptions_window_view.cc
index dbcfbf2..9bf44b4 100644
--- a/chrome/browser/views/options/passwords_exceptions_window_view.cc
+++ b/chrome/browser/views/options/passwords_exceptions_window_view.cc
@@ -65,7 +65,7 @@ void PasswordsExceptionsWindowView::ViewHierarchyChanged(
// PasswordsExceptionsWindowView, views::DisloagDelegate implementations
int PasswordsExceptionsWindowView::GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
std::wstring PasswordsExceptionsWindowView::GetWindowTitle() const {
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index f1e2f31..ecc3ef8 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -597,7 +597,7 @@ void PageInfoWindow::Show() {
}
int PageInfoWindow::GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_CANCEL;
}
std::wstring PageInfoWindow::GetWindowTitle() const {
diff --git a/chrome/browser/views/repost_form_warning_view.cc b/chrome/browser/views/repost_form_warning_view.cc
index ca71237..b8e9153 100644
--- a/chrome/browser/views/repost_form_warning_view.cc
+++ b/chrome/browser/views/repost_form_warning_view.cc
@@ -57,10 +57,10 @@ std::wstring RepostFormWarningView::GetWindowTitle() const {
}
std::wstring RepostFormWarningView::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+ DialogButton button) const {
+ if (button == DialogDelegate::DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_HTTP_POST_WARNING_RESEND);
- if (button == MessageBox::DIALOGBUTTON_CANCEL)
+ if (button == DialogDelegate::DIALOGBUTTON_CANCEL)
return l10n_util::GetString(IDS_HTTP_POST_WARNING_CANCEL);
return L"";
}
diff --git a/chrome/browser/views/repost_form_warning_view.h b/chrome/browser/views/repost_form_warning_view.h
index 092b02b..a653922 100644
--- a/chrome/browser/views/repost_form_warning_view.h
+++ b/chrome/browser/views/repost_form_warning_view.h
@@ -23,8 +23,7 @@ class RepostFormWarningView : public views::DialogDelegate,
// views::DialogDelegate Methods:
virtual std::wstring GetWindowTitle() const;
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual void DeleteDelegate();
virtual bool Cancel();
virtual bool Accept();
diff --git a/chrome/browser/views/restart_message_box.cc b/chrome/browser/views/restart_message_box.cc
index f052ab1..e61e23f 100644
--- a/chrome/browser/views/restart_message_box.cc
+++ b/chrome/browser/views/restart_message_box.cc
@@ -21,12 +21,12 @@ void RestartMessageBox::ShowMessageBox(HWND parent_hwnd) {
}
int RestartMessageBox::GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_OK;
+ return DialogDelegate::DIALOGBUTTON_OK;
}
-std::wstring RestartMessageBox::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- DCHECK(button == MessageBox::DIALOGBUTTON_OK);
+std::wstring RestartMessageBox::GetDialogButtonLabel(DialogButton button)
+ const {
+ DCHECK(button == DIALOGBUTTON_OK);
return l10n_util::GetString(IDS_OK);
}
diff --git a/chrome/browser/views/restart_message_box.h b/chrome/browser/views/restart_message_box.h
index 6c9c12b..893bf43 100644
--- a/chrome/browser/views/restart_message_box.h
+++ b/chrome/browser/views/restart_message_box.h
@@ -20,7 +20,7 @@ class RestartMessageBox : public views::DialogDelegate {
protected:
// views::DialogDelegate:
virtual int GetDialogButtons() const;
- virtual std::wstring GetDialogButtonLabel(MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual std::wstring GetWindowTitle() const;
// views::WindowDelegate:
diff --git a/chrome/browser/views/select_profile_dialog.cc b/chrome/browser/views/select_profile_dialog.cc
index 3a5c6d2..b10c262 100644
--- a/chrome/browser/views/select_profile_dialog.cc
+++ b/chrome/browser/views/select_profile_dialog.cc
@@ -66,6 +66,10 @@ void SelectProfileDialog::Layout() {
GetLayoutManager()->Layout(this);
}
+int SelectProfileDialog::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
views::View* SelectProfileDialog::GetInitiallyFocusedView() {
return profile_combobox_;
}
diff --git a/chrome/browser/views/select_profile_dialog.h b/chrome/browser/views/select_profile_dialog.h
index 723efb2..a761623 100644
--- a/chrome/browser/views/select_profile_dialog.h
+++ b/chrome/browser/views/select_profile_dialog.h
@@ -50,6 +50,7 @@ class SelectProfileDialog
virtual bool Accept();
virtual bool Cancel();
virtual views::View* GetContentsView();
+ virtual int GetDialogButtons() const;
virtual views::View* GetInitiallyFocusedView();
virtual std::wstring GetWindowTitle() const;
virtual bool IsModal() const { return false; }
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index 32a32f9..68050b1 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -375,9 +375,8 @@ bool ShelfItemDialog::IsModal() const {
return true;
}
-std::wstring ShelfItemDialog::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+std::wstring ShelfItemDialog::GetDialogButtonLabel(DialogButton button) const {
+ if (button == DialogDelegate::DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_ASI_ADD);
return std::wstring();
}
@@ -427,7 +426,7 @@ void ShelfItemDialog::ContentsChanged(views::TextField* sender,
}
bool ShelfItemDialog::Accept() {
- if (!IsDialogButtonEnabled(MessageBox::DIALOGBUTTON_OK)) {
+ if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) {
if (!GetInputURL().is_valid())
url_field_->RequestFocus();
else if (title_field_)
@@ -438,9 +437,8 @@ bool ShelfItemDialog::Accept() {
return true;
}
-bool ShelfItemDialog::IsDialogButtonEnabled(
- MessageBox::DialogButton button) const {
- if (button == MessageBox::DIALOGBUTTON_OK)
+bool ShelfItemDialog::IsDialogButtonEnabled(DialogButton button) const {
+ if (button == DIALOGBUTTON_OK)
return GetInputURL().is_valid();
return true;
}
diff --git a/chrome/browser/views/shelf_item_dialog.h b/chrome/browser/views/shelf_item_dialog.h
index 40b2020..9e5520d 100644
--- a/chrome/browser/views/shelf_item_dialog.h
+++ b/chrome/browser/views/shelf_item_dialog.h
@@ -59,10 +59,9 @@ class ShelfItemDialog : public views::View,
// DialogDelegate.
virtual std::wstring GetWindowTitle() const;
virtual bool IsModal() const;
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual bool Accept();
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const;
+ virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual views::View* GetContentsView();
// TextField::Controller.
diff --git a/chrome/browser/views/uninstall_dialog.cc b/chrome/browser/views/uninstall_dialog.cc
index c8faee9..da54ca8 100644
--- a/chrome/browser/views/uninstall_dialog.cc
+++ b/chrome/browser/views/uninstall_dialog.cc
@@ -30,6 +30,10 @@ bool UninstallDialog::Cancel() {
return true;
}
+int UninstallDialog::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
std::wstring UninstallDialog::GetWindowTitle() const {
return l10n_util::GetString(IDS_UNINSTALL_CHROME);
}
diff --git a/chrome/browser/views/uninstall_dialog.h b/chrome/browser/views/uninstall_dialog.h
index bf9a6c9..0874db6 100644
--- a/chrome/browser/views/uninstall_dialog.h
+++ b/chrome/browser/views/uninstall_dialog.h
@@ -20,6 +20,7 @@ class UninstallDialog : public views::DialogDelegate {
// Overridden from views::DialogDelegate:
virtual bool Accept();
virtual bool Cancel();
+ virtual int GetDialogButtons() const;
virtual std::wstring GetWindowTitle() const;
// Overridden from views::WindowDelegate:
diff --git a/chrome/browser/views/user_data_dir_dialog.cc b/chrome/browser/views/user_data_dir_dialog.cc
index e5a2a8c..3598950 100644
--- a/chrome/browser/views/user_data_dir_dialog.cc
+++ b/chrome/browser/views/user_data_dir_dialog.cc
@@ -37,14 +37,19 @@ UserDataDirDialog::~UserDataDirDialog() {
select_file_dialog_->ListenerDestroyed();
}
+int UserDataDirDialog::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+
+}
+
std::wstring UserDataDirDialog::GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
+ DialogButton button) const {
switch (button) {
- case MessageBox::DIALOGBUTTON_OK:
+ case DIALOGBUTTON_OK:
return l10n_util::GetString(
IDS_CANT_WRITE_USER_DIRECTORY_CHOOSE_DIRECTORY_BUTTON);
- case MessageBox::DIALOGBUTTON_CANCEL:
+ case DIALOGBUTTON_CANCEL:
return l10n_util::GetString(IDS_CANT_WRITE_USER_DIRECTORY_EXIT_BUTTON);
default:
NOTREACHED();
diff --git a/chrome/browser/views/user_data_dir_dialog.h b/chrome/browser/views/user_data_dir_dialog.h
index 35ee6d7..78192ce 100644
--- a/chrome/browser/views/user_data_dir_dialog.h
+++ b/chrome/browser/views/user_data_dir_dialog.h
@@ -32,8 +32,8 @@ class UserDataDirDialog : public views::DialogDelegate,
std::wstring user_data_dir() { return user_data_dir_; }
// views::DialogDelegate Methods:
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const;
+ virtual int GetDialogButtons() const;
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual std::wstring GetWindowTitle() const;
virtual void DeleteDelegate();
virtual bool Accept();
diff --git a/chrome/common/message_box_flags.h b/chrome/common/message_box_flags.h
index b2daf38..40047d9 100644
--- a/chrome/common/message_box_flags.h
+++ b/chrome/common/message_box_flags.h
@@ -42,13 +42,6 @@ class MessageBox {
static const int kIsJavascriptPrompt = kIsJavascriptConfirm |
kFlagHasPromptField;
- // Dialog button identifiers used to specify which buttons to show the user.
- enum DialogButton {
- DIALOGBUTTON_NONE = 0, // No dialog buttons, for WindowType == WINDOW.
- DIALOGBUTTON_OK = 1, // Has an OK button.
- DIALOGBUTTON_CANCEL = 2, // Has a Cancel button (becomes a Close button if
- }; // no OK button).
-
private:
MessageBox() {}
DISALLOW_COPY_AND_ASSIGN(MessageBox);
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index 4dcb220..8d2fbff 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -119,6 +119,16 @@ void AutomationProvider::OnMessageFromExternalHost(
NOTIMPLEMENTED();
}
+void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog,
+ int* dialog_button) {
+ NOTIMPLEMENTED();
+}
+
+void AutomationProvider::ClickAppModalDialogButton(int button, bool* success) {
+ *success = false;
+ NOTIMPLEMENTED();
+}
+
//--------------------------------------------------------------------------
bool ShellIntegration::SetAsDefaultBrowser() {
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index fac5001..5715aac 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -318,9 +318,11 @@ bool AutomationProxy::WaitForWindowCountToBecome(int count,
return false;
}
+#if defined(OS_WIN)
+// TODO(port): Port when DialogDelegate is ported.
bool AutomationProxy::GetShowingAppModalDialog(
bool* showing_app_modal_dialog,
- MessageBox::DialogButton* button) {
+ views::DialogDelegate::DialogButton* button) {
if (!showing_app_modal_dialog || !button) {
NOTREACHED();
return false;
@@ -336,12 +338,12 @@ bool AutomationProxy::GetShowingAppModalDialog(
return false;
}
- *button = static_cast<MessageBox::DialogButton>(button_int);
+ *button = static_cast<views::DialogDelegate::DialogButton>(button_int);
return true;
}
bool AutomationProxy::ClickAppModalDialogButton(
- MessageBox::DialogButton button) {
+ views::DialogDelegate::DialogButton button) {
bool succeeded = false;
if (!SendWithTimeout(
@@ -359,7 +361,8 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
while (TimeTicks::Now() - start < timeout) {
bool dialog_shown = false;
- MessageBox::DialogButton button = MessageBox::DIALOGBUTTON_NONE;
+ views::DialogDelegate::DialogButton button =
+ views::DialogDelegate::DIALOGBUTTON_NONE;
bool succeeded = GetShowingAppModalDialog(&dialog_shown, &button);
if (!succeeded) {
// Try again next round, but log it.
@@ -367,11 +370,12 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
} else if (dialog_shown) {
return true;
}
- PlatformThread::Sleep(automation::kSleepTime);
+ Sleep(automation::kSleepTime);
}
// Dialog never shown.
return false;
}
+#endif // defined(OS_WIN)
bool AutomationProxy::WaitForURLDisplayed(GURL url, int wait_timeout) {
const TimeTicks start = TimeTicks::Now();
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index 9b052a8..e9d55d1 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -16,10 +16,14 @@
#include "chrome/common/ipc_channel_proxy.h"
#include "chrome/common/ipc_message.h"
#include "chrome/common/ipc_sync_channel.h"
-#include "chrome/common/message_box_flags.h"
#include "chrome/test/automation/automation_handle_tracker.h"
#include "chrome/test/automation/automation_messages.h"
+#if defined(OS_WIN)
+// TODO(port): Enable this or equivalent.
+#include "chrome/views/window/dialog_delegate.h"
+#endif
+
class AutomationRequest;
class BrowserProxy;
class TabProxy;
@@ -94,13 +98,17 @@ class AutomationProxy : public IPC::Channel::Listener,
// Returns true on success.
bool WaitForWindowCountToBecome(int target_count, int wait_timeout);
+#if defined(OS_WIN)
+ // TODO(port): Enable when we have portable DialogDelegate.
+
// Returns whether an app modal dialog window is showing right now (i.e., a
// javascript alert), and what buttons it contains.
bool GetShowingAppModalDialog(bool* showing_app_modal_dialog,
- MessageBox::DialogButton* button);
+ views::DialogDelegate::DialogButton* button);
// Simulates a click on a dialog button.
- bool ClickAppModalDialogButton(MessageBox::DialogButton button);
+ bool ClickAppModalDialogButton(views::DialogDelegate::DialogButton button);
+#endif // defined(OS_WIN)
// Block the thread until a modal dialog is displayed. Returns true on
// success.
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index bd5495a..464fa81 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -1005,11 +1005,12 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
ASSERT_TRUE(tab.get());
bool modal_dialog_showing = false;
- MessageBox::DialogButton button = MessageBox::DIALOGBUTTON_NONE;
+ views::DialogDelegate::DialogButton button =
+ views::DialogDelegate::DIALOGBUTTON_NONE;
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
- EXPECT_EQ(MessageBox::DIALOGBUTTON_NONE, button);
+ EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_NONE, button);
// Show a simple alert.
std::string content =
@@ -1021,19 +1022,19 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
- EXPECT_EQ(MessageBox::DIALOGBUTTON_OK, button);
+ EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_OK, button);
// Test that clicking missing button fails graciously and does not close the
// dialog.
EXPECT_FALSE(automation()->ClickAppModalDialogButton(
- MessageBox::DIALOGBUTTON_CANCEL));
+ views::DialogDelegate::DIALOGBUTTON_CANCEL));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
// Now click OK, that should close the dialog.
EXPECT_TRUE(automation()->ClickAppModalDialogButton(
- MessageBox::DIALOGBUTTON_OK));
+ views::DialogDelegate::DIALOGBUTTON_OK));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
@@ -1048,12 +1049,12 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
- EXPECT_EQ(MessageBox::DIALOGBUTTON_OK |
- MessageBox::DIALOGBUTTON_CANCEL, button);
+ EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_OK |
+ views::DialogDelegate::DIALOGBUTTON_CANCEL, button);
// Click OK.
EXPECT_TRUE(automation()->ClickAppModalDialogButton(
- MessageBox::DIALOGBUTTON_OK));
+ views::DialogDelegate::DIALOGBUTTON_OK));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
@@ -1068,12 +1069,12 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
- EXPECT_EQ(MessageBox::DIALOGBUTTON_OK |
- MessageBox::DIALOGBUTTON_CANCEL, button);
+ EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_OK |
+ views::DialogDelegate::DIALOGBUTTON_CANCEL, button);
// Click Cancel this time.
EXPECT_TRUE(automation()->ClickAppModalDialogButton(
- MessageBox::DIALOGBUTTON_CANCEL));
+ views::DialogDelegate::DIALOGBUTTON_CANCEL));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index 432a47b..9fbf481 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -843,8 +843,12 @@ class TestDialogView : public views::View,
}
// views::DialogDelegate implementation:
+ virtual int GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+ }
+
virtual int GetDefaultDialogButton() const {
- return MessageBox::DIALOGBUTTON_OK;
+ return DIALOGBUTTON_OK;
}
virtual View* GetContentsView() {
diff --git a/chrome/views/window/dialog_client_view.cc b/chrome/views/window/dialog_client_view.cc
index 0a8294f..542439d 100644
--- a/chrome/views/window/dialog_client_view.cc
+++ b/chrome/views/window/dialog_client_view.cc
@@ -27,7 +27,7 @@ namespace {
// Updates any of the standard buttons according to the delegate.
void UpdateButtonHelper(NativeButton* button_view,
DialogDelegate* delegate,
- MessageBox::DialogButton button) {
+ DialogDelegate::DialogButton button) {
std::wstring label = delegate->GetDialogButtonLabel(button);
if (!label.empty())
button_view->SetLabel(label);
@@ -50,7 +50,7 @@ class DialogButton : public NativeButton {
public:
DialogButton(ButtonListener* listener,
Window* owner,
- MessageBox::DialogButton type,
+ DialogDelegate::DialogButton type,
const std::wstring& title,
bool is_default)
: NativeButton(listener, title),
@@ -70,7 +70,7 @@ class DialogButton : public NativeButton {
private:
Window* owner_;
- const MessageBox::DialogButton type_;
+ const DialogDelegate::DialogButton type_;
DISALLOW_COPY_AND_ASSIGN(DialogButton);
};
@@ -106,38 +106,38 @@ DialogClientView::~DialogClientView() {
void DialogClientView::ShowDialogButtons() {
DialogDelegate* dd = GetDialogDelegate();
int buttons = dd->GetDialogButtons();
- if (buttons & MessageBox::DIALOGBUTTON_OK && !ok_button_) {
+ if (buttons & DialogDelegate::DIALOGBUTTON_OK && !ok_button_) {
std::wstring label =
- dd->GetDialogButtonLabel(MessageBox::DIALOGBUTTON_OK);
+ dd->GetDialogButtonLabel(DialogDelegate::DIALOGBUTTON_OK);
if (label.empty())
label = l10n_util::GetString(IDS_OK);
bool is_default_button =
- (dd->GetDefaultDialogButton() & MessageBox::DIALOGBUTTON_OK) != 0;
+ (dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_OK) != 0;
ok_button_ = new DialogButton(this, window(),
- MessageBox::DIALOGBUTTON_OK, label,
+ DialogDelegate::DIALOGBUTTON_OK, label,
is_default_button);
ok_button_->SetGroup(kButtonGroup);
if (is_default_button)
default_button_ = ok_button_;
- if (!(buttons & MessageBox::DIALOGBUTTON_CANCEL))
+ if (!(buttons & DialogDelegate::DIALOGBUTTON_CANCEL))
ok_button_->AddAccelerator(Accelerator(VK_ESCAPE, false, false, false));
AddChildView(ok_button_);
}
- if (buttons & MessageBox::DIALOGBUTTON_CANCEL && !cancel_button_) {
+ if (buttons & DialogDelegate::DIALOGBUTTON_CANCEL && !cancel_button_) {
std::wstring label =
- dd->GetDialogButtonLabel(MessageBox::DIALOGBUTTON_CANCEL);
+ dd->GetDialogButtonLabel(DialogDelegate::DIALOGBUTTON_CANCEL);
if (label.empty()) {
- if (buttons & MessageBox::DIALOGBUTTON_OK) {
+ if (buttons & DialogDelegate::DIALOGBUTTON_OK) {
label = l10n_util::GetString(IDS_CANCEL);
} else {
label = l10n_util::GetString(IDS_CLOSE);
}
}
bool is_default_button =
- (dd->GetDefaultDialogButton() & MessageBox::DIALOGBUTTON_CANCEL)
+ (dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_CANCEL)
!= 0;
cancel_button_ = new DialogButton(this, window(),
- MessageBox::DIALOGBUTTON_CANCEL,
+ DialogDelegate::DIALOGBUTTON_CANCEL,
label, is_default_button);
cancel_button_->SetGroup(kButtonGroup);
cancel_button_->AddAccelerator(Accelerator(VK_ESCAPE, false, false, false));
@@ -174,9 +174,9 @@ void DialogClientView::FocusWillChange(View* focused_before,
// The focused view is not a button, get the default button from the
// delegate.
DialogDelegate* dd = GetDialogDelegate();
- if ((dd->GetDefaultDialogButton() & MessageBox::DIALOGBUTTON_OK) != 0)
+ if ((dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_OK) != 0)
new_default_button = ok_button_;
- if ((dd->GetDefaultDialogButton() & MessageBox::DIALOGBUTTON_CANCEL)
+ if ((dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_CANCEL)
!= 0)
new_default_button = cancel_button_;
}
@@ -188,11 +188,11 @@ void DialogClientView::UpdateDialogButtons() {
DialogDelegate* dd = GetDialogDelegate();
int buttons = dd->GetDialogButtons();
- if (buttons & MessageBox::DIALOGBUTTON_OK)
- UpdateButtonHelper(ok_button_, dd, MessageBox::DIALOGBUTTON_OK);
+ if (buttons & DialogDelegate::DIALOGBUTTON_OK)
+ UpdateButtonHelper(ok_button_, dd, DialogDelegate::DIALOGBUTTON_OK);
- if (buttons & MessageBox::DIALOGBUTTON_CANCEL)
- UpdateButtonHelper(cancel_button_, dd, MessageBox::DIALOGBUTTON_CANCEL);
+ if (buttons & DialogDelegate::DIALOGBUTTON_CANCEL)
+ UpdateButtonHelper(cancel_button_, dd, DialogDelegate::DIALOGBUTTON_CANCEL);
LayoutDialogButtons();
SchedulePaint();
@@ -224,9 +224,9 @@ bool DialogClientView::CanClose() const {
if (!accepted_) {
DialogDelegate* dd = GetDialogDelegate();
int buttons = dd->GetDialogButtons();
- if (buttons & MessageBox::DIALOGBUTTON_CANCEL)
+ if (buttons & DialogDelegate::DIALOGBUTTON_CANCEL)
return dd->Cancel();
- if (buttons & MessageBox::DIALOGBUTTON_OK)
+ if (buttons & DialogDelegate::DIALOGBUTTON_OK)
return dd->Accept(true);
}
return true;
@@ -352,7 +352,7 @@ void DialogClientView::PaintSizeBox(ChromeCanvas* canvas) {
int DialogClientView::GetButtonWidth(int button) const {
DialogDelegate* dd = GetDialogDelegate();
std::wstring button_label = dd->GetDialogButtonLabel(
- static_cast<MessageBox::DialogButton>(button));
+ static_cast<DialogDelegate::DialogButton>(button));
int string_width = dialog_button_font_->GetStringWidth(button_label);
return std::max(string_width + kDialogButtonLabelSpacing,
kDialogMinButtonWidth);
@@ -372,7 +372,7 @@ void DialogClientView::LayoutDialogButtons() {
if (cancel_button_) {
gfx::Size ps = cancel_button_->GetPreferredSize();
gfx::Rect lb = GetLocalBounds(false);
- int button_width = GetButtonWidth(MessageBox::DIALOGBUTTON_CANCEL);
+ int button_width = GetButtonWidth(DialogDelegate::DIALOGBUTTON_CANCEL);
int button_x = lb.right() - button_width - kButtonHEdgeMargin;
int button_y = lb.bottom() - ps.height() - kButtonVEdgeMargin;
cancel_button_->SetBounds(button_x, button_y, button_width, ps.height());
@@ -383,7 +383,7 @@ void DialogClientView::LayoutDialogButtons() {
if (ok_button_) {
gfx::Size ps = ok_button_->GetPreferredSize();
gfx::Rect lb = GetLocalBounds(false);
- int button_width = GetButtonWidth(MessageBox::DIALOGBUTTON_OK);
+ int button_width = GetButtonWidth(DialogDelegate::DIALOGBUTTON_OK);
int ok_button_right = lb.right() - kButtonHEdgeMargin;
if (cancel_button_)
ok_button_right = cancel_button_->x() - kRelatedButtonHSpacing;
diff --git a/chrome/views/window/dialog_delegate.cc b/chrome/views/window/dialog_delegate.cc
index 80d0e8b..9778066 100644
--- a/chrome/views/window/dialog_delegate.cc
+++ b/chrome/views/window/dialog_delegate.cc
@@ -13,18 +13,18 @@ namespace views {
// Overridden from WindowDelegate:
int DialogDelegate::GetDefaultDialogButton() const {
- if (GetDialogButtons() & MessageBox::DIALOGBUTTON_OK)
- return MessageBox::DIALOGBUTTON_OK;
- if (GetDialogButtons() & MessageBox::DIALOGBUTTON_CANCEL)
- return MessageBox::DIALOGBUTTON_CANCEL;
- return MessageBox::DIALOGBUTTON_NONE;
+ if (GetDialogButtons() & DIALOGBUTTON_OK)
+ return DIALOGBUTTON_OK;
+ if (GetDialogButtons() & DIALOGBUTTON_CANCEL)
+ return DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_NONE;
}
View* DialogDelegate::GetInitiallyFocusedView() {
// Focus the default button if any.
DialogClientView* dcv = GetDialogClientView();
int default_button = GetDefaultDialogButton();
- if (default_button == MessageBox::DIALOGBUTTON_NONE)
+ if (default_button == DIALOGBUTTON_NONE)
return NULL;
if ((default_button & GetDialogButtons()) == 0) {
@@ -33,9 +33,9 @@ View* DialogDelegate::GetInitiallyFocusedView() {
return NULL;
}
- if (default_button & MessageBox::DIALOGBUTTON_OK)
+ if (default_button & DIALOGBUTTON_OK)
return dcv->ok_button();
- if (default_button & MessageBox::DIALOGBUTTON_CANCEL)
+ if (default_button & DIALOGBUTTON_CANCEL)
return dcv->cancel_button();
return NULL;
}
diff --git a/chrome/views/window/dialog_delegate.h b/chrome/views/window/dialog_delegate.h
index 0705703..b8b2d1b 100644
--- a/chrome/views/window/dialog_delegate.h
+++ b/chrome/views/window/dialog_delegate.h
@@ -5,7 +5,6 @@
#ifndef CHROME_VIEWS_WINDOW_DIALOG_DELEGATE_H_
#define CHROME_VIEWS_WINDOW_DIALOG_DELEGATE_H_
-#include "chrome/common/message_box_flags.h"
#include "chrome/views/window/dialog_client_view.h"
#include "chrome/views/window/window_delegate.h"
@@ -27,6 +26,12 @@ class DialogDelegate : public WindowDelegate {
public:
virtual DialogDelegate* AsDialogDelegate() { return this; }
+ enum DialogButton {
+ DIALOGBUTTON_NONE = 0, // No dialog buttons, for WindowType == WINDOW.
+ DIALOGBUTTON_OK = 1, // Has an OK button.
+ DIALOGBUTTON_CANCEL = 2, // Has a Cancel button (becomes a Close button if
+ }; // no OK button).
+
// Returns a mask specifying which of the available DialogButtons are visible
// for the dialog. Note: If an OK button is provided, you should provide a
// CANCEL button. A dialog box with just an OK button is frowned upon and
@@ -35,21 +40,18 @@ class DialogDelegate : public WindowDelegate {
//
// To use the extra button you need to override GetDialogButtons()
virtual int GetDialogButtons() const {
- return MessageBox::DIALOGBUTTON_OK | MessageBox::DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
}
// Returns whether accelerators are enabled on the button. This is invoked
// when an accelerator is pressed, not at construction time. This
// returns true.
- virtual bool AreAcceleratorsEnabled(MessageBox::DialogButton button) {
- return true;
- }
+ virtual bool AreAcceleratorsEnabled(DialogButton button) { return true; }
// Returns the label of the specified DialogButton.
- virtual std::wstring GetDialogButtonLabel(
- MessageBox::DialogButton button) const {
- // empty string results in defaults for MessageBox::DIALOGBUTTON_OK,
- // MessageBox::DIALOGBUTTON_CANCEL.
+ virtual std::wstring GetDialogButtonLabel(DialogButton button) const {
+ // empty string results in defaults for DIALOGBUTTON_OK,
+ // DIALOGBUTTON_CANCEL.
return L"";
}
@@ -58,21 +60,20 @@ class DialogDelegate : public WindowDelegate {
// up to the buttons.
virtual View* GetExtraView() { return NULL; }
- // Returns the default dialog button. This should not be a mask as only
- // one button should ever be the default button. Return
- // MessageBox::DIALOGBUTTON_NONE if there is no default. Default behavior
- // is to return MessageBox::DIALOGBUTTON_OK or
- // MessageBox::DIALOGBUTTON_CANCEL (in that order) if they are present,
- // MessageBox::DIALOGBUTTON_NONE otherwise.
+ // Returns the default dialog button. This should not be a mask as only one
+ // button should ever be the default button. Return DIALOGBUTTON_NONE if
+ // there is no default. Default behavior is to return DIALOGBUTTON_OK or
+ // DIALOGBUTTON_CANCEL (in that order) if they are present, DIALOGBUTTON_NONE
+ // otherwise.
virtual int GetDefaultDialogButton() const;
// Returns whether the specified dialog button is enabled.
- virtual bool IsDialogButtonEnabled(MessageBox::DialogButton button) const {
+ virtual bool IsDialogButtonEnabled(DialogButton button) const {
return true;
}
// Returns whether the specified dialog button is visible.
- virtual bool IsDialogButtonVisible(MessageBox::DialogButton button) const {
+ virtual bool IsDialogButtonVisible(DialogButton button) const {
return true;
}