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

Side by Side Diff: ui/views/window/dialog_delegate.cc

Issue 2880433002: views: don't snap dialogs with no buttons (Closed)
Patch Set: add unittest Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/window/dialog_delegate.h" 5 #include "ui/views/window/dialog_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 button->SetEnabled(IsDialogButtonEnabled(type)); 126 button->SetEnabled(IsDialogButtonEnabled(type));
127 bool is_default = type == GetDefaultDialogButton(); 127 bool is_default = type == GetDefaultDialogButton();
128 if (!PlatformStyle::kDialogDefaultButtonCanBeCancel && 128 if (!PlatformStyle::kDialogDefaultButtonCanBeCancel &&
129 type == ui::DIALOG_BUTTON_CANCEL) { 129 type == ui::DIALOG_BUTTON_CANCEL) {
130 is_default = false; 130 is_default = false;
131 } 131 }
132 button->SetIsDefault(is_default); 132 button->SetIsDefault(is_default);
133 } 133 }
134 134
135 bool DialogDelegate::ShouldSnapFrameWidth() const { 135 bool DialogDelegate::ShouldSnapFrameWidth() const {
136 return true; 136 return GetDialogButtons() != ui::DIALOG_BUTTON_NONE;
sky 2017/05/12 17:28:07 Would a better fix be to have BubbleDialogDelegate
137 } 137 }
138 138
139 int DialogDelegate::GetDialogButtons() const { 139 int DialogDelegate::GetDialogButtons() const {
140 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; 140 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
141 } 141 }
142 142
143 int DialogDelegate::GetDefaultDialogButton() const { 143 int DialogDelegate::GetDefaultDialogButton() const {
144 if (GetDialogButtons() & ui::DIALOG_BUTTON_OK) 144 if (GetDialogButtons() & ui::DIALOG_BUTTON_OK)
145 return ui::DIALOG_BUTTON_OK; 145 return ui::DIALOG_BUTTON_OK;
146 if (GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL) 146 if (GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 node_data->role = ui::AX_ROLE_DIALOG; 268 node_data->role = ui::AX_ROLE_DIALOG;
269 } 269 }
270 270
271 void DialogDelegateView::ViewHierarchyChanged( 271 void DialogDelegateView::ViewHierarchyChanged(
272 const ViewHierarchyChangedDetails& details) { 272 const ViewHierarchyChangedDetails& details) {
273 if (details.is_add && details.child == this && GetWidget()) 273 if (details.is_add && details.child == this && GetWidget())
274 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 274 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
275 } 275 }
276 276
277 } // namespace views 277 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view_unittest.cc ('k') | ui/views/window/dialog_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698