Commit 8d36b2d6 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

The password leak check now links to the local Chrome settings page.

TBR=holte@chromium.org

Bug: 1049200
Change-Id: I096daf099c8bf97f0699aacb4ca3cd0a58d012d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090430
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748174}
parent 448c7812
...@@ -449,6 +449,11 @@ void ShowPasswordManager(Browser* browser) { ...@@ -449,6 +449,11 @@ void ShowPasswordManager(Browser* browser) {
ShowSettingsSubPage(browser, kPasswordManagerSubPage); ShowSettingsSubPage(browser, kPasswordManagerSubPage);
} }
void ShowPasswordCheck(Browser* browser) {
base::RecordAction(UserMetricsAction("Options_ShowPasswordCheck"));
ShowSettingsSubPage(browser, kPasswordCheckSubPage);
}
void ShowImportDialog(Browser* browser) { void ShowImportDialog(Browser* browser) {
base::RecordAction(UserMetricsAction("Import_ShowDlg")); base::RecordAction(UserMetricsAction("Import_ShowDlg"));
ShowSettingsSubPage(browser, kImportDataSubPage); ShowSettingsSubPage(browser, kImportDataSubPage);
......
...@@ -125,6 +125,7 @@ void ShowSettingsSubPageInTabbedBrowser(Browser* browser, ...@@ -125,6 +125,7 @@ void ShowSettingsSubPageInTabbedBrowser(Browser* browser,
const std::string& sub_page); const std::string& sub_page);
void ShowClearBrowsingDataDialog(Browser* browser); void ShowClearBrowsingDataDialog(Browser* browser);
void ShowPasswordManager(Browser* browser); void ShowPasswordManager(Browser* browser);
void ShowPasswordCheck(Browser* browser);
void ShowImportDialog(Browser* browser); void ShowImportDialog(Browser* browser);
void ShowAboutChrome(Browser* browser); void ShowAboutChrome(Browser* browser);
void ShowSearchEngineSettings(Browser* browser); void ShowSearchEngineSettings(Browser* browser);
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "components/password_manager/core/browser/password_ui_utils.h" #include "components/password_manager/core/browser/password_ui_utils.h"
#include "components/password_manager/core/browser/statistics_table.h" #include "components/password_manager/core/browser/statistics_table.h"
#include "components/password_manager/core/common/credential_manager_types.h" #include "components/password_manager/core/common/credential_manager_types.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -493,8 +494,14 @@ void ManagePasswordsUIController::NavigateToPasswordManagerAccountDashboard( ...@@ -493,8 +494,14 @@ void ManagePasswordsUIController::NavigateToPasswordManagerAccountDashboard(
} }
void ManagePasswordsUIController::NavigateToPasswordCheckup() { void ManagePasswordsUIController::NavigateToPasswordCheckup() {
NavigateToPasswordCheckupPage( if (base::FeatureList::IsEnabled(
Profile::FromBrowserContext(web_contents()->GetBrowserContext())); password_manager::features::kPasswordCheck)) {
chrome::ShowPasswordCheck(
chrome::FindBrowserWithWebContents(web_contents()));
} else {
NavigateToPasswordCheckupPage(
Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
}
} }
void ManagePasswordsUIController::EnableSync(const AccountInfo& account, void ManagePasswordsUIController::EnableSync(const AccountInfo& account,
......
...@@ -374,6 +374,7 @@ const char kHandlerSettingsSubPage[] = "handlers"; ...@@ -374,6 +374,7 @@ const char kHandlerSettingsSubPage[] = "handlers";
const char kImportDataSubPage[] = "importData"; const char kImportDataSubPage[] = "importData";
const char kLanguageOptionsSubPage[] = "languages"; const char kLanguageOptionsSubPage[] = "languages";
const char kOnStartupSubPage[] = "onStartup"; const char kOnStartupSubPage[] = "onStartup";
const char kPasswordCheckSubPage[] = "passwords/check";
const char kPasswordManagerSubPage[] = "passwords"; const char kPasswordManagerSubPage[] = "passwords";
const char kPaymentsSubPage[] = "payments"; const char kPaymentsSubPage[] = "payments";
const char kPrintingSettingsSubPage[] = "printing"; const char kPrintingSettingsSubPage[] = "printing";
......
...@@ -330,6 +330,7 @@ extern const char kImportDataSubPage[]; ...@@ -330,6 +330,7 @@ extern const char kImportDataSubPage[];
extern const char kLanguageOptionsSubPage[]; extern const char kLanguageOptionsSubPage[];
extern const char kManageProfileSubPage[]; extern const char kManageProfileSubPage[];
extern const char kOnStartupSubPage[]; extern const char kOnStartupSubPage[];
extern const char kPasswordCheckSubPage[];
extern const char kPasswordManagerSubPage[]; extern const char kPasswordManagerSubPage[];
extern const char kPaymentsSubPage[]; extern const char kPaymentsSubPage[];
extern const char kPeopleSubPage[]; extern const char kPeopleSubPage[];
......
...@@ -100,6 +100,10 @@ base::string16 GetLeakDetectionTooltip() { ...@@ -100,6 +100,10 @@ base::string16 GetLeakDetectionTooltip() {
} }
bool ShouldCheckPasswords(CredentialLeakType leak_type) { bool ShouldCheckPasswords(CredentialLeakType leak_type) {
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
return password_manager::IsPasswordUsedOnOtherSites(leak_type);
}
return password_manager::IsPasswordUsedOnOtherSites(leak_type) && return password_manager::IsPasswordUsedOnOtherSites(leak_type) &&
password_manager::IsSyncingPasswordsNormally(leak_type); password_manager::IsSyncingPasswordsNormally(leak_type);
} }
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
#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 "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/password_manager/core/common/password_manager_features.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"
...@@ -52,6 +55,17 @@ const struct { ...@@ -52,6 +55,17 @@ const struct {
IDS_LEAK_CHECK_CREDENTIALS, IDS_CLOSE, IDS_LEAK_CHECK_CREDENTIALS, IDS_CLOSE,
IDS_CREDENTIAL_LEAK_CHECK_PASSWORDS_MESSAGE, IDS_CREDENTIAL_LEAK_CHECK_PASSWORDS_MESSAGE,
IDS_CREDENTIAL_LEAK_TITLE_CHECK, true, true}}; IDS_CREDENTIAL_LEAK_TITLE_CHECK, true, true}};
struct BulkCheckParams {
// Specifies the test case.
CredentialLeakType leak_type;
bool should_check_passwords;
} kBulkCheckTestCases[] = {
{CreateLeakType(IsSaved(false), IsReused(false), IsSyncing(false)), false},
{CreateLeakType(IsSaved(true), IsReused(false), IsSyncing(false)), false},
{CreateLeakType(IsSaved(false), IsReused(true), IsSyncing(false)), true},
{CreateLeakType(IsSaved(true), IsReused(true), IsSyncing(false)), true},
{CreateLeakType(IsSaved(true), IsReused(true), IsSyncing(true)), true}};
} // namespace } // namespace
TEST(CredentialLeakDialogUtilsTest, GetAcceptButtonLabel) { TEST(CredentialLeakDialogUtilsTest, GetAcceptButtonLabel) {
...@@ -144,4 +158,44 @@ TEST(CredentialLeakDialogUtilsTest, ShouldShowCancelButton) { ...@@ -144,4 +158,44 @@ TEST(CredentialLeakDialogUtilsTest, ShouldShowCancelButton) {
} }
} }
class BulkCheckCredentialLeakDialogUtilsTest
: public testing::TestWithParam<BulkCheckParams> {
public:
BulkCheckCredentialLeakDialogUtilsTest() {
feature_list_.InitAndEnableFeature(features::kPasswordCheck);
}
private:
base::test::ScopedFeatureList feature_list_;
};
TEST_P(BulkCheckCredentialLeakDialogUtilsTest, ShouldCheckPasswords) {
SCOPED_TRACE(testing::Message() << GetParam().leak_type);
EXPECT_EQ(GetParam().should_check_passwords,
ShouldCheckPasswords(GetParam().leak_type));
}
TEST_P(BulkCheckCredentialLeakDialogUtilsTest, Buttons) {
SCOPED_TRACE(testing::Message() << GetParam().leak_type);
EXPECT_EQ(GetParam().should_check_passwords,
ShouldShowCancelButton(GetParam().leak_type));
EXPECT_EQ(l10n_util::GetStringUTF16(GetParam().should_check_passwords
? IDS_LEAK_CHECK_CREDENTIALS
: IDS_OK),
GetAcceptButtonLabel(GetParam().leak_type));
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_CLOSE), GetCancelButtonLabel());
}
TEST_P(BulkCheckCredentialLeakDialogUtilsTest, Title) {
SCOPED_TRACE(testing::Message() << GetParam().leak_type);
EXPECT_EQ(l10n_util::GetStringUTF16(GetParam().should_check_passwords
? IDS_CREDENTIAL_LEAK_TITLE_CHECK
: IDS_CREDENTIAL_LEAK_TITLE_CHANGE),
GetTitle(GetParam().leak_type));
}
INSTANTIATE_TEST_SUITE_P(InstantiationName,
BulkCheckCredentialLeakDialogUtilsTest,
testing::ValuesIn(kBulkCheckTestCases));
} // namespace password_manager } // namespace password_manager
...@@ -16827,14 +16827,16 @@ should be able to be added at any place in this file. ...@@ -16827,14 +16827,16 @@ should be able to be added at any place in this file.
<description>Settings: Keyboard settings</description> <description>Settings: Keyboard settings</description>
</action> </action>
<action name="Options_ShowPasswordManager"> <action name="Options_ShowPasswordCheck">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>jdoerrie@chromium.org</owner>
<description>Please enter the description of this user action.</description> <owner>vasilii@chromium.org</owner>
<description>Settings: passwords check</description>
</action> </action>
<action name="Options_ShowPasswordsExceptions"> <action name="Options_ShowPasswordManager">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>jdoerrie@chromium.org</owner>
<description>Please enter the description of this user action.</description> <owner>vasilii@chromium.org</owner>
<description>Settings: saved passwords</description>
</action> </action>
<action name="Options_ShowPowerSettings"> <action name="Options_ShowPowerSettings">
......
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