Commit aaf6089b authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Move to account store bubble: Hook up the "No, thanks" button

If the user presses the "No, thanks" button, Chrome shouldn't ask to
move this particular password again. That requires hooking up the button
to PasswordFormManager::BlockMovingCredentialsToAccountStore() which
this CL does.

Bug: 1060128
Change-Id: I706bffd07d9883db1544363524628d24f56e4272
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2263214Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781807}
parent 47f2f468
...@@ -47,6 +47,10 @@ void MoveToAccountStoreBubbleController::AcceptMove() { ...@@ -47,6 +47,10 @@ void MoveToAccountStoreBubbleController::AcceptMove() {
return delegate_->AuthenticateUserForAccountStoreOptInAndMovePassword(); return delegate_->AuthenticateUserForAccountStoreOptInAndMovePassword();
} }
void MoveToAccountStoreBubbleController::RejectMove() {
return delegate_->BlockMovingPasswordToAccountStore();
}
gfx::Image MoveToAccountStoreBubbleController::GetProfileIcon() { gfx::Image MoveToAccountStoreBubbleController::GetProfileIcon() {
if (!GetProfile()) if (!GetProfile())
return gfx::Image(); return gfx::Image();
......
...@@ -21,6 +21,9 @@ class MoveToAccountStoreBubbleController : public PasswordBubbleControllerBase { ...@@ -21,6 +21,9 @@ class MoveToAccountStoreBubbleController : public PasswordBubbleControllerBase {
// Called by the view when the user clicks the confirmation button. // Called by the view when the user clicks the confirmation button.
void AcceptMove(); void AcceptMove();
// Called by the view when the user clicks the "No, thanks" button.
void RejectMove();
// Returns either a large site icon or a fallback icon. // Returns either a large site icon or a fallback icon.
gfx::Image GetProfileIcon(); gfx::Image GetProfileIcon();
......
...@@ -82,6 +82,11 @@ TEST_F(MoveToAccountStoreBubbleControllerTest, AuthenticateMoveIfOptedOut) { ...@@ -82,6 +82,11 @@ TEST_F(MoveToAccountStoreBubbleControllerTest, AuthenticateMoveIfOptedOut) {
controller()->AcceptMove(); controller()->AcceptMove();
} }
TEST_F(MoveToAccountStoreBubbleControllerTest, RejectMove) {
EXPECT_CALL(*delegate(), BlockMovingPasswordToAccountStore);
controller()->RejectMove();
}
TEST_F(MoveToAccountStoreBubbleControllerTest, ProvidesTitle) { TEST_F(MoveToAccountStoreBubbleControllerTest, ProvidesTitle) {
PasswordBubbleControllerBase* controller_ptr = controller(); PasswordBubbleControllerBase* controller_ptr = controller();
EXPECT_EQ(controller_ptr->GetTitle(), EXPECT_EQ(controller_ptr->GetTitle(),
......
...@@ -545,6 +545,16 @@ void ManagePasswordsUIController::MovePasswordToAccountStore() { ...@@ -545,6 +545,16 @@ void ManagePasswordsUIController::MovePasswordToAccountStore() {
UpdateBubbleAndIconVisibility(); UpdateBubbleAndIconVisibility();
} }
void ManagePasswordsUIController::BlockMovingPasswordToAccountStore() {
DCHECK_EQ(GetState(),
password_manager::ui::CAN_MOVE_PASSWORD_TO_ACCOUNT_STATE)
<< GetState();
passwords_data_.form_manager()->BlockMovingCredentialsToAccountStore();
ClearPopUpFlagForBubble();
passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
UpdateBubbleAndIconVisibility();
}
void ManagePasswordsUIController::ChooseCredential( void ManagePasswordsUIController::ChooseCredential(
const autofill::PasswordForm& form, const autofill::PasswordForm& form,
password_manager::CredentialType credential_type) { password_manager::CredentialType credential_type) {
......
...@@ -146,6 +146,7 @@ class ManagePasswordsUIController ...@@ -146,6 +146,7 @@ class ManagePasswordsUIController
void SaveUnsyncedCredentialsInProfileStore() override; void SaveUnsyncedCredentialsInProfileStore() override;
void DiscardUnsyncedCredentials() override; void DiscardUnsyncedCredentials() override;
void MovePasswordToAccountStore() override; void MovePasswordToAccountStore() override;
void BlockMovingPasswordToAccountStore() override;
void ChooseCredential( void ChooseCredential(
const autofill::PasswordForm& form, const autofill::PasswordForm& form,
password_manager::CredentialType credential_type) override; password_manager::CredentialType credential_type) override;
......
...@@ -121,6 +121,10 @@ class PasswordsModelDelegate { ...@@ -121,6 +121,10 @@ class PasswordsModelDelegate {
// used credential to their account store. // used credential to their account store.
virtual void MovePasswordToAccountStore() = 0; virtual void MovePasswordToAccountStore() = 0;
// Called from the dialog controller when a user rejects moving the recently
// used credential to their account store.
virtual void BlockMovingPasswordToAccountStore() = 0;
// Called from the dialog controller when the user chooses a credential. // Called from the dialog controller when the user chooses a credential.
// Controller can be destroyed inside the method. // Controller can be destroyed inside the method.
virtual void ChooseCredential( virtual void ChooseCredential(
......
...@@ -51,6 +51,7 @@ class PasswordsModelDelegateMock ...@@ -51,6 +51,7 @@ class PasswordsModelDelegateMock
MOCK_METHOD0(SaveUnsyncedCredentialsInProfileStore, void()); MOCK_METHOD0(SaveUnsyncedCredentialsInProfileStore, void());
MOCK_METHOD0(DiscardUnsyncedCredentials, void()); MOCK_METHOD0(DiscardUnsyncedCredentials, void());
MOCK_METHOD0(MovePasswordToAccountStore, void()); MOCK_METHOD0(MovePasswordToAccountStore, void());
MOCK_METHOD0(BlockMovingPasswordToAccountStore, void());
MOCK_METHOD2(ChooseCredential, MOCK_METHOD2(ChooseCredential,
void(const autofill::PasswordForm&, void(const autofill::PasswordForm&,
password_manager::CredentialType)); password_manager::CredentialType));
......
...@@ -88,6 +88,9 @@ MoveToAccountStoreBubbleView::MoveToAccountStoreBubbleView( ...@@ -88,6 +88,9 @@ MoveToAccountStoreBubbleView::MoveToAccountStoreBubbleView(
SetAcceptCallback( SetAcceptCallback(
base::BindOnce(&MoveToAccountStoreBubbleController::AcceptMove, base::BindOnce(&MoveToAccountStoreBubbleController::AcceptMove,
base::Unretained(&controller_))); base::Unretained(&controller_)));
SetCancelCallback(
base::BindOnce(&MoveToAccountStoreBubbleController::RejectMove,
base::Unretained(&controller_)));
} }
MoveToAccountStoreBubbleView::~MoveToAccountStoreBubbleView() = default; MoveToAccountStoreBubbleView::~MoveToAccountStoreBubbleView() = default;
......
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