Commit 2aa1dcc8 authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

[b4p] Use special button text in save bubble when opting in to b4p

When the user must opt in to the account-scoped password storage before
saving a password, the ok button in the bubble must display "Next".

Fixed: 1113126
Change-Id: Iff6e38359241344ab6ec280685bfd00ac995d4df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2369194Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Victor Vianna <victorvianna@google.com>
Cr-Commit-Position: refs/heads/master@{#800942}
parent a5f79dfc
......@@ -5998,6 +5998,9 @@ the Bookmarks menu.">
<message name="IDS_PASSWORD_MANAGER_SAVE_BUTTON" desc="Save button text for password manager">
Save
</message>
<message name="IDS_PASSWORD_MANAGER_SAVE_BUBBLE_OPT_IN_BUTTON" desc="Text for action button in the save bubble that leads the user to opt in to the account-scoped password storage.">
Next
</message>
<message name="IDS_PASSWORD_MANAGER_MOVE_BUBBLE_OK_BUTTON" desc="Text for the ok button in the password manager move bubble.">
Move
</message>
......
e7d99b469be750abbe29eb5d63c326fb0f037d23
\ No newline at end of file
......@@ -153,18 +153,12 @@ void SaveUpdateWithAccountStoreBubbleController::OnSaveClicked() {
dismissal_reason_ = metrics_util::CLICKED_ACCEPT;
if (delegate_) {
CleanStatisticsForSite(GetProfile(), origin_);
if (IsCurrentStateUpdate() || !IsUsingAccountStore() ||
delegate_->GetPasswordFeatureManager()->IsOptedInForAccountStorage()) {
// The following cases don't require gaia reauth:
// 1. Password Update.
// 2. User is saving locally .
// 3. User has already opted in to the account store.
delegate_->SavePassword(pending_password_.username_value,
pending_password_.password_value);
} else {
// Otherwise, we should invoke the reauth flow before saving.
if (IsAccountStorageOptInRequired()) {
delegate_->AuthenticateUserForAccountStoreOptInAndSavePassword(
pending_password_.username_value, pending_password_.password_value);
} else {
delegate_->SavePassword(pending_password_.username_value,
pending_password_.password_value);
}
}
}
......@@ -229,6 +223,22 @@ bool SaveUpdateWithAccountStoreBubbleController::IsUsingAccountStore() {
Store::kAccountStore;
}
bool SaveUpdateWithAccountStoreBubbleController::
IsAccountStorageOptInRequired() {
// If this is an update, either a) the password only exists in the profile
// store, so the opt-in shouldn't be offered because the account storage won't
// be used, or b) there is a copy in the account store, which means the user
// already opted in. Either way,the opt-in shouldn't be offered.
if (IsCurrentStateUpdate())
return false;
if (!IsUsingAccountStore())
return false;
if (delegate_->GetPasswordFeatureManager()->IsOptedInForAccountStorage()) {
return false;
}
return true;
}
std::string
SaveUpdateWithAccountStoreBubbleController::GetPrimaryAccountEmail() {
Profile* profile = GetProfile();
......
......@@ -68,6 +68,10 @@ class SaveUpdateWithAccountStoreBubbleController
// Returns true iff the password account store is used.
bool IsUsingAccountStore();
// Returns true if the user must opt-in to the account-scoped password storage
// before the bubble action can be concluded.
bool IsAccountStorageOptInRequired();
// Returns the email of current primary account. Returns empty string if no
// account is signed in.
std::string GetPrimaryAccountEmail();
......
......@@ -313,6 +313,7 @@ TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest,
EXPECT_TRUE(controller()->enable_editing());
EXPECT_FALSE(controller()->IsCurrentStateUpdate());
EXPECT_FALSE(controller()->IsAccountStorageOptInRequired());
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
EXPECT_CALL(*delegate(), OnPasswordsRevealed()).Times(0);
......@@ -336,6 +337,7 @@ TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest,
EXPECT_TRUE(controller()->enable_editing());
EXPECT_FALSE(controller()->IsCurrentStateUpdate());
EXPECT_TRUE(controller()->IsAccountStorageOptInRequired());
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
EXPECT_CALL(*delegate(), SavePassword).Times(0);
......@@ -360,6 +362,7 @@ TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest,
EXPECT_TRUE(controller()->enable_editing());
EXPECT_TRUE(controller()->IsCurrentStateUpdate());
EXPECT_FALSE(controller()->IsAccountStorageOptInRequired());
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
EXPECT_CALL(*delegate(), SavePassword(pending_password().username_value,
......
......@@ -658,11 +658,16 @@ void PasswordSaveUpdateWithAccountStoreView::
void PasswordSaveUpdateWithAccountStoreView::UpdateBubbleUIElements() {
SetButtons((ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL));
SetButtonLabel(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(controller_.IsCurrentStateUpdate()
? IDS_PASSWORD_MANAGER_UPDATE_BUTTON
: IDS_PASSWORD_MANAGER_SAVE_BUTTON));
base::string16 ok_button_text;
if (controller_.IsAccountStorageOptInRequired()) {
ok_button_text = l10n_util::GetStringUTF16(
IDS_PASSWORD_MANAGER_SAVE_BUBBLE_OPT_IN_BUTTON);
} else {
ok_button_text = l10n_util::GetStringUTF16(
controller_.IsCurrentStateUpdate() ? IDS_PASSWORD_MANAGER_UPDATE_BUTTON
: IDS_PASSWORD_MANAGER_SAVE_BUTTON);
}
SetButtonLabel(ui::DIALOG_BUTTON_OK, ok_button_text);
SetButtonLabel(
ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(
......
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