Commit 9e5fd477 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

Merge credential_leak_dialog_utils with leak_detection_dialog_utils

Merge c/b/ui/passwords/credential_leak_dialog_utils.* with
components/password_manager/core/browser/leak_detection_dialog_utils.h.
Move the strings it uses to components/password_manager_strings.grdp.
Move the constants it uses to
components/password_manager/core/browser/leak_detection/leak_detection_dialog_constants.*

Bug: 1008862
Change-Id: I5766efef92cc343b861baaf4cf66ca8aeb1315f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1833473
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701980}
parent 7f4bd1a9
...@@ -8490,21 +8490,6 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -8490,21 +8490,6 @@ Please help our engineers fix this problem. Tell us what happened right before y
<message name="IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE_MD" desc="The title of the auto-signin toast in Material Design mode."> <message name="IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE_MD" desc="The title of the auto-signin toast in Material Design mode.">
Signing in as Signing in as
</message> </message>
<message name="IDS_CREDENTIAL_LEAK_TITLE" desc="The title of the credential leak dialog.">
Data breach reported
</message>
<message name="IDS_CREDENTIAL_LEAK_CHECK_PASSWORDS_MESSAGE" desc="The text that is used in credential leak detection dialog when saved credentials were used on multiple sites.">
A data breach on a site or app you use exposed your password. Chrome recommends checking your saved passwords now.
</message>
<message name="IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_MESSAGE" desc="The text that is used in credential leak detection dialog when credentials were leaked on current site only.">
A data breach on a site or app you use exposed your password. Chrome recommends <ph name="BOLD">$1<ex>changing your password</ex></ph> on <ph name="ORIGIN">$2<ex>example.com</ex></ph> now.
</message>
<message name="IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_BOLD_MESSAGE" desc="The text that is written in bold in leak dialog message when credentials were leaked on current site only.">
changing your password
</message>
<message name="IDS_CREDENTIAL_LEAK_CHANGE_AND_CHECK_PASSWORDS_MESSAGE" desc="The text that is used in credential leak detection dialog when credentials were not saved in chrome, but used on multiple sites.">
A data breach on a site or app you use exposed your password. Chrome recommends checking your saved passwords and changing your password on <ph name="ORIGIN">$1<ex>example.com</ex></ph>.
</message>
<message name="IDS_AUTO_SIGNIN_FIRST_RUN_TITLE_MANY_DEVICES" desc="The title of the dialog during the autosign-in first run experience for the Chrome syncing users."> <message name="IDS_AUTO_SIGNIN_FIRST_RUN_TITLE_MANY_DEVICES" desc="The title of the dialog during the autosign-in first run experience for the Chrome syncing users.">
Sign in easily across devices Sign in easily across devices
</message> </message>
...@@ -8524,16 +8509,6 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -8524,16 +8509,6 @@ Please help our engineers fix this problem. Tell us what happened right before y
OK, got it OK, got it
</message> </message>
</if> </if>
<if expr="use_titlecase">
<message name="IDS_LEAK_CHECK_CREDENTIALS" desc="The text of the OK button in the dialog for credentials leaked on multiple sites.">
Check Passwords
</message>
</if>
<if expr="not use_titlecase">
<message name="IDS_LEAK_CHECK_CREDENTIALS" desc="The text of the OK button in the dialog for credentials leaked on multiple sites.">
Check passwords
</message>
</if>
<!-- Extra Mac UI Strings --> <!-- Extra Mac UI Strings -->
<if expr="is_macosx"> <if expr="is_macosx">
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "chrome/android/chrome_jni_headers/PasswordCheckupLauncher_jni.h" #include "chrome/android/chrome_jni_headers/PasswordCheckupLauncher_jni.h"
#include "chrome/browser/ui/android/passwords/credential_leak_dialog_view_android.h" #include "chrome/browser/ui/android/passwords/credential_leak_dialog_view_android.h"
#include "chrome/browser/ui/passwords/credential_leak_dialog_utils.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "ui/android/window_android.h" #include "ui/android/window_android.h"
using password_manager::metrics_util::LeakDialogDismissalReason; using password_manager::metrics_util::LeakDialogDismissalReason;
...@@ -30,14 +30,14 @@ void CredentialLeakControllerAndroid::ShowDialog() { ...@@ -30,14 +30,14 @@ void CredentialLeakControllerAndroid::ShowDialog() {
void CredentialLeakControllerAndroid::OnCancelDialog() { void CredentialLeakControllerAndroid::OnCancelDialog() {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
LeakDialogDismissalReason::kClickedClose); LeakDialogDismissalReason::kClickedClose);
delete this; delete this;
} }
void CredentialLeakControllerAndroid::OnAcceptDialog() { void CredentialLeakControllerAndroid::OnAcceptDialog() {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
ShouldCheckPasswords() ? LeakDialogDismissalReason::kClickedCheckPasswords ShouldCheckPasswords() ? LeakDialogDismissalReason::kClickedCheckPasswords
: LeakDialogDismissalReason::kClickedOk); : LeakDialogDismissalReason::kClickedOk);
...@@ -47,7 +47,7 @@ void CredentialLeakControllerAndroid::OnAcceptDialog() { ...@@ -47,7 +47,7 @@ void CredentialLeakControllerAndroid::OnAcceptDialog() {
Java_PasswordCheckupLauncher_launchCheckup( Java_PasswordCheckupLauncher_launchCheckup(
env, env,
base::android::ConvertUTF8ToJavaString( base::android::ConvertUTF8ToJavaString(
env, leak_dialog_utils::GetPasswordCheckupURL().spec()), env, password_manager::GetPasswordCheckupURL().spec()),
window_android_->GetJavaObject()); window_android_->GetJavaObject());
} }
...@@ -56,35 +56,35 @@ void CredentialLeakControllerAndroid::OnAcceptDialog() { ...@@ -56,35 +56,35 @@ void CredentialLeakControllerAndroid::OnAcceptDialog() {
void CredentialLeakControllerAndroid::OnCloseDialog() { void CredentialLeakControllerAndroid::OnCloseDialog() {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
LeakDialogDismissalReason::kNoDirectInteraction); LeakDialogDismissalReason::kNoDirectInteraction);
delete this; delete this;
} }
base::string16 CredentialLeakControllerAndroid::GetAcceptButtonLabel() const { base::string16 CredentialLeakControllerAndroid::GetAcceptButtonLabel() const {
return leak_dialog_utils::GetAcceptButtonLabel(leak_type_); return password_manager::GetAcceptButtonLabel(leak_type_);
} }
base::string16 CredentialLeakControllerAndroid::GetCancelButtonLabel() const { base::string16 CredentialLeakControllerAndroid::GetCancelButtonLabel() const {
return leak_dialog_utils::GetCancelButtonLabel(); return password_manager::GetCancelButtonLabel();
} }
base::string16 CredentialLeakControllerAndroid::GetDescription() const { base::string16 CredentialLeakControllerAndroid::GetDescription() const {
return leak_dialog_utils::GetDescription(leak_type_, origin_); return password_manager::GetDescription(leak_type_, origin_);
} }
base::string16 CredentialLeakControllerAndroid::GetTitle() const { base::string16 CredentialLeakControllerAndroid::GetTitle() const {
return leak_dialog_utils::GetTitle(leak_type_); return password_manager::GetTitle(leak_type_);
} }
gfx::Range CredentialLeakControllerAndroid::GetDescriptionBoldRange() const { gfx::Range CredentialLeakControllerAndroid::GetDescriptionBoldRange() const {
return leak_dialog_utils::GetChangePasswordBoldRange(leak_type_, origin_); return password_manager::GetChangePasswordBoldRange(leak_type_, origin_);
} }
bool CredentialLeakControllerAndroid::ShouldCheckPasswords() const { bool CredentialLeakControllerAndroid::ShouldCheckPasswords() const {
return leak_dialog_utils::ShouldCheckPasswords(leak_type_); return password_manager::ShouldCheckPasswords(leak_type_);
} }
bool CredentialLeakControllerAndroid::ShouldShowCancelButton() const { bool CredentialLeakControllerAndroid::ShouldShowCancelButton() const {
return leak_dialog_utils::ShouldShowCancelButton(leak_type_); return password_manager::ShouldShowCancelButton(leak_type_);
} }
...@@ -135,8 +135,6 @@ jumbo_split_static_library("ui") { ...@@ -135,8 +135,6 @@ jumbo_split_static_library("ui") {
"page_info/page_info_ui.h", "page_info/page_info_ui.h",
"passwords/account_avatar_fetcher.cc", "passwords/account_avatar_fetcher.cc",
"passwords/account_avatar_fetcher.h", "passwords/account_avatar_fetcher.h",
"passwords/credential_leak_dialog_utils.cc",
"passwords/credential_leak_dialog_utils.h",
"passwords/manage_passwords_state.cc", "passwords/manage_passwords_state.cc",
"passwords/manage_passwords_state.h", "passwords/manage_passwords_state.h",
"passwords/manage_passwords_view_utils.cc", "passwords/manage_passwords_view_utils.cc",
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.h" #include "chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.h"
#include "chrome/browser/ui/passwords/credential_leak_dialog_utils.h"
#include "chrome/browser/ui/passwords/password_dialog_prompts.h" #include "chrome/browser/ui/passwords/password_dialog_prompts.h"
#include "chrome/browser/ui/passwords/passwords_leak_dialog_delegate.h" #include "chrome/browser/ui/passwords/passwords_leak_dialog_delegate.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h"
using password_manager::CredentialLeakFlags; using password_manager::CredentialLeakFlags;
...@@ -37,7 +37,7 @@ bool CredentialLeakDialogControllerImpl::IsShowingAccountChooser() const { ...@@ -37,7 +37,7 @@ bool CredentialLeakDialogControllerImpl::IsShowingAccountChooser() const {
void CredentialLeakDialogControllerImpl::OnCancelDialog() { void CredentialLeakDialogControllerImpl::OnCancelDialog() {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
LeakDialogDismissalReason::kClickedClose); LeakDialogDismissalReason::kClickedClose);
delegate_->OnLeakDialogHidden(); delegate_->OnLeakDialogHidden();
} }
...@@ -45,12 +45,12 @@ void CredentialLeakDialogControllerImpl::OnCancelDialog() { ...@@ -45,12 +45,12 @@ void CredentialLeakDialogControllerImpl::OnCancelDialog() {
void CredentialLeakDialogControllerImpl::OnAcceptDialog() { void CredentialLeakDialogControllerImpl::OnAcceptDialog() {
if (ShouldCheckPasswords()) { if (ShouldCheckPasswords()) {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
LeakDialogDismissalReason::kClickedCheckPasswords); LeakDialogDismissalReason::kClickedCheckPasswords);
delegate_->NavigateToPasswordCheckup(); delegate_->NavigateToPasswordCheckup();
} else { } else {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
LeakDialogDismissalReason::kClickedOk); LeakDialogDismissalReason::kClickedOk);
} }
delegate_->OnLeakDialogHidden(); delegate_->OnLeakDialogHidden();
...@@ -58,40 +58,40 @@ void CredentialLeakDialogControllerImpl::OnAcceptDialog() { ...@@ -58,40 +58,40 @@ void CredentialLeakDialogControllerImpl::OnAcceptDialog() {
void CredentialLeakDialogControllerImpl::OnCloseDialog() { void CredentialLeakDialogControllerImpl::OnCloseDialog() {
LogLeakDialogTypeAndDismissalReason( LogLeakDialogTypeAndDismissalReason(
leak_dialog_utils::GetLeakDialogType(leak_type_), password_manager::GetLeakDialogType(leak_type_),
LeakDialogDismissalReason::kNoDirectInteraction); LeakDialogDismissalReason::kNoDirectInteraction);
delegate_->OnLeakDialogHidden(); delegate_->OnLeakDialogHidden();
} }
base::string16 CredentialLeakDialogControllerImpl::GetAcceptButtonLabel() base::string16 CredentialLeakDialogControllerImpl::GetAcceptButtonLabel()
const { const {
return leak_dialog_utils::GetAcceptButtonLabel(leak_type_); return password_manager::GetAcceptButtonLabel(leak_type_);
} }
base::string16 CredentialLeakDialogControllerImpl::GetCancelButtonLabel() base::string16 CredentialLeakDialogControllerImpl::GetCancelButtonLabel()
const { const {
return leak_dialog_utils::GetCancelButtonLabel(); return password_manager::GetCancelButtonLabel();
} }
base::string16 CredentialLeakDialogControllerImpl::GetDescription() const { base::string16 CredentialLeakDialogControllerImpl::GetDescription() const {
return leak_dialog_utils::GetDescription(leak_type_, origin_); return password_manager::GetDescription(leak_type_, origin_);
} }
base::string16 CredentialLeakDialogControllerImpl::GetTitle() const { base::string16 CredentialLeakDialogControllerImpl::GetTitle() const {
return leak_dialog_utils::GetTitle(leak_type_); return password_manager::GetTitle(leak_type_);
} }
bool CredentialLeakDialogControllerImpl::ShouldCheckPasswords() const { bool CredentialLeakDialogControllerImpl::ShouldCheckPasswords() const {
return leak_dialog_utils::ShouldCheckPasswords(leak_type_); return password_manager::ShouldCheckPasswords(leak_type_);
} }
bool CredentialLeakDialogControllerImpl::ShouldShowCancelButton() const { bool CredentialLeakDialogControllerImpl::ShouldShowCancelButton() const {
return leak_dialog_utils::ShouldShowCancelButton(leak_type_); return password_manager::ShouldShowCancelButton(leak_type_);
} }
gfx::Range CredentialLeakDialogControllerImpl::GetChangePasswordBoldRange() gfx::Range CredentialLeakDialogControllerImpl::GetChangePasswordBoldRange()
const { const {
return leak_dialog_utils::GetChangePasswordBoldRange(leak_type_, origin_); return password_manager::GetChangePasswordBoldRange(leak_type_, origin_);
} }
void CredentialLeakDialogControllerImpl::ResetDialog() { void CredentialLeakDialogControllerImpl::ResetDialog() {
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/passwords/credential_leak_dialog_utils.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#include "url/origin.h"
using password_manager::CredentialLeakFlags;
using password_manager::CredentialLeakType;
using password_manager::metrics_util::LeakDialogType;
namespace leak_dialog_utils {
namespace {
// Formats the |origin| to a human-friendly url string.
base::string16 GetFormattedUrl(const GURL& origin) {
return url_formatter::FormatUrlForSecurityDisplay(
origin, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
}
} // namespace
base::string16 GetAcceptButtonLabel(CredentialLeakType leak_type) {
return l10n_util::GetStringUTF16(
ShouldCheckPasswords(leak_type) ? IDS_LEAK_CHECK_CREDENTIALS : IDS_OK);
}
base::string16 GetCancelButtonLabel() {
return l10n_util::GetStringUTF16(IDS_CLOSE);
}
base::string16 GetDescription(CredentialLeakType leak_type,
const GURL& origin) {
const base::string16 formatted = GetFormattedUrl(origin);
if (!ShouldCheckPasswords(leak_type)) {
std::vector<size_t> offsets;
base::string16 bold_message = l10n_util::GetStringUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_BOLD_MESSAGE);
return l10n_util::GetStringFUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_MESSAGE, bold_message, formatted,
&offsets);
} else if (password_manager::IsPasswordSaved(leak_type)) {
return l10n_util::GetStringUTF16(
IDS_CREDENTIAL_LEAK_CHECK_PASSWORDS_MESSAGE);
} else {
return l10n_util::GetStringFUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_AND_CHECK_PASSWORDS_MESSAGE, formatted);
}
}
base::string16 GetTitle(CredentialLeakType leak_type) {
return l10n_util::GetStringUTF16(IDS_CREDENTIAL_LEAK_TITLE);
}
bool ShouldCheckPasswords(CredentialLeakType leak_type) {
return password_manager::IsPasswordUsedOnOtherSites(leak_type) &&
password_manager::IsSyncingPasswordsNormally(leak_type);
}
bool ShouldShowCancelButton(CredentialLeakType leak_type) {
return ShouldCheckPasswords(leak_type);
}
LeakDialogType GetLeakDialogType(CredentialLeakType leak_type) {
if (!ShouldCheckPasswords(leak_type))
return LeakDialogType::kChange;
return password_manager::IsPasswordSaved(leak_type)
? LeakDialogType::kCheckup
: LeakDialogType::kCheckupAndChange;
}
GURL GetPasswordCheckupURL() {
std::string value = base::GetFieldTrialParamValueByFeature(
password_manager::features::kLeakDetection, "leak-check-url");
if (value.empty())
return GURL(chrome::kPasswordCheckupURL);
return GURL(value);
}
gfx::Range GetChangePasswordBoldRange(CredentialLeakType leak_type,
const GURL& origin) {
if (ShouldCheckPasswords(leak_type))
return gfx::Range();
std::vector<size_t> offsets;
const base::string16 bold_message = l10n_util::GetStringUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_BOLD_MESSAGE);
const base::string16 change_password_message = l10n_util::GetStringFUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_MESSAGE, bold_message,
GetFormattedUrl(origin), &offsets);
return offsets.empty()
? gfx::Range()
: gfx::Range(offsets[0], offsets[0] + bold_message.length());
}
} // namespace leak_dialog_utils
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_PASSWORDS_CREDENTIAL_LEAK_DIALOG_UTILS_H_
#define CHROME_BROWSER_UI_PASSWORDS_CREDENTIAL_LEAK_DIALOG_UTILS_H_
#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "ui/gfx/range/range.h"
#include "url/gurl.h"
namespace leak_dialog_utils {
// Returns the label for the leak dialog accept button.
base::string16 GetAcceptButtonLabel(
password_manager::CredentialLeakType leak_type);
// Returns the label for the leak dialog cancel button.
base::string16 GetCancelButtonLabel();
// Returns the leak dialog message based on leak type.
base::string16 GetDescription(password_manager::CredentialLeakType leak_type,
const GURL& origin);
// Returns the leak dialog title based on leak type.
base::string16 GetTitle(password_manager::CredentialLeakType leak_type);
// Checks whether the leak dialog should prompt user to password checkup.
bool ShouldCheckPasswords(password_manager::CredentialLeakType leak_type);
// Checks whether the leak dialog should show cancel button.
bool ShouldShowCancelButton(password_manager::CredentialLeakType leak_type);
// Returns the LeakDialogType corresponding to |leak_type|.
password_manager::metrics_util::LeakDialogType GetLeakDialogType(
password_manager::CredentialLeakType leak_type);
// Returns the URL used to launch the password checkup.
GURL GetPasswordCheckupURL();
// Returns the range of the bold part of the leak dialog message when
// credentials were leaked only on current site.
gfx::Range GetChangePasswordBoldRange(
password_manager::CredentialLeakType leak_type,
const GURL& origin);
} // namespace leak_dialog_utils
#endif // CHROME_BROWSER_UI_PASSWORDS_CREDENTIAL_LEAK_DIALOG_UTILS_H_
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/passwords/credential_leak_dialog_utils.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h" #include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_constants.h" #include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
...@@ -257,7 +257,7 @@ void NavigateToManagePasswordsPage(Browser* browser, ...@@ -257,7 +257,7 @@ void NavigateToManagePasswordsPage(Browser* browser,
} }
void NavigateToPasswordCheckupPage(Profile* profile) { void NavigateToPasswordCheckupPage(Profile* profile) {
NavigateParams params(profile, leak_dialog_utils::GetPasswordCheckupURL(), NavigateParams params(profile, password_manager::GetPasswordCheckupURL(),
ui::PAGE_TRANSITION_LINK); ui::PAGE_TRANSITION_LINK);
params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
Navigate(&params); Navigate(&params);
......
...@@ -156,17 +156,6 @@ const char kGoogleAccountChooserURL[] = ...@@ -156,17 +156,6 @@ const char kGoogleAccountChooserURL[] =
const char kGooglePasswordManagerURL[] = "https://passwords.google.com"; const char kGooglePasswordManagerURL[] = "https://passwords.google.com";
const char kPasswordCheckupURL[] =
#if defined(OS_ANDROID)
"https://passwords.google.com/checkup/"
"start?utm_source=chrome&utm_medium=android&utm_campaign=leak_dialog&crch="
"true";
#else
"https://passwords.google.com/checkup/"
"start?utm_source=chrome&utm_medium=desktop&utm_campaign=leak_dialog&crch="
"true";
#endif
const char kLearnMoreReportingURL[] = const char kLearnMoreReportingURL[] =
"https://support.google.com/chrome/?p=ui_usagestat"; "https://support.google.com/chrome/?p=ui_usagestat";
......
...@@ -150,9 +150,6 @@ extern const char kGoogleAccountChooserURL[]; ...@@ -150,9 +150,6 @@ extern const char kGoogleAccountChooserURL[];
// URL of the Google Password Manager. // URL of the Google Password Manager.
extern const char kGooglePasswordManagerURL[]; extern const char kGooglePasswordManagerURL[];
// URL for Password Checkup.
extern const char kPasswordCheckupURL[];
// The URL for the "Learn more" page for the usage/crash reporting option in the // The URL for the "Learn more" page for the usage/crash reporting option in the
// first run dialog. // first run dialog.
extern const char kLearnMoreReportingURL[]; extern const char kLearnMoreReportingURL[];
......
...@@ -3283,7 +3283,6 @@ test("unit_tests") { ...@@ -3283,7 +3283,6 @@ test("unit_tests") {
"../browser/ui/find_bar/find_backend_unittest.cc", "../browser/ui/find_bar/find_backend_unittest.cc",
"../browser/ui/login/login_handler_unittest.cc", "../browser/ui/login/login_handler_unittest.cc",
"../browser/ui/page_info/page_info_unittest.cc", "../browser/ui/page_info/page_info_unittest.cc",
"../browser/ui/passwords/credential_leak_dialog_utils_unittest.cc",
"../browser/ui/passwords/manage_passwords_state_unittest.cc", "../browser/ui/passwords/manage_passwords_state_unittest.cc",
"../browser/ui/passwords/manage_passwords_view_utils_unittest.cc", "../browser/ui/passwords/manage_passwords_view_utils_unittest.cc",
"../browser/ui/passwords/password_generation_popup_controller_impl_unittest.cc", "../browser/ui/passwords/password_generation_popup_controller_impl_unittest.cc",
......
...@@ -102,6 +102,8 @@ jumbo_static_library("browser") { ...@@ -102,6 +102,8 @@ jumbo_static_library("browser") {
"import/password_csv_reader.h", "import/password_csv_reader.h",
"import/password_importer.cc", "import/password_importer.cc",
"import/password_importer.h", "import/password_importer.h",
"leak_detection_dialog_utils.cc",
"leak_detection_dialog_utils.h",
"leaked_credentials_table.cc", "leaked_credentials_table.cc",
"leaked_credentials_table.h", "leaked_credentials_table.h",
"login_database.cc", "login_database.cc",
...@@ -231,6 +233,7 @@ jumbo_static_library("browser") { ...@@ -231,6 +233,7 @@ jumbo_static_library("browser") {
":password_generator", ":password_generator",
":password_hash_data", ":password_hash_data",
":proto", ":proto",
"//base",
"//base:i18n", "//base:i18n",
"//components/autofill/core/browser", "//components/autofill/core/browser",
"//components/autofill/core/browser/proto", "//components/autofill/core/browser/proto",
...@@ -247,6 +250,7 @@ jumbo_static_library("browser") { ...@@ -247,6 +250,7 @@ jumbo_static_library("browser") {
"//components/security_state/core", "//components/security_state/core",
"//components/signin/public/identity_manager", "//components/signin/public/identity_manager",
"//components/strings", "//components/strings",
"//components/strings:components_strings",
"//components/sync", "//components/sync",
"//components/sync_preferences", "//components/sync_preferences",
"//components/url_formatter", "//components/url_formatter",
...@@ -262,6 +266,7 @@ jumbo_static_library("browser") { ...@@ -262,6 +266,7 @@ jumbo_static_library("browser") {
"//third_party/re2", "//third_party/re2",
"//ui/base", "//ui/base",
"//ui/gfx", "//ui/gfx",
"//ui/gfx/range",
"//url", "//url",
] ]
...@@ -275,8 +280,6 @@ jumbo_static_library("browser") { ...@@ -275,8 +280,6 @@ jumbo_static_library("browser") {
"leak_detection_delegate.h", "leak_detection_delegate.h",
"leak_detection_delegate_helper.cc", "leak_detection_delegate_helper.cc",
"leak_detection_delegate_helper.h", "leak_detection_delegate_helper.h",
"leak_detection_dialog_utils.cc",
"leak_detection_dialog_utils.h",
] ]
deps += [ deps += [
"//components/password_manager/core/browser/leak_detection:leak_detection", "//components/password_manager/core/browser/leak_detection:leak_detection",
...@@ -514,6 +517,7 @@ source_set("unit_tests") { ...@@ -514,6 +517,7 @@ source_set("unit_tests") {
"import/csv_reader_unittest.cc", "import/csv_reader_unittest.cc",
"import/password_csv_reader_unittest.cc", "import/password_csv_reader_unittest.cc",
"import/password_importer_unittest.cc", "import/password_importer_unittest.cc",
"leak_detection_dialog_utils_unittest.cc",
"leaked_credentials_table_unittest.cc", "leaked_credentials_table_unittest.cc",
"login_database_unittest.cc", "login_database_unittest.cc",
"multi_store_form_fetcher_unittest.cc", "multi_store_form_fetcher_unittest.cc",
...@@ -603,6 +607,7 @@ source_set("unit_tests") { ...@@ -603,6 +607,7 @@ source_set("unit_tests") {
"//components/sync:test_support", "//components/sync:test_support",
"//components/sync_preferences:test_support", "//components/sync_preferences:test_support",
"//components/ukm:test_support", "//components/ukm:test_support",
"//components/url_formatter",
"//components/variations", "//components/variations",
"//google_apis:google_apis", "//google_apis:google_apis",
"//net:test_support", "//net:test_support",
......
...@@ -4,8 +4,36 @@ ...@@ -4,8 +4,36 @@
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h" #include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace password_manager { namespace password_manager {
using metrics_util::LeakDialogType;
constexpr char kPasswordCheckupURL[] =
#if defined(OS_ANDROID)
"https://passwords.google.com/checkup/"
"start?utm_source=chrome&utm_medium=android&utm_campaign=leak_dialog&crch="
"true";
#elif defined(OS_IOS)
"https://passwords.google.com/checkup/"
"start?utm_source=chrome&utm_medium=ios&utm_campaign=leak_dialog&crch="
"true";
#else
"https://passwords.google.com/checkup/"
"start?utm_source=chrome&utm_medium=desktop&utm_campaign=leak_dialog&crch="
"true";
#endif
CredentialLeakType CreateLeakType(IsSaved is_saved, CredentialLeakType CreateLeakType(IsSaved is_saved,
IsReused is_reused, IsReused is_reused,
IsSyncing is_syncing) { IsSyncing is_syncing) {
...@@ -31,4 +59,84 @@ bool IsSyncingPasswordsNormally(CredentialLeakType leak_type) { ...@@ -31,4 +59,84 @@ bool IsSyncingPasswordsNormally(CredentialLeakType leak_type) {
return leak_type & CredentialLeakFlags::kSyncingPasswordsNormally; return leak_type & CredentialLeakFlags::kSyncingPasswordsNormally;
} }
// Formats the |origin| to a human-friendly url string.
base::string16 GetFormattedUrl(const GURL& origin) {
return url_formatter::FormatUrlForSecurityDisplay(
origin, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
}
base::string16 GetAcceptButtonLabel(CredentialLeakType leak_type) {
return l10n_util::GetStringUTF16(
ShouldCheckPasswords(leak_type) ? IDS_LEAK_CHECK_CREDENTIALS : IDS_OK);
}
base::string16 GetCancelButtonLabel() {
return l10n_util::GetStringUTF16(IDS_CLOSE);
}
base::string16 GetDescription(CredentialLeakType leak_type,
const GURL& origin) {
const base::string16 formatted = GetFormattedUrl(origin);
if (!ShouldCheckPasswords(leak_type)) {
std::vector<size_t> offsets;
base::string16 bold_message = l10n_util::GetStringUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_BOLD_MESSAGE);
return l10n_util::GetStringFUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_MESSAGE, bold_message, formatted,
&offsets);
} else if (password_manager::IsPasswordSaved(leak_type)) {
return l10n_util::GetStringUTF16(
IDS_CREDENTIAL_LEAK_CHECK_PASSWORDS_MESSAGE);
} else {
return l10n_util::GetStringFUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_AND_CHECK_PASSWORDS_MESSAGE, formatted);
}
}
base::string16 GetTitle(CredentialLeakType leak_type) {
return l10n_util::GetStringUTF16(IDS_CREDENTIAL_LEAK_TITLE);
}
bool ShouldCheckPasswords(CredentialLeakType leak_type) {
return password_manager::IsPasswordUsedOnOtherSites(leak_type) &&
password_manager::IsSyncingPasswordsNormally(leak_type);
}
bool ShouldShowCancelButton(CredentialLeakType leak_type) {
return ShouldCheckPasswords(leak_type);
}
LeakDialogType GetLeakDialogType(CredentialLeakType leak_type) {
if (!ShouldCheckPasswords(leak_type))
return LeakDialogType::kChange;
return password_manager::IsPasswordSaved(leak_type)
? LeakDialogType::kCheckup
: LeakDialogType::kCheckupAndChange;
}
GURL GetPasswordCheckupURL() {
std::string value = base::GetFieldTrialParamValueByFeature(
password_manager::features::kLeakDetection, "leak-check-url");
if (value.empty())
return GURL(password_manager::kPasswordCheckupURL);
return GURL(value);
}
gfx::Range GetChangePasswordBoldRange(CredentialLeakType leak_type,
const GURL& origin) {
if (ShouldCheckPasswords(leak_type))
return gfx::Range();
std::vector<size_t> offsets;
const base::string16 bold_message = l10n_util::GetStringUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_BOLD_MESSAGE);
const base::string16 change_password_message = l10n_util::GetStringFUTF16(
IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_MESSAGE, bold_message,
GetFormattedUrl(origin), &offsets);
return offsets.empty()
? gfx::Range()
: gfx::Range(offsets[0], offsets[0] + bold_message.length());
}
} // namespace password_manager } // namespace password_manager
...@@ -7,7 +7,13 @@ ...@@ -7,7 +7,13 @@
#include <type_traits> #include <type_traits>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/util/type_safety/strong_alias.h" #include "base/util/type_safety/strong_alias.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "ui/gfx/range/range.h"
#include "url/gurl.h"
namespace password_manager { namespace password_manager {
...@@ -42,6 +48,39 @@ bool IsPasswordUsedOnOtherSites(CredentialLeakType leak_type); ...@@ -42,6 +48,39 @@ bool IsPasswordUsedOnOtherSites(CredentialLeakType leak_type);
// Checks whether user is syncing passwords with normal encryption. // Checks whether user is syncing passwords with normal encryption.
bool IsSyncingPasswordsNormally(CredentialLeakType leak_type); bool IsSyncingPasswordsNormally(CredentialLeakType leak_type);
// Returns the label for the leak dialog accept button.
base::string16 GetAcceptButtonLabel(
password_manager::CredentialLeakType leak_type);
// Returns the label for the leak dialog cancel button.
base::string16 GetCancelButtonLabel();
// Returns the leak dialog message based on leak type.
base::string16 GetDescription(password_manager::CredentialLeakType leak_type,
const GURL& origin);
// Returns the leak dialog title based on leak type.
base::string16 GetTitle(password_manager::CredentialLeakType leak_type);
// Checks whether the leak dialog should prompt user to password checkup.
bool ShouldCheckPasswords(password_manager::CredentialLeakType leak_type);
// Checks whether the leak dialog should show cancel button.
bool ShouldShowCancelButton(password_manager::CredentialLeakType leak_type);
// Returns the LeakDialogType corresponding to |leak_type|.
password_manager::metrics_util::LeakDialogType GetLeakDialogType(
password_manager::CredentialLeakType leak_type);
// Returns the URL used to launch the password checkup.
GURL GetPasswordCheckupURL();
// Returns the range of the bold part of the leak dialog message when
// credentials were leaked only on current site.
gfx::Range GetChangePasswordBoldRange(
password_manager::CredentialLeakType leak_type,
const GURL& origin);
} // namespace password_manager } // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_DIALOG_UTILS_H_ #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_DIALOG_UTILS_H_
...@@ -2,10 +2,8 @@ ...@@ -2,10 +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.
#include "chrome/browser/ui/passwords/credential_leak_dialog_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h" #include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h" #include "components/url_formatter/elide_url.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -20,7 +18,7 @@ using password_manager::IsReused; ...@@ -20,7 +18,7 @@ using password_manager::IsReused;
using password_manager::IsSaved; using password_manager::IsSaved;
using password_manager::IsSyncing; using password_manager::IsSyncing;
namespace leak_dialog_utils { namespace password_manager {
namespace { namespace {
...@@ -153,4 +151,4 @@ TEST(CredentialLeakDialogUtilsTest, ShouldShowCancelButton) { ...@@ -153,4 +151,4 @@ TEST(CredentialLeakDialogUtilsTest, ShouldShowCancelButton) {
} }
} }
} // namespace leak_dialog_utils } // namespace password_manager
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<grit-part> <grit-part>
<if expr="use_titlecase">
<message name="IDS_LEAK_CHECK_CREDENTIALS" desc="The text of the OK button in the dialog for credentials leaked on multiple sites.">
Check Passwords
</message>
</if>
<if expr="not use_titlecase">
<message name="IDS_LEAK_CHECK_CREDENTIALS" desc="The text of the OK button in the dialog for credentials leaked on multiple sites.">
Check passwords
</message>
</if>
<message name="IDS_CREDENTIAL_LEAK_TITLE" desc="The title of the credential leak dialog.">
Data breach reported
</message>
<message name="IDS_CREDENTIAL_LEAK_CHECK_PASSWORDS_MESSAGE" desc="The text that is used in credential leak detection dialog when saved credentials were used on multiple sites.">
A data breach on a site or app you use exposed your password. Chrome recommends checking your saved passwords now.
</message>
<message name="IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_MESSAGE" desc="The text that is used in credential leak detection dialog when credentials were leaked on current site only.">
A data breach on a site or app you use exposed your password. Chrome recommends <ph name="BOLD">$1<ex>changing your password</ex></ph> on <ph name="ORIGIN">$2<ex>example.com</ex></ph> now.
</message>
<message name="IDS_CREDENTIAL_LEAK_CHANGE_PASSWORD_BOLD_MESSAGE" desc="The text that is written in bold in leak dialog message when credentials were leaked on current site only.">
changing your password
</message>
<message name="IDS_CREDENTIAL_LEAK_CHANGE_AND_CHECK_PASSWORDS_MESSAGE" desc="The text that is used in credential leak detection dialog when credentials were not saved in chrome, but used on multiple sites.">
A data breach on a site or app you use exposed your password. Chrome recommends checking your saved passwords and changing your password on <ph name="ORIGIN">$1<ex>example.com</ex></ph>.
</message>
<message name="IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE" desc="The title of the auto-signin toast."> <message name="IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE" desc="The title of the auto-signin toast.">
Signing in as <ph name="username">$1<ex>chef@google.com</ex></ph> Signing in as <ph name="username">$1<ex>chef@google.com</ex></ph>
</message> </message>
...@@ -35,5 +59,4 @@ ...@@ -35,5 +59,4 @@
<message name="IDS_PASSWORD_MANAGER_DEFAULT_EXPORT_FILENAME" desc="Chrome suggests this file name when user chooses to export their passwords saved with Chrome."> <message name="IDS_PASSWORD_MANAGER_DEFAULT_EXPORT_FILENAME" desc="Chrome suggests this file name when user chooses to export their passwords saved with Chrome.">
Chrome Passwords Chrome Passwords
</message> </message>
</grit-part> </grit-part>
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