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

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

Issue 2615563003: MacViews: Ensure cancel buttons don't get default button styling. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
tapted 2017/01/04 23:11:40 CL description: Harfmony -> Harmony
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_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
11 #include "ui/events/keycodes/keyboard_codes.h" 11 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/views/background.h" 12 #include "ui/views/background.h"
13 #include "ui/views/controls/button/blue_button.h" 13 #include "ui/views/controls/button/blue_button.h"
14 #include "ui/views/controls/button/custom_button.h" 14 #include "ui/views/controls/button/custom_button.h"
15 #include "ui/views/controls/button/label_button.h" 15 #include "ui/views/controls/button/label_button.h"
16 #include "ui/views/controls/button/md_text_button.h" 16 #include "ui/views/controls/button/md_text_button.h"
17 #include "ui/views/layout/layout_constants.h" 17 #include "ui/views/layout/layout_constants.h"
18 #include "ui/views/style/platform_style.h"
18 #include "ui/views/views_delegate.h" 19 #include "ui/views/views_delegate.h"
19 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
20 #include "ui/views/window/dialog_delegate.h" 21 #include "ui/views/window/dialog_delegate.h"
21 22
22 namespace views { 23 namespace views {
23 24
24 namespace { 25 namespace {
25 26
26 // The group used by the buttons. This name is chosen voluntarily big not to 27 // The group used by the buttons. This name is chosen voluntarily big not to
27 // conflict with other groups that could be in the dialog content. 28 // conflict with other groups that could be in the dialog content.
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void DialogClientView::ChildVisibilityChanged(View* child) { 316 void DialogClientView::ChildVisibilityChanged(View* child) {
316 ChildPreferredSizeChanged(child); 317 ChildPreferredSizeChanged(child);
317 } 318 }
318 319
319 //////////////////////////////////////////////////////////////////////////////// 320 ////////////////////////////////////////////////////////////////////////////////
320 // DialogClientView, private: 321 // DialogClientView, private:
321 322
322 LabelButton* DialogClientView::CreateDialogButton(ui::DialogButton type) { 323 LabelButton* DialogClientView::CreateDialogButton(ui::DialogButton type) {
323 const base::string16 title = GetDialogDelegate()->GetDialogButtonLabel(type); 324 const base::string16 title = GetDialogDelegate()->GetDialogButtonLabel(type);
324 LabelButton* button = nullptr; 325 LabelButton* button = nullptr;
326
327 const bool is_default =
328 GetDialogDelegate()->GetDefaultDialogButton() == type &&
329 (type != ui::DIALOG_BUTTON_CANCEL ||
karandeepb 2017/01/04 07:46:51 This is similar to what we do in DialogDelegate::U
tapted 2017/01/04 23:11:40 IMO the nicer fix would be to merge the Blue/Regul
330 PlatformStyle::kDialogDefaultButtonCanBeCancel);
331
325 // The default button is always blue in Harmony. 332 // The default button is always blue in Harmony.
326 if (GetDialogDelegate()->GetDefaultDialogButton() == type && 333 if (is_default && (ui::MaterialDesignController::IsSecondaryUiMaterial() ||
327 (ui::MaterialDesignController::IsSecondaryUiMaterial() || 334 GetDialogDelegate()->ShouldDefaultButtonBeBlue())) {
328 GetDialogDelegate()->ShouldDefaultButtonBeBlue())) {
329 button = MdTextButton::CreateSecondaryUiBlueButton(this, title); 335 button = MdTextButton::CreateSecondaryUiBlueButton(this, title);
330 } else { 336 } else {
331 button = MdTextButton::CreateSecondaryUiButton(this, title); 337 button = MdTextButton::CreateSecondaryUiButton(this, title);
332 } 338 }
333 339
334 const int kDialogMinButtonWidth = 75; 340 const int kDialogMinButtonWidth = 75;
335 button->SetMinSize(gfx::Size(kDialogMinButtonWidth, 0)); 341 button->SetMinSize(gfx::Size(kDialogMinButtonWidth, 0));
336 button->SetGroup(kButtonGroup); 342 button->SetGroup(kButtonGroup);
337 return button; 343 return button;
338 } 344 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 std::remove(child_views.begin(), child_views.end(), nullptr), 392 std::remove(child_views.begin(), child_views.end(), nullptr),
387 child_views.end()); 393 child_views.end());
388 394
389 // Setup focus by reordering views. It is not safe to use SetNextFocusableView 395 // Setup focus by reordering views. It is not safe to use SetNextFocusableView
390 // since child views may be added externally to this view. 396 // since child views may be added externally to this view.
391 for (size_t i = 0; i < child_views.size(); i++) 397 for (size_t i = 0; i < child_views.size(); i++)
392 ReorderChildView(child_views[i], i); 398 ReorderChildView(child_views[i], i);
393 } 399 }
394 400
395 } // namespace views 401 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698