Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: chrome/views/dialog_delegate.cc

Issue 8786: Fix default focused button in dialogs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/views/dialog_delegate.h ('k') | chrome/views/message_box_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/views/dialog_delegate.cc
===================================================================
--- chrome/views/dialog_delegate.cc (revision 4259)
+++ chrome/views/dialog_delegate.cc (working copy)
@@ -9,12 +9,31 @@
namespace views {
// Overridden from WindowDelegate:
+
+int DialogDelegate::GetDefaultDialogButton() const {
+ if (GetDialogButtons() & DIALOGBUTTON_OK)
+ return DIALOGBUTTON_OK;
+ if (GetDialogButtons() & DIALOGBUTTON_CANCEL)
+ return DIALOGBUTTON_CANCEL;
+ return DIALOGBUTTON_NONE;
+}
+
View* DialogDelegate::GetInitiallyFocusedView() const {
- // Try to focus the OK then the Cancel button if present.
+ // Focus the default button if any.
DialogClientView* dcv = GetDialogClientView();
- if (GetDialogButtons() & DIALOGBUTTON_OK)
+ int default_button = GetDefaultDialogButton();
+ if (default_button == DIALOGBUTTON_NONE)
+ return NULL;
+
+ if ((default_button & GetDialogButtons()) == 0) {
+ // The default button is a button we don't have.
+ NOTREACHED();
+ return NULL;
+ }
+
+ if (default_button & DIALOGBUTTON_OK)
return dcv->ok_button();
- if (GetDialogButtons() & DIALOGBUTTON_CANCEL)
+ if (default_button & DIALOGBUTTON_CANCEL)
return dcv->cancel_button();
return NULL;
}
« no previous file with comments | « chrome/views/dialog_delegate.h ('k') | chrome/views/message_box_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698