Commit 1328a2dd authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cbui: remove SaveCardOfferBubbleViews CreateFootnoteView

For this dialog, the LegalMessageLines parameter comes from
SaveCardBubbleControllerImpl, which has two code paths to show this
dialog. Both those code paths look roughly like this:

  if (already_showing_dialog)
    return;
  legal_message_lines_ = ...;
  ShowDialog();

and there are no other places that change legal_message_lines_, so it is
effectively const across the lifetime of the dialog. Unfortunately,
because the same SaveCardBubbleControllerImpl is used for several
different concrete bubble subclasses, changing the behavior of
ShowDialog to simply pass the message lines in as a constructor
parameter (which would make it obvious that it's const for the lifetime
of the dialog) is not easy to do.

Bug: 1011446
Change-Id: I9b0584de8495b97f685b2973134e9d04873c317e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917520Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715447}
parent 1eb97ea7
...@@ -49,6 +49,16 @@ namespace autofill { ...@@ -49,6 +49,16 @@ namespace autofill {
namespace { namespace {
const int kTooltipBubbleWidth = 320; const int kTooltipBubbleWidth = 320;
const int kTooltipIconSize = 12; const int kTooltipIconSize = 12;
std::unique_ptr<LegalMessageView> CreateLegalMessageView(
const LegalMessageLines& message_lines,
views::StyledLabelListener* listener) {
if (message_lines.empty())
return nullptr;
return std::make_unique<LegalMessageView>(message_lines, listener);
}
} // namespace } // namespace
SaveCardOfferBubbleViews::SaveCardOfferBubbleViews( SaveCardOfferBubbleViews::SaveCardOfferBubbleViews(
...@@ -57,6 +67,10 @@ SaveCardOfferBubbleViews::SaveCardOfferBubbleViews( ...@@ -57,6 +67,10 @@ SaveCardOfferBubbleViews::SaveCardOfferBubbleViews(
SaveCardBubbleController* controller) SaveCardBubbleController* controller)
: SaveCardBubbleViews(anchor_view, web_contents, controller) { : SaveCardBubbleViews(anchor_view, web_contents, controller) {
DialogDelegate::set_buttons(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL); DialogDelegate::set_buttons(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL);
legal_message_view_ = DialogDelegate::SetFootnoteView(
CreateLegalMessageView(controller->GetLegalMessageLines(), this));
if (legal_message_view_)
InitFootnoteView(legal_message_view_);
} }
void SaveCardOfferBubbleViews::Init() { void SaveCardOfferBubbleViews::Init() {
...@@ -64,18 +78,6 @@ void SaveCardOfferBubbleViews::Init() { ...@@ -64,18 +78,6 @@ void SaveCardOfferBubbleViews::Init() {
DialogDelegate::SetExtraView(CreateUploadExplanationView()); DialogDelegate::SetExtraView(CreateUploadExplanationView());
} }
std::unique_ptr<views::View> SaveCardOfferBubbleViews::CreateFootnoteView() {
if (controller()->GetLegalMessageLines().empty())
return nullptr;
auto legal_message_view = std::make_unique<LegalMessageView>(
controller()->GetLegalMessageLines(), this);
legal_message_view_ = legal_message_view.get();
InitFootnoteView(legal_message_view_);
return legal_message_view;
}
bool SaveCardOfferBubbleViews::Accept() { bool SaveCardOfferBubbleViews::Accept() {
if (controller()) { if (controller()) {
controller()->OnSaveButton( controller()->OnSaveButton(
......
...@@ -34,7 +34,6 @@ class SaveCardOfferBubbleViews : public SaveCardBubbleViews, ...@@ -34,7 +34,6 @@ class SaveCardOfferBubbleViews : public SaveCardBubbleViews,
// BubbleDialogDelegateView: // BubbleDialogDelegateView:
void Init() override; void Init() override;
std::unique_ptr<views::View> CreateFootnoteView() override;
bool Accept() override; bool Accept() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
......
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