Commit 648fa1e6 authored by siyua's avatar siyua Committed by Commit Bot

[AF][Upstream String] Move GetDialogButtonLabel logic from views to

save card bubble controller.

This is required in my other CL 1610308 as adding string variations
experiment logic all to views should be avoided. Separate the refactor
from the other CL to keep them small. Following Upstream String
related CL will be based on this one

Bug: 961082
Change-Id: I44ccdb387405685789871ad8d758988237f2194a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626025
Commit-Queue: Siyu An <siyua@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#662494}
parent 92571fda
......@@ -257,6 +257,35 @@ base::string16 SaveCardBubbleControllerImpl::GetExplanatoryMessage() const {
: IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_V3);
}
base::string16 SaveCardBubbleControllerImpl::GetAcceptButtonText() const {
switch (current_bubble_type_) {
case BubbleType::LOCAL_SAVE:
case BubbleType::UPLOAD_SAVE:
return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_ACCEPT);
case BubbleType::MANAGE_CARDS:
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DONE);
case BubbleType::SIGN_IN_PROMO:
case BubbleType::FAILURE:
case BubbleType::INACTIVE:
NOTREACHED();
return base::string16();
}
}
base::string16 SaveCardBubbleControllerImpl::GetDeclineButtonText() const {
switch (current_bubble_type_) {
case BubbleType::LOCAL_SAVE:
case BubbleType::UPLOAD_SAVE:
return l10n_util::GetStringUTF16(IDS_NO_THANKS);
case BubbleType::MANAGE_CARDS:
case BubbleType::SIGN_IN_PROMO:
case BubbleType::FAILURE:
case BubbleType::INACTIVE:
NOTREACHED();
return base::string16();
}
}
const AccountInfo& SaveCardBubbleControllerImpl::GetAccountInfo() const {
return account_info_;
}
......
......@@ -101,6 +101,8 @@ class SaveCardBubbleControllerImpl
// SaveCardBubbleController:
base::string16 GetWindowTitle() const override;
base::string16 GetExplanatoryMessage() const override;
base::string16 GetAcceptButtonText() const override;
base::string16 GetDeclineButtonText() const override;
const AccountInfo& GetAccountInfo() const override;
Profile* GetProfile() const override;
const CreditCard& GetCard() const override;
......
......@@ -77,6 +77,12 @@ void SaveCardBubbleViews::Hide() {
CloseBubble();
}
base::string16 SaveCardBubbleViews::GetDialogButtonLabel(
ui::DialogButton button) const {
return button == ui::DIALOG_BUTTON_OK ? controller()->GetAcceptButtonText()
: controller()->GetDeclineButtonText();
}
views::View* SaveCardBubbleViews::CreateFootnoteView() {
return nullptr;
}
......
......@@ -40,6 +40,7 @@ class SaveCardBubbleViews : public SaveCardBubbleView,
void Hide() override;
// views::BubbleDialogDelegateView:
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
views::View* CreateFootnoteView() override;
bool Accept() override;
bool Cancel() override;
......@@ -85,9 +86,7 @@ class SaveCardBubbleViews : public SaveCardBubbleView,
// Called by sub-classes to initialize |footnote_view_|.
virtual void InitFootnoteView(views::View* footnote_view);
SaveCardBubbleController* controller() {
return controller_;
} // Weak reference.
SaveCardBubbleController* controller() const { return controller_; }
// Attributes IDs to the DialogClientView and its buttons.
void AssignIdsToDialogClientView();
......
......@@ -76,11 +76,6 @@ int SaveCardManageCardsBubbleViews::GetDialogButtons() const {
return ui::DIALOG_BUTTON_OK;
}
base::string16 SaveCardManageCardsBubbleViews::GetDialogButtonLabel(
ui::DialogButton button) const {
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DONE);
}
SaveCardManageCardsBubbleViews::~SaveCardManageCardsBubbleViews() {}
std::unique_ptr<views::View>
......
......@@ -29,7 +29,6 @@ class SaveCardManageCardsBubbleViews : public SaveCardBubbleViews,
views::View* CreateFootnoteView() override;
views::View* CreateExtraView() override;
int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
private:
std::unique_ptr<views::View> CreateMainContentView() override;
......
......@@ -113,13 +113,6 @@ int SaveCardOfferBubbleViews::GetDialogButtons() const {
: ui::DIALOG_BUTTON_OK;
}
base::string16 SaveCardOfferBubbleViews::GetDialogButtonLabel(
ui::DialogButton button) const {
return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK
? IDS_AUTOFILL_SAVE_CARD_PROMPT_ACCEPT
: IDS_NO_THANKS);
}
bool SaveCardOfferBubbleViews::IsDialogButtonEnabled(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_CANCEL)
......
......@@ -37,7 +37,6 @@ class SaveCardOfferBubbleViews : public SaveCardBubbleViews,
views::View* CreateExtraView() override;
views::View* CreateFootnoteView() override;
bool Accept() override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
int GetDialogButtons() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
......
......@@ -41,6 +41,10 @@ class SaveCardBubbleController {
// Returns an empty string if no message should be displayed.
virtual base::string16 GetExplanatoryMessage() const = 0;
// Returns the button label text for save card bubbles.
virtual base::string16 GetAcceptButtonText() const = 0;
virtual base::string16 GetDeclineButtonText() const = 0;
// Returns the account info of the signed-in user.
virtual const AccountInfo& GetAccountInfo() const = 0;
......
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