Commit 397b6d8a authored by Pavel Yatsuk's avatar Pavel Yatsuk Committed by Chromium LUCI CQ

[Messages] Update Clank save password title and description

This CL updates Clank save password message's title and description to
match the spec and iOS behavior: https://docs.google.com/presentation/d/1g1kh48QQI83Smn6Nyq0AaRJ8ZVcURagRgIrZh02dF00/edit#slide=id.g88ba208385_0_43

The title depends on whether the user has enabled password sync.
The description contains username and masked password.

R=lazzzis@chromium.org
BUG=1153925

Change-Id: Ideefa29e86d6f710012d82f440e38b7fe9073b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2564329Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833748}
parent 20601a35
...@@ -4927,6 +4927,12 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -4927,6 +4927,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_UPDATE_PASSWORD_DIFFERENT_DOMAINS_TITLE" desc="The title of the update password bubble when the submitted form origin isn't equal to saved credentials origin."> <message name="IDS_UPDATE_PASSWORD_DIFFERENT_DOMAINS_TITLE" desc="The title of the update password bubble when the submitted form origin isn't equal to saved credentials origin.">
Update password for <ph name="ORIGIN">$1<ex>example.com</ex></ph>? Update password for <ph name="ORIGIN">$1<ex>example.com</ex></ph>?
</message> </message>
<message name="IDS_SAVE_PASSWORD_TO_GOOGLE" desc="The title of the save password bubble when the user syncs passswors to thir Google account.">
Save password to your Google Account?
</message>
<message name="IDS_SAVE_ACCOUNT_TO_GOOGLE" desc="The title of the save password bubble when a federated credential can be saved to the user's Google account.">
Save username to your Google Account?
</message>
<message name="IDS_SAVE_PASSWORD_FOOTER" desc="The footer text of the bubble that offers user to save a password to Chrome."> <message name="IDS_SAVE_PASSWORD_FOOTER" desc="The footer text of the bubble that offers user to save a password to Chrome.">
Passwords are saved in your Google Account so you can use them on any device Passwords are saved in your Google Account so you can use them on any device
</message> </message>
......
d82dbe45f91b7573060266d89e8d5d7a91923458
\ No newline at end of file
b53a8f296fc56d2e618e646ced5095d95857fefc
\ No newline at end of file
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
#include "chrome/browser/password_manager/android/save_password_message_delegate.h" #include "chrome/browser/password_manager/android/save_password_message_delegate.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/android/android_theme_resources.h" #include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/android/resource_mapper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/messages/android/message_dispatcher_bridge.h" #include "components/messages/android/message_dispatcher_bridge.h"
#include "components/password_manager/core/browser/password_bubble_experiment.h" #include "components/password_manager/core/browser/password_bubble_experiment.h"
...@@ -63,18 +63,25 @@ void SavePasswordMessageDelegate::CreateMessage( ...@@ -63,18 +63,25 @@ void SavePasswordMessageDelegate::CreateMessage(
base::BindOnce(&SavePasswordMessageDelegate::HandleDismissCallback, base::BindOnce(&SavePasswordMessageDelegate::HandleDismissCallback,
base::Unretained(this))); base::Unretained(this)));
PasswordTitleType type = const password_manager::PasswordForm& pending_credentials =
form_to_save_->GetPendingCredentials().federation_origin.opaque() form_to_save_->GetPendingCredentials();
? PasswordTitleType::SAVE_PASSWORD
: PasswordTitleType::SAVE_ACCOUNT; int title_message_id = 0;
if (!pending_credentials.federation_origin.opaque()) {
message_->SetTitle(GetSavePasswordDialogTitleText( title_message_id = is_saving_google_account ? IDS_SAVE_ACCOUNT_TO_GOOGLE
web_contents_->GetVisibleURL(), : IDS_SAVE_ACCOUNT;
url::Origin::Create(form_to_save_->GetURL()), type)); } else {
if (type == PasswordTitleType::SAVE_PASSWORD && is_saving_google_account) { title_message_id = is_saving_google_account ? IDS_SAVE_PASSWORD_TO_GOOGLE
message_->SetDescription( : IDS_SAVE_PASSWORD;
l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_FOOTER));
} }
message_->SetTitle(l10n_util::GetStringUTF16(title_message_id));
base::string16 description = pending_credentials.username_value;
description.append(base::ASCIIToUTF16(" "))
.append(pending_credentials.password_value.size(), L'•');
message_->SetDescription(description);
message_->SetPrimaryButtonText( message_->SetPrimaryButtonText(
l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON));
message_->SetIconResourceId( message_->SetIconResourceId(
......
...@@ -28,8 +28,8 @@ using password_manager::PasswordFormMetricsRecorder; ...@@ -28,8 +28,8 @@ using password_manager::PasswordFormMetricsRecorder;
namespace { namespace {
constexpr char kDefaultUrl[] = "http://example.com"; constexpr char kDefaultUrl[] = "http://example.com";
constexpr char kAlternativeUrl[] = "http://bar.com"; constexpr char kUsername[] = "username";
constexpr char kAlternativeUrlHost[] = "bar.com"; constexpr char kPassword[] = "password";
constexpr char kDismissalReasonHistogramName[] = constexpr char kDismissalReasonHistogramName[] =
"PasswordManager.SaveUIDismissalReason"; "PasswordManager.SaveUIDismissalReason";
} // namespace } // namespace
...@@ -43,6 +43,7 @@ class SavePasswordMessageDelegateTest : public ChromeRenderViewHostTestHarness { ...@@ -43,6 +43,7 @@ class SavePasswordMessageDelegateTest : public ChromeRenderViewHostTestHarness {
std::unique_ptr<MockPasswordFormManagerForUI> CreateFormManager( std::unique_ptr<MockPasswordFormManagerForUI> CreateFormManager(
const GURL& url); const GURL& url);
void SetUsernameAndPassword(base::string16 username, base::string16 password);
void CreateMessage(std::unique_ptr<PasswordFormManagerForUI> form_to_save, void CreateMessage(std::unique_ptr<PasswordFormManagerForUI> form_to_save,
bool is_saving_google_account); bool is_saving_google_account);
...@@ -89,6 +90,13 @@ SavePasswordMessageDelegateTest::CreateFormManager( ...@@ -89,6 +90,13 @@ SavePasswordMessageDelegateTest::CreateFormManager(
return form_manager; return form_manager;
} }
void SavePasswordMessageDelegateTest::SetUsernameAndPassword(
base::string16 username,
base::string16 password) {
form_.username_value = std::move(username);
form_.password_value = std::move(password);
}
void SavePasswordMessageDelegateTest::CreateMessage( void SavePasswordMessageDelegateTest::CreateMessage(
std::unique_ptr<PasswordFormManagerForUI> form_to_save, std::unique_ptr<PasswordFormManagerForUI> form_to_save,
bool is_saving_google_account) { bool is_saving_google_account) {
...@@ -134,12 +142,18 @@ void SavePasswordMessageDelegateTest::VerifyUkmMetrics( ...@@ -134,12 +142,18 @@ void SavePasswordMessageDelegateTest::VerifyUkmMetrics(
// Tests that message properties (title, description, icon, button text) are // Tests that message properties (title, description, icon, button text) are
// set correctly. // set correctly.
TEST_F(SavePasswordMessageDelegateTest, MessagePropertyValues) { TEST_F(SavePasswordMessageDelegateTest, MessagePropertyValues) {
SetUsernameAndPassword(base::ASCIIToUTF16(kUsername),
base::ASCIIToUTF16(kPassword));
auto form_manager = CreateFormManager(GURL(kDefaultUrl)); auto form_manager = CreateFormManager(GURL(kDefaultUrl));
CreateMessage(std::move(form_manager), false /*is_saving_google_account*/); CreateMessage(std::move(form_manager), false /*is_saving_google_account*/);
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD), EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD),
GetMessageWrapper()->GetTitle()); GetMessageWrapper()->GetTitle());
EXPECT_EQ(base::string16(), GetMessageWrapper()->GetDescription()); EXPECT_NE(base::string16::npos, GetMessageWrapper()->GetDescription().find(
base::ASCIIToUTF16(kUsername)));
EXPECT_EQ(base::string16::npos, GetMessageWrapper()->GetDescription().find(
base::ASCIIToUTF16(kPassword)));
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON), EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON),
GetMessageWrapper()->GetPrimaryButtonText()); GetMessageWrapper()->GetPrimaryButtonText());
EXPECT_EQ( EXPECT_EQ(
...@@ -149,28 +163,14 @@ TEST_F(SavePasswordMessageDelegateTest, MessagePropertyValues) { ...@@ -149,28 +163,14 @@ TEST_F(SavePasswordMessageDelegateTest, MessagePropertyValues) {
TriggerMessageDismissedCallback(); TriggerMessageDismissedCallback();
} }
// Tests that the description is set correctly when user is syncing passwords to // Tests that the title is set correctly when the user is syncing passwords to
// their Google Account. // their Google Account.
TEST_F(SavePasswordMessageDelegateTest, SaveToGoogleDescription) { TEST_F(SavePasswordMessageDelegateTest, SaveToGoogleTitle) {
auto form_manager = CreateFormManager(GURL(kDefaultUrl)); auto form_manager = CreateFormManager(GURL(kDefaultUrl));
CreateMessage(std::move(form_manager), true /*is_saving_google_account*/); CreateMessage(std::move(form_manager), true /*is_saving_google_account*/);
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_FOOTER), EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_TO_GOOGLE),
GetMessageWrapper()->GetDescription());
TriggerMessageDismissedCallback();
}
// Tests that the title is set correctly when form domain differs from current
// page domain.
TEST_F(SavePasswordMessageDelegateTest, TitleForDifferentDomainPassword) {
auto form_manager = CreateFormManager(GURL(kAlternativeUrl));
CreateMessage(std::move(form_manager), false /*is_saving_google_account*/);
EXPECT_NE(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD),
GetMessageWrapper()->GetTitle()); GetMessageWrapper()->GetTitle());
EXPECT_NE(base::string16::npos, GetMessageWrapper()->GetTitle().find(
base::ASCIIToUTF16(kAlternativeUrlHost)));
TriggerMessageDismissedCallback(); TriggerMessageDismissedCallback();
} }
......
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