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