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

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

Issue 2187473004: Make normal MD text buttons *on infobars* white. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
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 if (ui::MaterialDesignController::IsModeMaterial()) { 75 if (ui::MaterialDesignController::IsModeMaterial()) {
76 views::MdTextButton* button = CreateMdTextButton( 76 views::MdTextButton* button = views::MdTextButton::CreateMdButton(
77 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 77 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
78 button->SetCallToAction(true); 78 button->SetCallToAction(true);
79 ok_button_ = button; 79 ok_button_ = button;
80 } else { 80 } else {
81 ok_button_ = CreateTextButton( 81 ok_button_ = CreateTextButton(
82 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 82 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
83 } 83 }
84 if (delegate->OKButtonTriggersUACPrompt()) { 84 if (delegate->OKButtonTriggersUACPrompt()) {
85 elevation_icon_setter_.reset(new ElevationIconSetter( 85 elevation_icon_setter_.reset(new ElevationIconSetter(
86 ok_button_, 86 ok_button_,
87 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this)))); 87 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this))));
88 } 88 }
89 AddViewToContentArea(ok_button_); 89 AddViewToContentArea(ok_button_);
90 ok_button_->SizeToPreferredSize(); 90 ok_button_->SizeToPreferredSize();
91 } 91 }
92 92
93 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { 93 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) {
94 if (ui::MaterialDesignController::IsModeMaterial()) { 94 if (ui::MaterialDesignController::IsModeMaterial()) {
95 views::MdTextButton* button = CreateMdTextButton( 95 views::MdTextButton* button = views::MdTextButton::CreateMdButton(
96 this, 96 this,
97 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 97 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
98 // Apply CTA only if the cancel button is the only button. 98 if (delegate->GetButtons() == ConfirmInfoBarDelegate::BUTTON_CANCEL) {
99 button->SetCallToAction(delegate->GetButtons() == 99 // Apply CTA only if the cancel button is the only button.
100 ConfirmInfoBarDelegate::BUTTON_CANCEL); 100 button->SetCallToAction(true);
101 } else {
102 // Otherwise set the bg color to white and the text color to black.
103 // TODO(estade): These should be removed and moved into the native
104 // theme. Also, infobars should always use the normal (non-incognito)
105 // native theme.
106 button->set_bg_color_override(SK_ColorWHITE);
107 button->SetEnabledTextColors(kTextColor);
108 }
101 cancel_button_ = button; 109 cancel_button_ = button;
102 } else { 110 } else {
103 cancel_button_ = CreateTextButton( 111 cancel_button_ = CreateTextButton(
104 this, 112 this,
105 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 113 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
106 } 114 }
107 AddViewToContentArea(cancel_button_); 115 AddViewToContentArea(cancel_button_);
108 cancel_button_->SizeToPreferredSize(); 116 cancel_button_->SizeToPreferredSize();
109 } 117 }
110 118
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 160 }
153 161
154 int ConfirmInfoBar::NonLabelWidth() const { 162 int ConfirmInfoBar::NonLabelWidth() const {
155 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? 163 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ?
156 0 : kEndOfLabelSpacing; 164 0 : kEndOfLabelSpacing;
157 if (ok_button_) 165 if (ok_button_)
158 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); 166 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0);
159 width += cancel_button_ ? cancel_button_->width() : 0; 167 width += cancel_button_ ? cancel_button_->width() : 0;
160 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); 168 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing);
161 } 169 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/infobars/infobar_view.h » ('j') | ui/views/controls/button/md_text_button.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698