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

Side by Side Diff: chrome/browser/ui/views/infobars/confirm_infobar.cc

Issue 2375543003: Add SetProminent() to MdTextButton to create blue buttons. (Closed)
Patch Set: Fix nits. Created 4 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 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 "chrome/browser/ui/views/infobars/confirm_infobar.h" 5 #include "chrome/browser/ui/views/infobars/confirm_infobar.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void ConfirmInfoBar::ViewHierarchyChanged( 67 void ConfirmInfoBar::ViewHierarchyChanged(
68 const ViewHierarchyChangedDetails& details) { 68 const ViewHierarchyChangedDetails& details) {
69 if (details.is_add && details.child == this && (label_ == nullptr)) { 69 if (details.is_add && details.child == this && (label_ == nullptr)) {
70 ConfirmInfoBarDelegate* delegate = GetDelegate(); 70 ConfirmInfoBarDelegate* delegate = GetDelegate();
71 label_ = CreateLabel(delegate->GetMessageText()); 71 label_ = CreateLabel(delegate->GetMessageText());
72 AddViewToContentArea(label_); 72 AddViewToContentArea(label_);
73 73
74 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) { 74 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) {
75 ok_button_ = views::MdTextButton::Create( 75 ok_button_ = views::MdTextButton::Create(
76 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 76 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
77 ok_button_->SetCallToAction(true); 77 ok_button_->SetProminent(true);
78 if (delegate->OKButtonTriggersUACPrompt()) { 78 if (delegate->OKButtonTriggersUACPrompt()) {
79 elevation_icon_setter_.reset(new ElevationIconSetter( 79 elevation_icon_setter_.reset(new ElevationIconSetter(
80 ok_button_, 80 ok_button_,
81 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this)))); 81 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this))));
82 } 82 }
83 AddViewToContentArea(ok_button_); 83 AddViewToContentArea(ok_button_);
84 ok_button_->SizeToPreferredSize(); 84 ok_button_->SizeToPreferredSize();
85 } 85 }
86 86
87 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { 87 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) {
88 cancel_button_ = views::MdTextButton::Create( 88 cancel_button_ = views::MdTextButton::Create(
89 this, 89 this,
90 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 90 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
91 if (delegate->GetButtons() == ConfirmInfoBarDelegate::BUTTON_CANCEL) { 91 if (delegate->GetButtons() == ConfirmInfoBarDelegate::BUTTON_CANCEL) {
92 // Apply CTA only if the cancel button is the only button. 92 // Apply prominent styling only if the cancel button is the only button.
93 cancel_button_->SetCallToAction(true); 93 cancel_button_->SetProminent(true);
94 } else { 94 } else {
95 // Otherwise set the bg color to white and the text color to black. 95 // Otherwise set the bg color to white and the text color to black.
96 // TODO(estade): These should be removed and moved into the native 96 // TODO(estade): These should be removed and moved into the native
97 // theme. Also, infobars should always use the normal (non-incognito) 97 // theme. Also, infobars should always use the normal (non-incognito)
98 // native theme. 98 // native theme.
99 cancel_button_->set_bg_color_override(SK_ColorWHITE); 99 cancel_button_->set_bg_color_override(SK_ColorWHITE);
100 cancel_button_->SetEnabledTextColors(kTextColor); 100 cancel_button_->SetEnabledTextColors(kTextColor);
101 } 101 }
102 AddViewToContentArea(cancel_button_); 102 AddViewToContentArea(cancel_button_);
103 cancel_button_->SizeToPreferredSize(); 103 cancel_button_->SizeToPreferredSize();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 int ConfirmInfoBar::NonLabelWidth() const { 149 int ConfirmInfoBar::NonLabelWidth() const {
150 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? 150 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ?
151 0 : kEndOfLabelSpacing; 151 0 : kEndOfLabelSpacing;
152 if (ok_button_) 152 if (ok_button_)
153 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); 153 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0);
154 width += cancel_button_ ? cancel_button_->width() : 0; 154 width += cancel_button_ ? cancel_button_->width() : 0;
155 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); 155 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing);
156 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc ('k') | chrome/browser/ui/views/location_bar/bubble_icon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698