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

Unified Diff: ui/views/window/dialog_delegate.cc

Issue 2151933002: DialogDelegate: allow platforms to prevent Cancel being default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test for mac Created 4 years, 5 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 | « ui/views/window/dialog_client_view_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/window/dialog_delegate.cc
diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc
index 4b8a1f9890010f0a94e8d95083fee7e4f593a2ff..d98274cde71a90871a5fd96875f70838ca61cb3f 100644
--- a/ui/views/window/dialog_delegate.cc
+++ b/ui/views/window/dialog_delegate.cc
@@ -16,6 +16,7 @@
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/layout/layout_constants.h"
+#include "ui/views/style/platform_style.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/window/dialog_client_view.h"
@@ -119,7 +120,12 @@ bool DialogDelegate::Close() {
void DialogDelegate::UpdateButton(LabelButton* button, ui::DialogButton type) {
button->SetText(GetDialogButtonLabel(type));
button->SetEnabled(IsDialogButtonEnabled(type));
- button->SetIsDefault(type == GetDefaultDialogButton());
+ bool is_default = type == GetDefaultDialogButton();
+ if (!PlatformStyle::kDialogDefaultButtonCanBeCancel &&
+ type == ui::DIALOG_BUTTON_CANCEL) {
+ is_default = false;
+ }
+ button->SetIsDefault(is_default);
}
int DialogDelegate::GetDialogButtons() const {
« no previous file with comments | « ui/views/window/dialog_client_view_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698