Commit 37669835 authored by estade's avatar estade Committed by Commit bot

Remove a new usage of LabelButton::SetStyle (in ChromeCleanerDialog).

This still can't be removed until secondary MD is on by default (and it
can't be protected for now either since Translate is still using it).
Rename to SetStyleDeprecated to discourage further use.

BUG=642920

Review-Url: https://codereview.chromium.org/2855093002
Cr-Commit-Position: refs/heads/master@{#469362}
parent 6d0700c2
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/text_constants.h" #include "ui/gfx/text_constants.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_constants.h" #include "ui/views/layout/layout_constants.h"
...@@ -39,10 +40,7 @@ constexpr int kDialogWidth = 448; ...@@ -39,10 +40,7 @@ constexpr int kDialogWidth = 448;
ChromeCleanerDialog::ChromeCleanerDialog( ChromeCleanerDialog::ChromeCleanerDialog(
safe_browsing::ChromeCleanerDialogController* controller) safe_browsing::ChromeCleanerDialogController* controller)
: browser_(nullptr), : browser_(nullptr), controller_(controller) {
controller_(controller),
advanced_button_(
new views::LabelButton(this, controller_->GetAdvancedButtonLabel())) {
DCHECK(controller_); DCHECK(controller_);
SetLayoutManager(new views::BoxLayout( SetLayoutManager(new views::BoxLayout(
...@@ -54,8 +52,6 @@ ChromeCleanerDialog::ChromeCleanerDialog( ...@@ -54,8 +52,6 @@ ChromeCleanerDialog::ChromeCleanerDialog(
label->SetMultiLine(true); label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT); label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(label); AddChildView(label);
advanced_button_->SetStyle(views::Button::STYLE_BUTTON);
} }
ChromeCleanerDialog::~ChromeCleanerDialog() { ChromeCleanerDialog::~ChromeCleanerDialog() {
...@@ -107,7 +103,8 @@ base::string16 ChromeCleanerDialog::GetDialogButtonLabel( ...@@ -107,7 +103,8 @@ base::string16 ChromeCleanerDialog::GetDialogButtonLabel(
} }
views::View* ChromeCleanerDialog::CreateExtraView() { views::View* ChromeCleanerDialog::CreateExtraView() {
return advanced_button_; return views::MdTextButton::CreateSecondaryUiButton(
this, controller_->GetAdvancedButtonLabel());
} }
bool ChromeCleanerDialog::Accept() { bool ChromeCleanerDialog::Accept() {
...@@ -144,7 +141,6 @@ gfx::Size ChromeCleanerDialog::GetPreferredSize() const { ...@@ -144,7 +141,6 @@ gfx::Size ChromeCleanerDialog::GetPreferredSize() const {
void ChromeCleanerDialog::ButtonPressed(views::Button* sender, void ChromeCleanerDialog::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
DCHECK_EQ(sender, advanced_button_);
DCHECK(browser_); DCHECK(browser_);
// TODO(alito): Navigate to the webui version of the Chrome Cleaner UI when // TODO(alito): Navigate to the webui version of the Chrome Cleaner UI when
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
class Browser; class Browser;
...@@ -65,8 +64,6 @@ class ChromeCleanerDialog : public views::DialogDelegateView, ...@@ -65,8 +64,6 @@ class ChromeCleanerDialog : public views::DialogDelegateView,
// user interaction since the controller can delete itself after that point. // user interaction since the controller can delete itself after that point.
safe_browsing::ChromeCleanerDialogController* controller_; safe_browsing::ChromeCleanerDialogController* controller_;
views::LabelButton* advanced_button_;
DISALLOW_COPY_AND_ASSIGN(ChromeCleanerDialog); DISALLOW_COPY_AND_ASSIGN(ChromeCleanerDialog);
}; };
......
...@@ -623,7 +623,7 @@ views::View* TranslateBubbleView::CreateViewBeforeTranslate() { ...@@ -623,7 +623,7 @@ views::View* TranslateBubbleView::CreateViewBeforeTranslate() {
denial_menu_button_ = new views::MenuButton( denial_menu_button_ = new views::MenuButton(
l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_OPTIONS_MENU_BUTTON), l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_OPTIONS_MENU_BUTTON),
this, true); this, true);
denial_menu_button_->SetStyle(views::Button::STYLE_BUTTON); denial_menu_button_->SetStyleDeprecated(views::Button::STYLE_BUTTON);
layout->AddView(denial_menu_button_); layout->AddView(denial_menu_button_);
} else { } else {
std::vector<base::string16> items( std::vector<base::string16> items(
......
...@@ -21,7 +21,7 @@ const char BlueButton::kViewClassName[] = "views/BlueButton"; ...@@ -21,7 +21,7 @@ const char BlueButton::kViewClassName[] = "views/BlueButton";
BlueButton::BlueButton(ButtonListener* listener, const base::string16& text) BlueButton::BlueButton(ButtonListener* listener, const base::string16& text)
: LabelButton(listener, text) { : LabelButton(listener, text) {
// Inherit STYLE_BUTTON insets, minimum size, alignment, etc. // Inherit STYLE_BUTTON insets, minimum size, alignment, etc.
SetStyle(STYLE_BUTTON); SetStyleDeprecated(STYLE_BUTTON);
UpdateThemedBorder(); UpdateThemedBorder();
} }
......
...@@ -30,7 +30,7 @@ TEST_F(BlueButtonTest, Border) { ...@@ -30,7 +30,7 @@ TEST_F(BlueButtonTest, Border) {
EXPECT_TRUE(button->focus_painter()); EXPECT_TRUE(button->focus_painter());
// Switch to the same style as BlueButton for a more compelling comparison. // Switch to the same style as BlueButton for a more compelling comparison.
button->SetStyle(Button::STYLE_BUTTON); button->SetStyleDeprecated(Button::STYLE_BUTTON);
EXPECT_EQ(Button::STYLE_BUTTON, button->style()); EXPECT_EQ(Button::STYLE_BUTTON, button->style());
EXPECT_FALSE(button->focus_painter()); EXPECT_FALSE(button->focus_painter());
......
...@@ -196,7 +196,7 @@ void LabelButton::SetIsDefault(bool is_default) { ...@@ -196,7 +196,7 @@ void LabelButton::SetIsDefault(bool is_default) {
UpdateStyleToIndicateDefaultStatus(); UpdateStyleToIndicateDefaultStatus();
} }
void LabelButton::SetStyle(ButtonStyle style) { void LabelButton::SetStyleDeprecated(ButtonStyle style) {
// All callers currently pass STYLE_BUTTON, and should only call this once, to // All callers currently pass STYLE_BUTTON, and should only call this once, to
// change from the default style. // change from the default style.
DCHECK_EQ(style, STYLE_BUTTON); DCHECK_EQ(style, STYLE_BUTTON);
......
...@@ -76,8 +76,10 @@ class VIEWS_EXPORT LabelButton : public CustomButton, ...@@ -76,8 +76,10 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
void SetIsDefault(bool is_default); void SetIsDefault(bool is_default);
// Gets or sets the button's overall style; the default is |STYLE_TEXTBUTTON|. // Gets or sets the button's overall style; the default is |STYLE_TEXTBUTTON|.
// DEPRECATED: ButtonStyle is deprecated. Use MdTextButton in place of
// |STYLE_BUTTON|.
ButtonStyle style() const { return style_; } ButtonStyle style() const { return style_; }
void SetStyle(ButtonStyle style); void SetStyleDeprecated(ButtonStyle style);
// Sets the spacing between the image and the text. Shrinking the spacing // Sets the spacing between the image and the text. Shrinking the spacing
// will not shrink the overall button size, as it is monotonically increasing. // will not shrink the overall button size, as it is monotonically increasing.
......
...@@ -63,7 +63,7 @@ class LabelButtonTest : public test::WidgetTest { ...@@ -63,7 +63,7 @@ class LabelButtonTest : public test::WidgetTest {
TestLabelButton* AddStyledButton(const char* label, bool is_default) { TestLabelButton* AddStyledButton(const char* label, bool is_default) {
TestLabelButton* button = new TestLabelButton; TestLabelButton* button = new TestLabelButton;
button->SetText(ASCIIToUTF16(label)); button->SetText(ASCIIToUTF16(label));
button->SetStyle(CustomButton::STYLE_BUTTON); button->SetStyleDeprecated(CustomButton::STYLE_BUTTON);
if (is_default) if (is_default)
button->SetIsDefault(true); button->SetIsDefault(true);
button_->GetWidget()->GetContentsView()->AddChildView(button); button_->GetWidget()->GetContentsView()->AddChildView(button);
......
...@@ -34,7 +34,7 @@ LabelButton* CreateButton(ButtonListener* listener, ...@@ -34,7 +34,7 @@ LabelButton* CreateButton(ButtonListener* listener,
return MdTextButton::Create(listener, text); return MdTextButton::Create(listener, text);
LabelButton* button = new LabelButton(listener, text); LabelButton* button = new LabelButton(listener, text);
button->SetStyle(CustomButton::STYLE_BUTTON); button->SetStyleDeprecated(CustomButton::STYLE_BUTTON);
return button; return button;
} }
......
...@@ -49,11 +49,11 @@ void ButtonExample::CreateExampleView(View* container) { ...@@ -49,11 +49,11 @@ void ButtonExample::CreateExampleView(View* container) {
container->AddChildView(label_button_); container->AddChildView(label_button_);
styled_button_ = new LabelButton(this, ASCIIToUTF16("Styled Button")); styled_button_ = new LabelButton(this, ASCIIToUTF16("Styled Button"));
styled_button_->SetStyle(Button::STYLE_BUTTON); styled_button_->SetStyleDeprecated(Button::STYLE_BUTTON);
container->AddChildView(styled_button_); container->AddChildView(styled_button_);
disabled_button_ = new LabelButton(this, ASCIIToUTF16("Disabled Button")); disabled_button_ = new LabelButton(this, ASCIIToUTF16("Disabled Button"));
disabled_button_->SetStyle(Button::STYLE_BUTTON); disabled_button_->SetStyleDeprecated(Button::STYLE_BUTTON);
disabled_button_->SetState(Button::STATE_DISABLED); disabled_button_->SetState(Button::STATE_DISABLED);
container->AddChildView(disabled_button_); container->AddChildView(disabled_button_);
...@@ -108,7 +108,7 @@ void ButtonExample::LabelButtonPressed(LabelButton* label_button, ...@@ -108,7 +108,7 @@ void ButtonExample::LabelButtonPressed(LabelButton* label_button,
? label_button_->SetFocusBehavior(View::FocusBehavior::NEVER) ? label_button_->SetFocusBehavior(View::FocusBehavior::NEVER)
: label_button_->SetFocusForPlatform(); : label_button_->SetFocusForPlatform();
} else { } else {
label_button->SetStyle(static_cast<Button::ButtonStyle>( label_button->SetStyleDeprecated(static_cast<Button::ButtonStyle>(
(label_button->style() + 1) % Button::STYLE_COUNT)); (label_button->style() + 1) % Button::STYLE_COUNT));
} }
} else if (event.IsAltDown()) { } else if (event.IsAltDown()) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -55,9 +55,8 @@ base::string16 DialogExample::GetWindowTitle() const { ...@@ -55,9 +55,8 @@ base::string16 DialogExample::GetWindowTitle() const {
} }
View* DialogExample::CreateExtraView() { View* DialogExample::CreateExtraView() {
LabelButton* button = new LabelButton(NULL, ASCIIToUTF16("Extra button!")); return MdTextButton::CreateSecondaryUiButton(nullptr,
button->SetStyle(Button::STYLE_BUTTON); ASCIIToUTF16("Extra button!"));
return button;
} }
View* DialogExample::CreateFootnoteView() { View* DialogExample::CreateFootnoteView() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment