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

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

Issue 1871133002: [MD] Use strong call to action styling on solitary infobar buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: strong and independent Created 4 years, 8 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.
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 "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const ViewHierarchyChangedDetails& details) { 67 const ViewHierarchyChangedDetails& details) {
68 if (details.is_add && details.child == this && (label_ == nullptr)) { 68 if (details.is_add && details.child == this && (label_ == nullptr)) {
69 ConfirmInfoBarDelegate* delegate = GetDelegate(); 69 ConfirmInfoBarDelegate* delegate = GetDelegate();
70 label_ = CreateLabel(delegate->GetMessageText()); 70 label_ = CreateLabel(delegate->GetMessageText());
71 AddViewToContentArea(label_); 71 AddViewToContentArea(label_);
72 72
73 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) { 73 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) {
74 if (ui::MaterialDesignController::IsModeMaterial()) { 74 if (ui::MaterialDesignController::IsModeMaterial()) {
75 views::MdTextButton* button = CreateMdTextButton( 75 views::MdTextButton* button = CreateMdTextButton(
76 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 76 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
77 // If this is the only button, weak call to action. Otherwise, strong 77 button->SetCallToAction(views::MdTextButton::STRONG_CALL_TO_ACTION);
78 // call to action.
79 button->SetCallToAction(
80 delegate->GetButtons() == ConfirmInfoBarDelegate::BUTTON_OK
81 ? views::MdTextButton::WEAK_CALL_TO_ACTION
82 : views::MdTextButton::STRONG_CALL_TO_ACTION);
83 ok_button_ = button; 78 ok_button_ = button;
84 } else { 79 } else {
85 ok_button_ = CreateTextButton( 80 ok_button_ = CreateTextButton(
86 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 81 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
87 } 82 }
88 if (delegate->OKButtonTriggersUACPrompt()) { 83 if (delegate->OKButtonTriggersUACPrompt()) {
89 elevation_icon_setter_.reset(new ElevationIconSetter( 84 elevation_icon_setter_.reset(new ElevationIconSetter(
90 ok_button_, 85 ok_button_,
91 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this)))); 86 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this))));
92 } 87 }
93 AddViewToContentArea(ok_button_); 88 AddViewToContentArea(ok_button_);
94 ok_button_->SizeToPreferredSize(); 89 ok_button_->SizeToPreferredSize();
95 } 90 }
96 91
97 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { 92 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) {
98 if (ui::MaterialDesignController::IsModeMaterial()) { 93 if (ui::MaterialDesignController::IsModeMaterial()) {
99 views::MdTextButton* button = CreateMdTextButton( 94 views::MdTextButton* button = CreateMdTextButton(
100 this, 95 this,
101 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 96 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
102 // If this is the only button, weak call to action. Otherwise, no call 97 // Apply CTA only if the cancel button is the only button.
103 // to action. 98 if (delegate->GetButtons() == ConfirmInfoBarDelegate::BUTTON_CANCEL)
104 button->SetCallToAction( 99 button->SetCallToAction(views::MdTextButton::STRONG_CALL_TO_ACTION);
105 delegate->GetButtons() == ConfirmInfoBarDelegate::BUTTON_CANCEL
106 ? views::MdTextButton::WEAK_CALL_TO_ACTION
107 : views::MdTextButton::NO_CALL_TO_ACTION);
108 cancel_button_ = button; 100 cancel_button_ = button;
109 } else { 101 } else {
110 cancel_button_ = CreateTextButton( 102 cancel_button_ = CreateTextButton(
111 this, 103 this,
112 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 104 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
113 } 105 }
114 AddViewToContentArea(cancel_button_); 106 AddViewToContentArea(cancel_button_);
115 cancel_button_->SizeToPreferredSize(); 107 cancel_button_->SizeToPreferredSize();
116 } 108 }
117 109
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 151 }
160 152
161 int ConfirmInfoBar::NonLabelWidth() const { 153 int ConfirmInfoBar::NonLabelWidth() const {
162 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? 154 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ?
163 0 : kEndOfLabelSpacing; 155 0 : kEndOfLabelSpacing;
164 if (ok_button_) 156 if (ok_button_)
165 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); 157 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0);
166 width += cancel_button_ ? cancel_button_->width() : 0; 158 width += cancel_button_ ? cancel_button_->width() : 0;
167 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); 159 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing);
168 } 160 }
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