Commit 32e62489 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Add a footer to the password bubble.

The CL is a next stage of removing "Smart Lock" branch from the password UI.
We do the following:
- Change the behavior of IsSmartLockUser().
Those syncing with the custom passphrase should see the same UI as normal sync users.
- Use "passwords.google.com" site from the string resource instead of the constant.
Thus, it's possible to change it via Finch.
- Add a footer to the save/update password bubble.
For signed-in users it clarifies that the credentials are stored in the Google Account.

TBR=hcarmona@chromium.org

Bug: 865437,862269
Change-Id: I3a58e26319191b0e24fbc1ac793d6028b1828e1e
Reviewed-on: https://chromium-review.googlesource.com/1146648
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577819}
parent 956601bc
......@@ -21,10 +21,10 @@
#include "base/task_scheduler/post_task.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/grit/generated_resources.h"
#include "components/autofill/core/common/password_form.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/password_manager/core/browser/export/password_csv_writer.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/password_manager/core/browser/password_ui_utils.h"
#include "components/password_manager/core/browser/ui/credential_provider_interface.h"
#include "content/public/browser/browser_thread.h"
......@@ -189,8 +189,8 @@ void PasswordUIViewAndroid::HandleSerializePasswords(
ScopedJavaLocalRef<jstring> JNI_PasswordUIView_GetAccountDashboardURL(
JNIEnv* env,
const JavaParamRef<jclass>&) {
return ConvertUTF8ToJavaString(
env, password_manager::kPasswordManagerAccountDashboardURL);
return ConvertUTF16ToJavaString(
env, l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK));
}
// static
......
......@@ -8,19 +8,22 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/android/preferences/preferences_launcher.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_manager.h"
#include "components/password_manager/core/browser/password_bubble_experiment.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
GeneratedPasswordSavedInfoBarDelegateAndroid::
~GeneratedPasswordSavedInfoBarDelegateAndroid() {}
void GeneratedPasswordSavedInfoBarDelegateAndroid::OnInlineLinkClicked() {
chrome::android::PreferencesLauncher::ShowPasswordSettings();
GURL dashboard_link(l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK));
infobar()->owner()->OpenURL(dashboard_link,
WindowOpenDisposition::NEW_FOREGROUND_TAB);
}
GeneratedPasswordSavedInfoBarDelegateAndroid::
......
......@@ -60,7 +60,7 @@ std::vector<autofill::PasswordForm> DeepCopyForms(
return result;
}
bool IsSmartLockUser(Profile* profile) {
bool IsSyncUser(Profile* profile) {
const browser_sync::ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile);
return password_bubble_experiment::IsSmartLockUser(sync_service);
......@@ -464,6 +464,14 @@ bool ManagePasswordsBubbleModel::IsCurrentStateUpdate() const {
});
}
bool ManagePasswordsBubbleModel::ShouldShowFooter() const {
return (state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
state_ == password_manager::ui::PENDING_PASSWORD_STATE) &&
IsSyncUser(GetProfile()) &&
// TODO(crbug.com/862269): Remove when "Smart Lock" is gone.
pending_password_.federation_origin.unique();
}
const base::string16& ManagePasswordsBubbleModel::GetCurrentUsername() const {
return pending_password_.username_value;
}
......@@ -528,7 +536,7 @@ void ManagePasswordsBubbleModel::UpdatePendingStateTitle() {
? PasswordTitleType::SAVE_PASSWORD
: PasswordTitleType::SAVE_ACCOUNT);
GetSavePasswordDialogTitleTextAndLinkRange(
GetWebContents()->GetVisibleURL(), origin_, IsSmartLockUser(GetProfile()),
GetWebContents()->GetVisibleURL(), origin_, IsSyncUser(GetProfile()),
type, &title_, &title_brand_link_range_);
}
......
......@@ -71,6 +71,7 @@ class ManagePasswordsBubbleModel {
void OnNavigateToPasswordManagerAccountDashboardLinkClicked();
// Called by the view code when the brand name link is clicked by the user.
// TODO(crbug.com/862269): Remove when "Smart Lock" is gone.
void OnBrandLinkClicked();
// Called by the view code when the auto-signin toast is about to close due to
......@@ -137,6 +138,10 @@ class ManagePasswordsBubbleModel {
// creation. This method returns true iff the current state is "update".
bool IsCurrentStateUpdate() const;
// Returns true iff the bubble is supposed to show the footer about syncing
// to Google account.
bool ShouldShowFooter() const;
// Returns the value for the username field when the bubble is opened.
const base::string16& GetCurrentUsername() const;
......
......@@ -28,6 +28,7 @@
#include "chrome/browser/ui/passwords/password_dialog_prompts.h"
#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/browser_save_password_progress_logger.h"
#include "components/password_manager/core/browser/password_bubble_experiment.h"
#include "components/password_manager/core/browser/password_form_manager_for_ui.h"
......@@ -35,6 +36,7 @@
#include "components/password_manager/core/browser/statistics_table.h"
#include "components/password_manager/core/common/credential_manager_types.h"
#include "content/public/browser/navigation_handle.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_WIN)
#include "chrome/browser/password_manager/password_manager_util_win.h"
......@@ -464,10 +466,9 @@ void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() {
}
void ManagePasswordsUIController::NavigateToPasswordManagerAccountDashboard() {
NavigateParams params(
chrome::FindBrowserWithWebContents(web_contents()),
GURL(password_manager::kPasswordManagerAccountDashboardURL),
ui::PAGE_TRANSITION_LINK);
GURL dashboard_link(l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK));
NavigateParams params(chrome::FindBrowserWithWebContents(web_contents()),
dashboard_link, ui::PAGE_TRANSITION_LINK);
params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
Navigate(&params);
}
......
......@@ -26,6 +26,7 @@ class PasswordGenerationPopupController
virtual void PasswordAccepted() = 0;
// Called by the view when the saved passwords link is clicked.
// TODO(crbug.com/862269): Remove when "Smart Lock" is gone.
virtual void OnSavedPasswordsLinkClicked() = 0;
// Return the minimum allowable width for the popup.
......@@ -39,6 +40,7 @@ class PasswordGenerationPopupController
// Translated strings
virtual base::string16 SuggestedText() = 0;
virtual const base::string16& HelpText() = 0;
// TODO(crbug.com/862269): Remove when "Smart Lock" is gone.
virtual gfx::Range HelpTextLinkRange() = 0;
protected:
......
......@@ -30,7 +30,6 @@
#include "components/password_manager/core/browser/password_generation_manager.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_view_host.h"
......@@ -252,16 +251,7 @@ void PasswordGenerationPopupControllerImpl::ViewDestroyed() {
}
void PasswordGenerationPopupControllerImpl::OnSavedPasswordsLinkClicked() {
#if defined(OS_ANDROID)
chrome::android::PreferencesLauncher::ShowPasswordSettings();
#else
NavigateParams params(
chrome::FindBrowserWithWebContents(web_contents_),
GURL(password_manager::kPasswordManagerAccountDashboardURL),
ui::PAGE_TRANSITION_LINK);
params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
Navigate(&params);
#endif
NOTREACHED();
}
void PasswordGenerationPopupControllerImpl::SetSelectionAtPoint(
......
......@@ -101,6 +101,7 @@ class PasswordsModelDelegate {
password_manager::CredentialType credential_type) = 0;
// Open a new tab, pointing to the Smart Lock help article.
// TODO(crbug.com/862269): remove when "Smart Lock" is gone.
virtual void NavigateToSmartLockHelpPage() = 0;
// Open a new tab, pointing to passwords.google.com.
virtual void NavigateToPasswordManagerAccountDashboard() = 0;
......
......@@ -12,6 +12,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include "chrome/browser/ui/views/harmony/chrome_typography.h"
#include "chrome/browser/ui/views/passwords/password_items_view.h"
#include "chrome/browser/ui/views/passwords/password_sign_in_promo_view.h"
#include "chrome/grit/generated_resources.h"
......@@ -356,6 +357,17 @@ void PasswordPendingView::ContentsChanged(views::Textfield* sender,
}
}
views::View* PasswordPendingView::CreateFootnoteView() {
if (sign_in_promo_ || desktop_ios_promo_ || !model()->ShouldShowFooter())
return nullptr;
views::Label* label = new views::Label(
l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_FOOTER),
ChromeTextContext::CONTEXT_BODY_TEXT_SMALL, STYLE_SECONDARY);
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
return label;
}
gfx::Size PasswordPendingView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_BUBBLE_PREFERRED_WIDTH) -
......
......@@ -62,6 +62,7 @@ class PasswordPendingView : public PasswordBubbleViewBase,
const base::string16& new_contents) override;
// PasswordBubbleViewBase:
views::View* CreateFootnoteView() override;
gfx::Size CalculatePreferredSize() const override;
views::View* GetInitiallyFocusedView() override;
int GetDialogButtons() const override;
......
......@@ -32,7 +32,6 @@
#include "components/content_settings/core/common/features.h"
#include "components/google/core/browser/google_util.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/signin/core/browser/signin_buildflags.h"
......@@ -1469,8 +1468,7 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
"managePasswordsLabel",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_PASSWORDS_MANAGE_PASSWORDS,
base::ASCIIToUTF16(
password_manager::kPasswordManagerAccountDashboardURL)));
l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK)));
html_source->AddString("passwordManagerLearnMoreURL",
chrome::kPasswordManagerLearnMoreURL);
html_source->AddString("manageAddressesUrl",
......
......@@ -38,8 +38,8 @@ int GetSmartBubbleDismissalThreshold() {
}
bool IsSmartLockUser(const syncer::SyncService* sync_service) {
return password_manager_util::GetPasswordSyncState(sync_service) ==
password_manager::SYNCING_NORMAL_ENCRYPTION;
return password_manager_util::GetPasswordSyncState(sync_service) !=
password_manager::NOT_SYNCING;
}
bool ShouldShowAutoSignInPromptFirstRunExperience(PrefService* prefs) {
......
......@@ -26,7 +26,8 @@ void RegisterPrefs(PrefRegistrySimple* registry);
// user before it's not shown automatically.
int GetSmartBubbleDismissalThreshold();
// A Smart Lock user is a sync user without a custom passphrase.
// Returns true if the user syncs passwords to Google Account.
// TODO(crbug.com/862269): rename the function.
bool IsSmartLockUser(const syncer::SyncService* sync_service);
// Returns true if first run experience for auto sign-in prompt should be shown.
......
......@@ -136,19 +136,18 @@ TEST_F(PasswordManagerPasswordBubbleExperimentTest, IsSmartLockUser) {
constexpr struct {
syncer::ModelType type;
CustomPassphraseState passphrase_state;
bool expected_smart_lock_user;
bool expected_sync_user;
} kTestData[] = {
{syncer::ModelType::BOOKMARKS, CustomPassphraseState::NONE, false},
{syncer::ModelType::BOOKMARKS, CustomPassphraseState::SET, false},
{syncer::ModelType::PASSWORDS, CustomPassphraseState::NONE, true},
{syncer::ModelType::PASSWORDS, CustomPassphraseState::SET, false},
{syncer::ModelType::PASSWORDS, CustomPassphraseState::SET, true},
};
for (const auto& test_case : kTestData) {
SCOPED_TRACE(testing::Message("#test_case = ") << (&test_case - kTestData));
SetupFakeSyncServiceForTestCase(test_case.type, test_case.passphrase_state);
EXPECT_EQ(test_case.expected_smart_lock_user,
IsSmartLockUser(sync_service()));
EXPECT_EQ(test_case.expected_sync_user, IsSmartLockUser(sync_service()));
}
}
......
......@@ -13,9 +13,11 @@ extern const base::FilePath::CharType kAffiliationDatabaseFileName[];
extern const base::FilePath::CharType kLoginDataFileName[];
// URL to the password manager account dashboard.
// TODO(crbug.com/862269): remove when "Smart Lock" is completely gone.
extern const char kPasswordManagerAccountDashboardURL[];
// URL to the help center article about Smart Lock;
// TODO(crbug.com/862269): remove when "Smart Lock" is completely gone.
extern const char kPasswordManagerHelpCenterSmartLock[];
} // namespace password_manager
......
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