Commit be0f89fd authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Passwords] Add controller for bubble migrating credentials to account

This CL adds the controller scaffold of the bubble that proposes to
users to move their local credential to the account-storage.

See the linked bug for mocks.

Bug: 1060128
Change-Id: Idb53ef749d0ad18ee4dcb5af5f98cfedecfc7f8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159220
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760992}
parent fdb1c312
...@@ -1079,6 +1079,8 @@ jumbo_static_library("ui") { ...@@ -1079,6 +1079,8 @@ jumbo_static_library("ui") {
"page_info/page_info_infobar_delegate.h", "page_info/page_info_infobar_delegate.h",
"page_info/permission_menu_model.cc", "page_info/permission_menu_model.cc",
"page_info/permission_menu_model.h", "page_info/permission_menu_model.h",
"passwords/bubble_controllers/account_storage_migration_bubble_controller.cc",
"passwords/bubble_controllers/account_storage_migration_bubble_controller.h",
"passwords/bubble_controllers/auto_sign_in_bubble_controller.cc", "passwords/bubble_controllers/auto_sign_in_bubble_controller.cc",
"passwords/bubble_controllers/auto_sign_in_bubble_controller.h", "passwords/bubble_controllers/auto_sign_in_bubble_controller.h",
"passwords/bubble_controllers/generation_confirmation_bubble_controller.cc", "passwords/bubble_controllers/generation_confirmation_bubble_controller.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/passwords/bubble_controllers/account_storage_migration_bubble_controller.h"
AccountStorageMigrationBubbleController::
AccountStorageMigrationBubbleController(
base::WeakPtr<PasswordsModelDelegate> delegate)
: PasswordBubbleControllerBase(std::move(delegate),
password_manager::metrics_util::
AUTOMATIC_ACCOUNT_MIGRATION_PROPOSAL) {}
AccountStorageMigrationBubbleController::
~AccountStorageMigrationBubbleController() {
// Make sure the interactions are reported even if Views didn't notify the
// controller about the bubble being closed.
if (!interaction_reported_)
OnBubbleClosing();
}
base::string16 AccountStorageMigrationBubbleController::GetTitle() const {
return base::string16();
}
void AccountStorageMigrationBubbleController::ReportInteractions() {}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_ACCOUNT_STORAGE_MIGRATION_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_ACCOUNT_STORAGE_MIGRATION_BUBBLE_CONTROLLER_H_
#include "chrome/browser/ui/passwords/bubble_controllers/password_bubble_controller_base.h"
class PasswordsModelDelegate;
// This controller manages the bubble asking the user to move a local credential
// to the account storage.
class AccountStorageMigrationBubbleController
: public PasswordBubbleControllerBase {
public:
explicit AccountStorageMigrationBubbleController(
base::WeakPtr<PasswordsModelDelegate> delegate);
~AccountStorageMigrationBubbleController() override;
private:
// PasswordBubbleControllerBase:
base::string16 GetTitle() const override;
void ReportInteractions() override;
};
#endif // CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_ACCOUNT_STORAGE_MIGRATION_BUBBLE_CONTROLLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/passwords/bubble_controllers/account_storage_migration_bubble_controller.h"
#include "chrome/browser/ui/passwords/passwords_model_delegate_mock.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class AccountStorageMigrationBubbleControllerTest : public ::testing::Test {
public:
AccountStorageMigrationBubbleControllerTest() {
mock_delegate_ =
std::make_unique<testing::NiceMock<PasswordsModelDelegateMock>>();
EXPECT_CALL(*delegate(), OnBubbleShown());
controller_ = std::make_unique<AccountStorageMigrationBubbleController>(
mock_delegate_->AsWeakPtr());
EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(delegate()));
}
~AccountStorageMigrationBubbleControllerTest() override = default;
PasswordsModelDelegateMock* delegate() { return mock_delegate_.get(); }
AccountStorageMigrationBubbleController* controller() {
return controller_.get();
}
private:
std::unique_ptr<PasswordsModelDelegateMock> mock_delegate_;
std::unique_ptr<AccountStorageMigrationBubbleController> controller_;
};
TEST_F(AccountStorageMigrationBubbleControllerTest, CloseExplicictly) {
EXPECT_CALL(*delegate(), OnBubbleHidden());
controller()->OnBubbleClosing();
}
} // namespace
...@@ -4084,6 +4084,7 @@ test("unit_tests") { ...@@ -4084,6 +4084,7 @@ test("unit_tests") {
"../browser/ui/omnibox/clipboard_utils_unittest.cc", "../browser/ui/omnibox/clipboard_utils_unittest.cc",
"../browser/ui/page_info/permission_menu_model_unittest.cc", "../browser/ui/page_info/permission_menu_model_unittest.cc",
"../browser/ui/passwords/account_storage_auth_helper_unittest.cc", "../browser/ui/passwords/account_storage_auth_helper_unittest.cc",
"../browser/ui/passwords/bubble_controllers/account_storage_migration_bubble_controller_unittest.cc",
"../browser/ui/passwords/bubble_controllers/auto_sign_in_bubble_controller_unittest.cc", "../browser/ui/passwords/bubble_controllers/auto_sign_in_bubble_controller_unittest.cc",
"../browser/ui/passwords/bubble_controllers/generation_confirmation_bubble_controller_unittest.cc", "../browser/ui/passwords/bubble_controllers/generation_confirmation_bubble_controller_unittest.cc",
"../browser/ui/passwords/bubble_controllers/items_bubble_controller_unittest.cc", "../browser/ui/passwords/bubble_controllers/items_bubble_controller_unittest.cc",
......
...@@ -539,6 +539,7 @@ void PasswordFormMetricsRecorder::RecordPasswordBubbleShown( ...@@ -539,6 +539,7 @@ void PasswordFormMetricsRecorder::RecordPasswordBubbleShown(
case metrics_util::MANUAL_GENERATED_PASSWORD_CONFIRMATION: case metrics_util::MANUAL_GENERATED_PASSWORD_CONFIRMATION:
case metrics_util::AUTOMATIC_SIGNIN_TOAST: case metrics_util::AUTOMATIC_SIGNIN_TOAST:
case metrics_util::AUTOMATIC_COMPROMISED_CREDENTIALS_REMINDER: case metrics_util::AUTOMATIC_COMPROMISED_CREDENTIALS_REMINDER:
case metrics_util::AUTOMATIC_ACCOUNT_MIGRATION_PROPOSAL:
// Do nothing. // Do nothing.
return; return;
......
...@@ -31,6 +31,7 @@ enum UIDisplayDisposition { ...@@ -31,6 +31,7 @@ enum UIDisplayDisposition {
MANUAL_GENERATED_PASSWORD_CONFIRMATION, MANUAL_GENERATED_PASSWORD_CONFIRMATION,
AUTOMATIC_SAVE_UNSYNCED_CREDENTIALS_LOCALLY, AUTOMATIC_SAVE_UNSYNCED_CREDENTIALS_LOCALLY,
AUTOMATIC_COMPROMISED_CREDENTIALS_REMINDER, AUTOMATIC_COMPROMISED_CREDENTIALS_REMINDER,
AUTOMATIC_ACCOUNT_MIGRATION_PROPOSAL,
NUM_DISPLAY_DISPOSITIONS, NUM_DISPLAY_DISPOSITIONS,
}; };
......
...@@ -50565,6 +50565,9 @@ Called by update_net_trust_anchors.py.--> ...@@ -50565,6 +50565,9 @@ Called by update_net_trust_anchors.py.-->
locally"/> locally"/>
<int value="10" <int value="10"
label="Opened automatically / Notification about compromised passwords"/> label="Opened automatically / Notification about compromised passwords"/>
<int value="11"
label="Opened automatically / Proposal to move local password to
account store"/>
</enum> </enum>
<enum name="PasswordBubbleSignInPromoDismissalReason"> <enum name="PasswordBubbleSignInPromoDismissalReason">
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