Commit 79402863 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Rename PasswordPending View and Controller to SaveUpdate*

Bug: 1044034
Change-Id: Id6ddb20aa0d94c218c2c9f06a41ea0305c473e02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031404
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737325}
parent ebb83788
......@@ -1067,8 +1067,8 @@ jumbo_static_library("ui") {
"passwords/bubble_controllers/items_bubble_controller.h",
"passwords/bubble_controllers/password_bubble_controller_base.cc",
"passwords/bubble_controllers/password_bubble_controller_base.h",
"passwords/bubble_controllers/pending_bubble_controller.cc",
"passwords/bubble_controllers/pending_bubble_controller.h",
"passwords/bubble_controllers/save_update_bubble_controller.cc",
"passwords/bubble_controllers/save_update_bubble_controller.h",
"passwords/bubble_controllers/sign_in_promo_bubble_controller.cc",
"passwords/bubble_controllers/sign_in_promo_bubble_controller.h",
"passwords/credential_leak_dialog_controller.h",
......@@ -3123,8 +3123,8 @@ jumbo_static_library("ui") {
"views/passwords/password_generation_popup_view_views.h",
"views/passwords/password_items_view.cc",
"views/passwords/password_items_view.h",
"views/passwords/password_pending_view.cc",
"views/passwords/password_pending_view.h",
"views/passwords/password_save_update_view.cc",
"views/passwords/password_save_update_view.h",
"views/payments/contact_info_editor_view_controller.cc",
"views/payments/contact_info_editor_view_controller.h",
"views/payments/credit_card_editor_view_controller.cc",
......
......@@ -2,7 +2,7 @@
// 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/pending_bubble_controller.h"
#include "chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.h"
#include "base/metrics/field_trial_params.h"
#include "base/time/default_clock.h"
......@@ -88,7 +88,7 @@ bool IsSyncUser(Profile* profile) {
} // namespace
PendingBubbleController::PendingBubbleController(
SaveUpdateBubbleController::SaveUpdateBubbleController(
base::WeakPtr<PasswordsModelDelegate> delegate,
PasswordBubbleControllerBase::DisplayReason display_reason)
: PasswordBubbleControllerBase(
......@@ -151,12 +151,12 @@ PendingBubbleController::PendingBubbleController(
origin_, type, &title_);
}
PendingBubbleController::~PendingBubbleController() {
SaveUpdateBubbleController::~SaveUpdateBubbleController() {
if (!interaction_reported_)
OnBubbleClosing();
}
void PendingBubbleController::OnSaveClicked() {
void SaveUpdateBubbleController::OnSaveClicked() {
DCHECK(state_ == password_manager::ui::PENDING_PASSWORD_STATE ||
state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE);
dismissal_reason_ = metrics_util::CLICKED_SAVE;
......@@ -167,14 +167,14 @@ void PendingBubbleController::OnSaveClicked() {
}
}
void PendingBubbleController::OnNopeUpdateClicked() {
void SaveUpdateBubbleController::OnNopeUpdateClicked() {
DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, state_);
dismissal_reason_ = metrics_util::CLICKED_CANCEL;
if (delegate_)
delegate_->OnNopeUpdateClicked();
}
void PendingBubbleController::OnNeverForThisSiteClicked() {
void SaveUpdateBubbleController::OnNeverForThisSiteClicked() {
DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, state_);
dismissal_reason_ = metrics_util::CLICKED_NEVER;
if (delegate_) {
......@@ -183,7 +183,8 @@ void PendingBubbleController::OnNeverForThisSiteClicked() {
}
}
void PendingBubbleController::OnCredentialEdited(base::string16 new_username,
void SaveUpdateBubbleController::OnCredentialEdited(
base::string16 new_username,
base::string16 new_password) {
DCHECK(state_ == password_manager::ui::PENDING_PASSWORD_STATE ||
state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE);
......@@ -191,7 +192,7 @@ void PendingBubbleController::OnCredentialEdited(base::string16 new_username,
pending_password_.password_value = std::move(new_password);
}
bool PendingBubbleController::IsCurrentStateUpdate() const {
bool SaveUpdateBubbleController::IsCurrentStateUpdate() const {
DCHECK(state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
state_ == password_manager::ui::PENDING_PASSWORD_STATE);
return std::any_of(local_credentials_.begin(), local_credentials_.end(),
......@@ -201,13 +202,13 @@ bool PendingBubbleController::IsCurrentStateUpdate() const {
});
}
bool PendingBubbleController::ShouldShowFooter() const {
bool SaveUpdateBubbleController::ShouldShowFooter() const {
return (state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
state_ == password_manager::ui::PENDING_PASSWORD_STATE) &&
IsSyncUser(GetProfile());
}
int PendingBubbleController::GetTopIllustration(bool dark_mode) const {
int SaveUpdateBubbleController::GetTopIllustration(bool dark_mode) const {
if (state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
state_ == password_manager::ui::PENDING_PASSWORD_STATE) {
int image = base::GetFieldTrialParamByFeatureAsInt(
......@@ -226,7 +227,7 @@ int PendingBubbleController::GetTopIllustration(bool dark_mode) const {
return 0;
}
bool PendingBubbleController::ReplaceToShowPromotionIfNeeded() {
bool SaveUpdateBubbleController::ReplaceToShowPromotionIfNeeded() {
Profile* profile = GetProfile();
if (!profile)
return false;
......@@ -249,7 +250,7 @@ bool PendingBubbleController::ReplaceToShowPromotionIfNeeded() {
return false;
}
bool PendingBubbleController::RevealPasswords() {
bool SaveUpdateBubbleController::RevealPasswords() {
bool reveal_immediately = !password_revealing_requires_reauth_ ||
(delegate_ && delegate_->AuthenticateUser());
if (reveal_immediately)
......@@ -258,18 +259,18 @@ bool PendingBubbleController::RevealPasswords() {
}
#if defined(PASSWORD_STORE_SELECT_ENABLED)
void PendingBubbleController::OnToggleAccountStore(bool is_checked) {
void SaveUpdateBubbleController::OnToggleAccountStore(bool is_checked) {
delegate_->GetPasswordFeatureManager()->SetDefaultPasswordStore(
is_checked ? Store::kAccountStore : Store::kProfileStore);
}
bool PendingBubbleController::IsUsingAccountStore() {
bool SaveUpdateBubbleController::IsUsingAccountStore() {
return delegate_->GetPasswordFeatureManager()->GetDefaultPasswordStore() ==
Store::kAccountStore;
}
#endif // defined(PASSWORD_STORE_SELECT_ENABLED)
void PendingBubbleController::ReportInteractions() {
void SaveUpdateBubbleController::ReportInteractions() {
if (state_ == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE)
return;
DCHECK(state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
......@@ -315,6 +316,6 @@ void PendingBubbleController::ReportInteractions() {
metrics_recorder_->RecordUIDismissalReason(dismissal_reason_);
}
base::string16 PendingBubbleController::GetTitle() const {
base::string16 SaveUpdateBubbleController::GetTitle() const {
return title_;
}
......@@ -2,8 +2,8 @@
// 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_PENDING_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_PENDING_BUBBLE_CONTROLLER_H_
#ifndef CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_SAVE_UPDATE_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_SAVE_UPDATE_BUBBLE_CONTROLLER_H_
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/passwords/bubble_controllers/password_bubble_controller_base.h"
......@@ -16,13 +16,13 @@ namespace base {
class Clock;
}
// This controller provides data and actions for the PasswordPendingView.
class PendingBubbleController : public PasswordBubbleControllerBase {
// This controller provides data and actions for the PasswordSaveUpdateView.
class SaveUpdateBubbleController : public PasswordBubbleControllerBase {
public:
explicit PendingBubbleController(
explicit SaveUpdateBubbleController(
base::WeakPtr<PasswordsModelDelegate> delegate,
DisplayReason display_reason);
~PendingBubbleController() override;
~SaveUpdateBubbleController() override;
// Called by the view code when the save/update button is clicked by the user.
void OnSaveClicked();
......@@ -126,4 +126,4 @@ class PendingBubbleController : public PasswordBubbleControllerBase {
base::Clock* clock_;
};
#endif // CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_PENDING_BUBBLE_CONTROLLER_H_
#endif // CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_SAVE_UPDATE_BUBBLE_CONTROLLER_H_
......@@ -2,7 +2,7 @@
// 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/pending_bubble_controller.h"
#include "chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.h"
#include <memory>
#include <string>
......@@ -62,10 +62,10 @@ constexpr char kUIDismissalReasonUpdateMetric[] =
} // namespace
class PendingBubbleControllerTest : public ::testing::Test {
class SaveUpdateBubbleControllerTest : public ::testing::Test {
public:
PendingBubbleControllerTest() = default;
~PendingBubbleControllerTest() override = default;
SaveUpdateBubbleControllerTest() = default;
~SaveUpdateBubbleControllerTest() override = default;
void SetUp() override {
test_web_contents_ =
......@@ -105,7 +105,7 @@ class PendingBubbleControllerTest : public ::testing::Test {
PasswordsModelDelegateMock* delegate() { return mock_delegate_.get(); }
PendingBubbleController* controller() { return controller_.get(); }
SaveUpdateBubbleController* controller() { return controller_.get(); }
autofill::PasswordForm& pending_password() { return pending_password_; }
const autofill::PasswordForm& pending_password() const {
......@@ -131,12 +131,12 @@ class PendingBubbleControllerTest : public ::testing::Test {
content::RenderViewHostTestEnabler rvh_enabler_;
TestingProfile profile_;
std::unique_ptr<content::WebContents> test_web_contents_;
std::unique_ptr<PendingBubbleController> controller_;
std::unique_ptr<SaveUpdateBubbleController> controller_;
std::unique_ptr<PasswordsModelDelegateMock> mock_delegate_;
autofill::PasswordForm pending_password_;
};
void PendingBubbleControllerTest::SetUpWithState(
void SaveUpdateBubbleControllerTest::SetUpWithState(
password_manager::ui::State state,
PasswordBubbleControllerBase::DisplayReason reason) {
GURL origin(kSiteOrigin);
......@@ -146,13 +146,13 @@ void PendingBubbleControllerTest::SetUpWithState(
EXPECT_CALL(*delegate(), GetWebContents())
.WillRepeatedly(Return(test_web_contents_.get()));
controller_.reset(
new PendingBubbleController(mock_delegate_->AsWeakPtr(), reason));
new SaveUpdateBubbleController(mock_delegate_->AsWeakPtr(), reason));
ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(delegate()));
EXPECT_CALL(*delegate(), GetWebContents())
.WillRepeatedly(Return(test_web_contents_.get()));
}
void PendingBubbleControllerTest::PretendPasswordWaiting(
void SaveUpdateBubbleControllerTest::PretendPasswordWaiting(
PasswordBubbleControllerBase::DisplayReason reason) {
EXPECT_CALL(*delegate(), GetPendingPassword())
.WillOnce(ReturnRef(pending_password()));
......@@ -165,7 +165,7 @@ void PendingBubbleControllerTest::PretendPasswordWaiting(
SetUpWithState(password_manager::ui::PENDING_PASSWORD_STATE, reason);
}
void PendingBubbleControllerTest::PretendUpdatePasswordWaiting() {
void SaveUpdateBubbleControllerTest::PretendUpdatePasswordWaiting() {
EXPECT_CALL(*delegate(), GetPendingPassword())
.WillOnce(ReturnRef(pending_password()));
std::vector<std::unique_ptr<autofill::PasswordForm>> forms =
......@@ -179,7 +179,7 @@ void PendingBubbleControllerTest::PretendUpdatePasswordWaiting() {
PasswordBubbleControllerBase::DisplayReason::kAutomatic);
}
void PendingBubbleControllerTest::
void SaveUpdateBubbleControllerTest::
DestroyModelAndVerifyControllerExpectations() {
EXPECT_CALL(*delegate(), OnBubbleHidden());
controller_->OnBubbleClosing();
......@@ -187,7 +187,7 @@ void PendingBubbleControllerTest::
controller_.reset();
}
void PendingBubbleControllerTest::DestroyModelExpectReason(
void SaveUpdateBubbleControllerTest::DestroyModelExpectReason(
password_manager::metrics_util::UIDismissalReason dismissal_reason) {
base::HistogramTester histogram_tester;
password_manager::ui::State state = controller_->state();
......@@ -202,7 +202,7 @@ void PendingBubbleControllerTest::DestroyModelExpectReason(
// static
password_manager::InteractionsStats
PendingBubbleControllerTest::GetTestStats() {
SaveUpdateBubbleControllerTest::GetTestStats() {
password_manager::InteractionsStats result;
result.origin_domain = GURL(kSiteOrigin).GetOrigin();
result.username_value = base::ASCIIToUTF16(kUsername);
......@@ -212,7 +212,7 @@ PendingBubbleControllerTest::GetTestStats() {
}
std::vector<std::unique_ptr<autofill::PasswordForm>>
PendingBubbleControllerTest::GetCurrentForms() const {
SaveUpdateBubbleControllerTest::GetCurrentForms() const {
autofill::PasswordForm form(pending_password());
form.username_value = base::ASCIIToUTF16(kUsernameExisting);
form.password_value = base::ASCIIToUTF16("123456");
......@@ -227,7 +227,7 @@ PendingBubbleControllerTest::GetCurrentForms() const {
return forms;
}
TEST_F(PendingBubbleControllerTest, CloseWithoutInteraction) {
TEST_F(SaveUpdateBubbleControllerTest, CloseWithoutInteraction) {
PretendPasswordWaiting();
EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE,
......@@ -247,7 +247,7 @@ TEST_F(PendingBubbleControllerTest, CloseWithoutInteraction) {
password_manager::metrics_util::NO_DIRECT_INTERACTION);
}
TEST_F(PendingBubbleControllerTest, ClickSave) {
TEST_F(SaveUpdateBubbleControllerTest, ClickSave) {
PretendPasswordWaiting();
EXPECT_TRUE(controller()->enable_editing());
......@@ -263,7 +263,7 @@ TEST_F(PendingBubbleControllerTest, ClickSave) {
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_SAVE);
}
TEST_F(PendingBubbleControllerTest, ClickSaveInUpdateState) {
TEST_F(SaveUpdateBubbleControllerTest, ClickSaveInUpdateState) {
PretendUpdatePasswordWaiting();
// Edit username, now it's a new credential.
......@@ -280,7 +280,7 @@ TEST_F(PendingBubbleControllerTest, ClickSaveInUpdateState) {
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_SAVE);
}
TEST_F(PendingBubbleControllerTest, ClickNever) {
TEST_F(SaveUpdateBubbleControllerTest, ClickNever) {
PretendPasswordWaiting();
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
......@@ -292,7 +292,7 @@ TEST_F(PendingBubbleControllerTest, ClickNever) {
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_NEVER);
}
TEST_F(PendingBubbleControllerTest, ClickUpdate) {
TEST_F(SaveUpdateBubbleControllerTest, ClickUpdate) {
PretendUpdatePasswordWaiting();
EXPECT_TRUE(controller()->enable_editing());
......@@ -308,7 +308,7 @@ TEST_F(PendingBubbleControllerTest, ClickUpdate) {
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_SAVE);
}
TEST_F(PendingBubbleControllerTest, ClickUpdateInSaveState) {
TEST_F(SaveUpdateBubbleControllerTest, ClickUpdateInSaveState) {
PretendPasswordWaiting();
// Edit username, now it's an existing credential.
......@@ -325,13 +325,13 @@ TEST_F(PendingBubbleControllerTest, ClickUpdateInSaveState) {
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_SAVE);
}
TEST_F(PendingBubbleControllerTest, GetInitialUsername_MatchedUsername) {
TEST_F(SaveUpdateBubbleControllerTest, GetInitialUsername_MatchedUsername) {
PretendUpdatePasswordWaiting();
EXPECT_EQ(base::UTF8ToUTF16(kUsername),
controller()->pending_password().username_value);
}
TEST_F(PendingBubbleControllerTest, EditCredential) {
TEST_F(SaveUpdateBubbleControllerTest, EditCredential) {
PretendPasswordWaiting();
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
......@@ -347,7 +347,7 @@ TEST_F(PendingBubbleControllerTest, EditCredential) {
DestroyModelAndVerifyControllerExpectations();
}
TEST_F(PendingBubbleControllerTest, SuppressSignInPromo) {
TEST_F(SaveUpdateBubbleControllerTest, SuppressSignInPromo) {
prefs()->SetBoolean(password_manager::prefs::kSignInPasswordPromoRevive,
true);
prefs()->SetBoolean(password_manager::prefs::kWasSignInPasswordPromoClicked,
......@@ -362,7 +362,7 @@ TEST_F(PendingBubbleControllerTest, SuppressSignInPromo) {
DestroyModelAndVerifyControllerExpectations();
}
TEST_F(PendingBubbleControllerTest, SignInPromoOK) {
TEST_F(SaveUpdateBubbleControllerTest, SignInPromoOK) {
base::HistogramTester histogram_tester;
PretendPasswordWaiting();
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
......@@ -378,7 +378,7 @@ TEST_F(PendingBubbleControllerTest, SignInPromoOK) {
}
#if !defined(OS_CHROMEOS)
TEST_F(PendingBubbleControllerTest, SignInPromoCancel) {
TEST_F(SaveUpdateBubbleControllerTest, SignInPromoCancel) {
base::HistogramTester histogram_tester;
PretendPasswordWaiting();
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
......@@ -393,7 +393,7 @@ TEST_F(PendingBubbleControllerTest, SignInPromoCancel) {
password_manager::metrics_util::CLICKED_SAVE, 1);
}
TEST_F(PendingBubbleControllerTest, SignInPromoDismiss) {
TEST_F(SaveUpdateBubbleControllerTest, SignInPromoDismiss) {
base::HistogramTester histogram_tester;
PretendPasswordWaiting();
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
......@@ -412,7 +412,7 @@ TEST_F(PendingBubbleControllerTest, SignInPromoDismiss) {
#endif // !defined(OS_CHROMEOS)
// Verify that URL keyed metrics are properly recorded.
TEST_F(PendingBubbleControllerTest, RecordUKMs) {
TEST_F(SaveUpdateBubbleControllerTest, RecordUKMs) {
using BubbleDismissalReason =
password_manager::PasswordFormMetricsRecorder::BubbleDismissalReason;
using BubbleTrigger =
......@@ -522,15 +522,15 @@ TEST_F(PendingBubbleControllerTest, RecordUKMs) {
}
}
class PendingBubbleControllerPasswordRevealingTest
: public PendingBubbleControllerTest,
class SaveUpdateBubbleControllerPasswordRevealingTest
: public SaveUpdateBubbleControllerTest,
public testing::WithParamInterface<
std::tuple<bool /*is manual fallback*/,
bool /*form has autofilled value*/,
bool /*does os support user authentication*/,
PasswordBubbleControllerBase::DisplayReason>> {};
TEST_P(PendingBubbleControllerPasswordRevealingTest,
TEST_P(SaveUpdateBubbleControllerPasswordRevealingTest,
EyeIcon_ReauthForPasswordsRevealing) {
bool is_manual_fallback_for_saving = std::get<0>(GetParam());
bool form_has_autofilled_value = std::get<1>(GetParam());
......@@ -584,8 +584,8 @@ TEST_P(PendingBubbleControllerPasswordRevealingTest,
}
INSTANTIATE_TEST_SUITE_P(
PendingBubbleController,
PendingBubbleControllerPasswordRevealingTest,
SaveUpdateBubbleController,
SaveUpdateBubbleControllerPasswordRevealingTest,
testing::Combine(
testing::Bool(),
testing::Bool(),
......@@ -594,7 +594,7 @@ INSTANTIATE_TEST_SUITE_P(
PasswordBubbleControllerBase::DisplayReason::kAutomatic,
PasswordBubbleControllerBase::DisplayReason::kUserAction)));
TEST_F(PendingBubbleControllerTest, EyeIcon_BubbleReopenedAfterAuth) {
TEST_F(SaveUpdateBubbleControllerTest, EyeIcon_BubbleReopenedAfterAuth) {
// Checks re-authentication is not needed if the bubble is opened right after
// successful authentication.
pending_password().form_has_autofilled_value = true;
......@@ -608,14 +608,14 @@ TEST_F(PendingBubbleControllerTest, EyeIcon_BubbleReopenedAfterAuth) {
EXPECT_TRUE(controller()->RevealPasswords());
}
TEST_F(PendingBubbleControllerTest, PasswordsRevealedReported) {
TEST_F(SaveUpdateBubbleControllerTest, PasswordsRevealedReported) {
PretendPasswordWaiting();
EXPECT_CALL(*delegate(), OnPasswordsRevealed());
EXPECT_TRUE(controller()->RevealPasswords());
}
TEST_F(PendingBubbleControllerTest, PasswordsRevealedReportedAfterReauth) {
TEST_F(SaveUpdateBubbleControllerTest, PasswordsRevealedReportedAfterReauth) {
// The bubble is opened after reauthentication and the passwords are revealed.
pending_password().form_has_autofilled_value = true;
// After successful authentication this value is set to true.
......@@ -626,7 +626,7 @@ TEST_F(PendingBubbleControllerTest, PasswordsRevealedReportedAfterReauth) {
PasswordBubbleControllerBase::DisplayReason::kUserAction);
}
TEST_F(PendingBubbleControllerTest, DisableEditing) {
TEST_F(SaveUpdateBubbleControllerTest, DisableEditing) {
EXPECT_CALL(*delegate(), BubbleIsManualFallbackForSaving())
.WillRepeatedly(Return(false));
EXPECT_CALL(*delegate(), GetCredentialSource())
......
......@@ -22,7 +22,7 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
#include "chrome/browser/ui/views/passwords/password_auto_sign_in_view.h"
#include "chrome/browser/ui/views/passwords/password_pending_view.h"
#include "chrome/browser/ui/views/passwords/password_save_update_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
......@@ -82,7 +82,8 @@ IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, BasicOpenAndClose) {
EXPECT_FALSE(IsBubbleShowing());
SetupPendingPassword();
EXPECT_TRUE(IsBubbleShowing());
const PasswordPendingView* bubble = static_cast<const PasswordPendingView*>(
const PasswordSaveUpdateView* bubble =
static_cast<const PasswordSaveUpdateView*>(
PasswordBubbleViewBase::manage_password_bubble());
EXPECT_FALSE(bubble->GetFocusManager()->GetFocusedView());
PasswordBubbleViewBase::CloseCurrentBubble();
......@@ -97,7 +98,7 @@ IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, BasicOpenAndClose) {
browser()->tab_strip_model()->GetActiveWebContents())
->ShowManagePasswordsBubble(true /* user_action */);
EXPECT_TRUE(IsBubbleShowing());
bubble = static_cast<const PasswordPendingView*>(
bubble = static_cast<const PasswordSaveUpdateView*>(
PasswordBubbleViewBase::manage_password_bubble());
// A pending password with empty username should initially focus on the
// username field.
......
......@@ -14,7 +14,7 @@
#include "chrome/browser/ui/views/passwords/password_auto_sign_in_view.h"
#include "chrome/browser/ui/views/passwords/password_generation_confirmation_view.h"
#include "chrome/browser/ui/views/passwords/password_items_view.h"
#include "chrome/browser/ui/views/passwords/password_pending_view.h"
#include "chrome/browser/ui/views/passwords/password_save_update_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/password_manager/core/common/password_manager_features.h"
......@@ -71,7 +71,7 @@ PasswordBubbleViewBase* PasswordBubbleViewBase::CreateBubble(
} else if (model_state ==
password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
model_state == password_manager::ui::PENDING_PASSWORD_STATE) {
view = new PasswordPendingView(web_contents, anchor_view, reason);
view = new PasswordSaveUpdateView(web_contents, anchor_view, reason);
} else {
NOTREACHED();
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/passwords/password_pending_view.h"
#include "chrome/browser/ui/views/passwords/password_save_update_view.h"
#include <algorithm>
#include <memory>
......@@ -49,7 +49,7 @@
namespace {
enum PasswordPendingViewColumnSetType {
enum PasswordSaveUpdateViewColumnSetType {
// | | (LEADING, FILL) | | (FILL, FILL) | |
// Used for the username/password line of the bubble, for the pending view.
DOUBLE_VIEW_COLUMN_SET_USERNAME,
......@@ -64,7 +64,7 @@ enum PasswordPendingViewColumnSetType {
// Construct an appropriate ColumnSet for the given |type|, and add it
// to |layout|.
void BuildColumnSet(views::GridLayout* layout,
PasswordPendingViewColumnSetType type) {
PasswordSaveUpdateViewColumnSetType type) {
views::ColumnSet* column_set = layout->AddColumnSet(type);
const int column_divider = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_HORIZONTAL);
......@@ -132,8 +132,8 @@ void BuildCredentialRows(
DISTANCE_CONTROL_LIST_VERTICAL));
// Password row.
PasswordPendingViewColumnSetType type = password_view_button
? TRIPLE_VIEW_COLUMN_SET
PasswordSaveUpdateViewColumnSetType type =
password_view_button ? TRIPLE_VIEW_COLUMN_SET
: DOUBLE_VIEW_COLUMN_SET_PASSWORD;
BuildColumnSet(layout, type);
layout->StartRow(views::GridLayout::kFixedSize, type);
......@@ -247,7 +247,8 @@ views::Checkbox* MaybeAppendAccountCheckboxRow(
} // namespace
PasswordPendingView::PasswordPendingView(content::WebContents* web_contents,
PasswordSaveUpdateView::PasswordSaveUpdateView(
content::WebContents* web_contents,
views::View* anchor_view,
DisplayReason reason)
: PasswordBubbleViewBase(web_contents,
......@@ -316,21 +317,22 @@ PasswordPendingView::PasswordPendingView(content::WebContents* web_contents,
UpdateDialogButtons();
}
views::View* PasswordPendingView::GetUsernameTextfieldForTest() const {
views::View* PasswordSaveUpdateView::GetUsernameTextfieldForTest() const {
return username_dropdown_->GetTextfieldForTest();
}
PasswordPendingView::~PasswordPendingView() = default;
PasswordSaveUpdateView::~PasswordSaveUpdateView() = default;
PasswordBubbleControllerBase* PasswordPendingView::GetController() {
PasswordBubbleControllerBase* PasswordSaveUpdateView::GetController() {
return &controller_;
}
const PasswordBubbleControllerBase* PasswordPendingView::GetController() const {
const PasswordBubbleControllerBase* PasswordSaveUpdateView::GetController()
const {
return &controller_;
}
bool PasswordPendingView::Accept() {
bool PasswordSaveUpdateView::Accept() {
UpdateUsernameAndPasswordInModel();
controller_.OnSaveClicked();
if (controller_.ReplaceToShowPromotionIfNeeded()) {
......@@ -340,7 +342,7 @@ bool PasswordPendingView::Accept() {
return true;
}
bool PasswordPendingView::Cancel() {
bool PasswordSaveUpdateView::Cancel() {
UpdateUsernameAndPasswordInModel();
if (is_update_bubble_) {
controller_.OnNopeUpdateClicked();
......@@ -350,11 +352,11 @@ bool PasswordPendingView::Cancel() {
return true;
}
bool PasswordPendingView::Close() {
bool PasswordSaveUpdateView::Close() {
return true;
}
void PasswordPendingView::ButtonPressed(views::Button* sender,
void PasswordSaveUpdateView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
#if defined(PASSWORD_STORE_SELECT_ENABLED)
DCHECK(sender);
......@@ -367,7 +369,7 @@ void PasswordPendingView::ButtonPressed(views::Button* sender,
TogglePasswordVisibility();
}
void PasswordPendingView::OnContentChanged(
void PasswordSaveUpdateView::OnContentChanged(
views::EditableCombobox* editable_combobox) {
bool is_update_state_before = controller_.IsCurrentStateUpdate();
bool is_ok_button_enabled_before =
......@@ -385,14 +387,14 @@ void PasswordPendingView::OnContentChanged(
}
}
gfx::Size PasswordPendingView::CalculatePreferredSize() const {
gfx::Size PasswordSaveUpdateView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
views::View* PasswordPendingView::GetInitiallyFocusedView() {
views::View* PasswordSaveUpdateView::GetInitiallyFocusedView() {
if (username_dropdown_ && username_dropdown_->GetText().empty())
return username_dropdown_;
View* initial_view = PasswordBubbleViewBase::GetInitiallyFocusedView();
......@@ -404,37 +406,38 @@ views::View* PasswordPendingView::GetInitiallyFocusedView() {
return (initial_view && initial_view->IsFocusable()) ? initial_view : nullptr;
}
bool PasswordPendingView::IsDialogButtonEnabled(ui::DialogButton button) const {
bool PasswordSaveUpdateView::IsDialogButtonEnabled(
ui::DialogButton button) const {
return button != ui::DIALOG_BUTTON_OK ||
controller_.pending_password().IsFederatedCredential() ||
!controller_.pending_password().password_value.empty();
}
gfx::ImageSkia PasswordPendingView::GetWindowIcon() {
gfx::ImageSkia PasswordSaveUpdateView::GetWindowIcon() {
return gfx::ImageSkia();
}
bool PasswordPendingView::ShouldShowWindowIcon() const {
bool PasswordSaveUpdateView::ShouldShowWindowIcon() const {
return false;
}
bool PasswordPendingView::ShouldShowCloseButton() const {
bool PasswordSaveUpdateView::ShouldShowCloseButton() const {
return true;
}
void PasswordPendingView::AddedToWidget() {
void PasswordSaveUpdateView::AddedToWidget() {
static_cast<views::Label*>(GetBubbleFrameView()->title())
->SetAllowCharacterBreak(true);
}
void PasswordPendingView::OnThemeChanged() {
void PasswordSaveUpdateView::OnThemeChanged() {
if (int id = controller_.GetTopIllustration(
color_utils::IsDark(GetBubbleFrameView()->GetBackgroundColor()))) {
GetBubbleFrameView()->SetHeaderView(CreateHeaderImage(id));
}
}
void PasswordPendingView::TogglePasswordVisibility() {
void PasswordSaveUpdateView::TogglePasswordVisibility() {
if (!are_passwords_revealed_ && !controller_.RevealPasswords())
return;
......@@ -444,7 +447,7 @@ void PasswordPendingView::TogglePasswordVisibility() {
password_dropdown_->RevealPasswords(are_passwords_revealed_);
}
void PasswordPendingView::UpdateUsernameAndPasswordInModel() {
void PasswordSaveUpdateView::UpdateUsernameAndPasswordInModel() {
if (!username_dropdown_ && !password_dropdown_)
return;
base::string16 new_username = controller_.pending_password().username_value;
......@@ -459,7 +462,7 @@ void PasswordPendingView::UpdateUsernameAndPasswordInModel() {
std::move(new_password));
}
void PasswordPendingView::ReplaceWithPromo() {
void PasswordSaveUpdateView::ReplaceWithPromo() {
#if defined(OS_CHROMEOS)
NOTREACHED();
#else
......@@ -488,7 +491,7 @@ void PasswordPendingView::ReplaceWithPromo() {
#endif // defined(OS_CHROMEOS)
}
void PasswordPendingView::UpdateDialogButtons() {
void PasswordSaveUpdateView::UpdateDialogButtons() {
if (sign_in_promo_) {
DialogDelegate::set_buttons(ui::DIALOG_BUTTON_NONE);
return;
......@@ -507,7 +510,7 @@ void PasswordPendingView::UpdateDialogButtons() {
: IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON));
}
std::unique_ptr<views::View> PasswordPendingView::CreateFooterView() {
std::unique_ptr<views::View> PasswordSaveUpdateView::CreateFooterView() {
if (!controller_.ShouldShowFooter())
return nullptr;
auto label = std::make_unique<views::Label>(
......
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_PENDING_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_PENDING_VIEW_H_
#ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_SAVE_UPDATE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_SAVE_UPDATE_VIEW_H_
#include "chrome/browser/ui/passwords/bubble_controllers/pending_bubble_controller.h"
#include "chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.h"
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/editable_combobox/editable_combobox_listener.h"
......@@ -25,18 +25,18 @@ class PasswordSignInPromoView;
// A view offering the user the ability to save or update credentials (depending
// on |is_update_bubble|). Contains a username and password field, along with a
// "Save"/"Update" button and a "Never"/"Nope" button.
class PasswordPendingView : public PasswordBubbleViewBase,
class PasswordSaveUpdateView : public PasswordBubbleViewBase,
public views::ButtonListener,
public views::EditableComboboxListener {
public:
PasswordPendingView(content::WebContents* web_contents,
PasswordSaveUpdateView(content::WebContents* web_contents,
views::View* anchor_view,
DisplayReason reason);
views::View* GetUsernameTextfieldForTest() const;
private:
~PasswordPendingView() override;
~PasswordSaveUpdateView() override;
// PasswordBubbleViewBase
PasswordBubbleControllerBase* GetController() override;
......@@ -70,7 +70,7 @@ class PasswordPendingView : public PasswordBubbleViewBase,
void UpdateDialogButtons();
std::unique_ptr<views::View> CreateFooterView();
PendingBubbleController controller_;
SaveUpdateBubbleController controller_;
// True iff it is an update password bubble on creation. False iff it is a
// save bubble.
......@@ -92,8 +92,6 @@ class PasswordPendingView : public PasswordBubbleViewBase,
#endif // defined(PASSWORD_STORE_SELECT_ENABLED)
bool are_passwords_revealed_;
DISALLOW_COPY_AND_ASSIGN(PasswordPendingView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_PENDING_VIEW_H_
#endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_SAVE_UPDATE_VIEW_H_
......@@ -4058,7 +4058,7 @@ test("unit_tests") {
"../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/items_bubble_controller_unittest.cc",
"../browser/ui/passwords/bubble_controllers/pending_bubble_controller_unittest.cc",
"../browser/ui/passwords/bubble_controllers/save_update_bubble_controller_unittest.cc",
"../browser/ui/passwords/bubble_controllers/sign_in_promo_bubble_controller_unittest.cc",
"../browser/ui/passwords/credential_leak_dialog_controller_impl_unittest.cc",
"../browser/ui/passwords/credential_manager_dialog_controller_impl_unittest.cc",
......
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