Commit 5bd8b22f authored by Bettina's avatar Bettina Committed by Commit Bot

Change the text in the page info bubble for non sync users.

This change depends on cr/1693188.

Bug: 914410
Change-Id: I510f2e63c924bc7860325601d6c4d1b93c542091
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1709893Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Commit-Queue: Bettina Dea <bdea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688720}
parent ef78d581
...@@ -266,17 +266,22 @@ PageInfoUI::GetSecurityDescription(const IdentityInfo& identity_info) const { ...@@ -266,17 +266,22 @@ PageInfoUI::GetSecurityDescription(const IdentityInfo& identity_info) const {
IDS_PAGE_INFO_UNWANTED_SOFTWARE_SUMMARY, IDS_PAGE_INFO_UNWANTED_SOFTWARE_SUMMARY,
IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS); IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
case PageInfo::SAFE_BROWSING_STATUS_SIGNED_IN_SYNC_PASSWORD_REUSE: case PageInfo::SAFE_BROWSING_STATUS_SIGNED_IN_SYNC_PASSWORD_REUSE:
#if BUILDFLAG(FULL_SAFE_BROWSING)
return CreateSecurityDescriptionForPasswordReuse(PasswordType::SYNC_GAIA);
#endif
NOTREACHED();
break;
case PageInfo::SAFE_BROWSING_STATUS_SIGNED_IN_NON_SYNC_PASSWORD_REUSE: case PageInfo::SAFE_BROWSING_STATUS_SIGNED_IN_NON_SYNC_PASSWORD_REUSE:
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
return CreateSecurityDescriptionForPasswordReuse( return CreateSecurityDescriptionForPasswordReuse(
/*is_enterprise_password=*/false); PasswordType::NON_SYNC_GAIA);
#endif #endif
NOTREACHED(); NOTREACHED();
break; break;
case PageInfo::SAFE_BROWSING_STATUS_ENTERPRISE_PASSWORD_REUSE: case PageInfo::SAFE_BROWSING_STATUS_ENTERPRISE_PASSWORD_REUSE:
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
return CreateSecurityDescriptionForPasswordReuse( return CreateSecurityDescriptionForPasswordReuse(
/*is_enterprise_password=*/true); PasswordType::NON_GAIA_ENTERPRISE);
#endif #endif
NOTREACHED(); NOTREACHED();
break; break;
......
...@@ -54,6 +54,18 @@ class PageInfoUI { ...@@ -54,6 +54,18 @@ class PageInfoUI {
base::string16 details; base::string16 details;
}; };
// This enum is used to create the description in the page info bubble when
// password reuse is detected.
enum PasswordType {
UNKNOWN,
// If the reused password is associated with a non-GAIA enterprise account.
NON_GAIA_ENTERPRISE,
// If the reused password is associated with a syncing GAIA account.
SYNC_GAIA,
// If the reused password is associated with a non-syncing GAIA account.
NON_SYNC_GAIA,
};
// |CookieInfo| contains information about the cookies from a specific source. // |CookieInfo| contains information about the cookies from a specific source.
// A source can for example be a specific origin or an entire wildcard domain. // A source can for example be a specific origin or an entire wildcard domain.
struct CookieInfo { struct CookieInfo {
...@@ -233,7 +245,7 @@ class PageInfoUI { ...@@ -233,7 +245,7 @@ class PageInfoUI {
// Creates security description for password reuse case. // Creates security description for password reuse case.
virtual std::unique_ptr<PageInfoUI::SecurityDescription> virtual std::unique_ptr<PageInfoUI::SecurityDescription>
CreateSecurityDescriptionForPasswordReuse( CreateSecurityDescriptionForPasswordReuse(
bool is_enterprise_password) const = 0; PasswordType password_type) const = 0;
#endif #endif
}; };
......
...@@ -106,7 +106,7 @@ class MockPageInfoUI : public PageInfoUI { ...@@ -106,7 +106,7 @@ class MockPageInfoUI : public PageInfoUI {
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
std::unique_ptr<PageInfoUI::SecurityDescription> std::unique_ptr<PageInfoUI::SecurityDescription>
CreateSecurityDescriptionForPasswordReuse( CreateSecurityDescriptionForPasswordReuse(
bool unused_is_enterprise_password) const override { PasswordType password_type) const override {
std::unique_ptr<PageInfoUI::SecurityDescription> security_description( std::unique_ptr<PageInfoUI::SecurityDescription> security_description(
new PageInfoUI::SecurityDescription()); new PageInfoUI::SecurityDescription());
security_description->summary_style = SecuritySummaryColor::RED; security_description->summary_style = SecuritySummaryColor::RED;
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
using bubble_anchor_util::AnchorConfiguration; using bubble_anchor_util::AnchorConfiguration;
using bubble_anchor_util::GetPageInfoAnchorConfiguration; using bubble_anchor_util::GetPageInfoAnchorConfiguration;
using bubble_anchor_util::GetPageInfoAnchorRect; using bubble_anchor_util::GetPageInfoAnchorRect;
using password_manager::metrics_util::PasswordType;
namespace { namespace {
...@@ -813,7 +812,7 @@ void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) { ...@@ -813,7 +812,7 @@ void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) {
if (identity_info.show_change_password_buttons) { if (identity_info.show_change_password_buttons) {
header_->AddPasswordReuseButtons(); header_->AddPasswordReuseButtons();
} }
details_text_ = security_description->details;
header_->SetDetails(security_description->details); header_->SetDetails(security_description->details);
Layout(); Layout();
...@@ -919,21 +918,36 @@ void PageInfoBubbleView::DidChangeVisibleSecurityState() { ...@@ -919,21 +918,36 @@ void PageInfoBubbleView::DidChangeVisibleSecurityState() {
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
std::unique_ptr<PageInfoUI::SecurityDescription> std::unique_ptr<PageInfoUI::SecurityDescription>
PageInfoBubbleView::CreateSecurityDescriptionForPasswordReuse( PageInfoBubbleView::CreateSecurityDescriptionForPasswordReuse(
bool is_enterprise_password) const { PasswordType password_type) const {
std::unique_ptr<PageInfoUI::SecurityDescription> security_description( std::unique_ptr<PageInfoUI::SecurityDescription> security_description(
new PageInfoUI::SecurityDescription()); new PageInfoUI::SecurityDescription());
security_description->summary_style = SecuritySummaryColor::RED; security_description->summary_style = SecuritySummaryColor::RED;
security_description->summary = security_description->summary =
l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_SUMMARY); l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_SUMMARY);
// TODO(crbug/914410): Need to account for non-sync users.
auto* service = safe_browsing::ChromePasswordProtectionService:: auto* service = safe_browsing::ChromePasswordProtectionService::
GetPasswordProtectionService(profile_); GetPasswordProtectionService(profile_);
password_manager::metrics_util::PasswordType metrics_password_type;
switch (password_type) {
case (PasswordType::NON_GAIA_ENTERPRISE):
metrics_password_type =
password_manager::metrics_util::PasswordType::ENTERPRISE_PASSWORD;
break;
case (PasswordType::SYNC_GAIA):
metrics_password_type = password_manager::metrics_util::PasswordType::
PRIMARY_ACCOUNT_PASSWORD;
break;
case (PasswordType::NON_SYNC_GAIA):
metrics_password_type =
password_manager::metrics_util::PasswordType::OTHER_GAIA_PASSWORD;
break;
default:
metrics_password_type =
password_manager::metrics_util::PasswordType::PASSWORD_TYPE_UNKNOWN;
}
security_description->details = service->GetWarningDetailText( security_description->details = service->GetWarningDetailText(
is_enterprise_password service->GetPasswordProtectionReusedPasswordAccountType(
? service->GetPasswordProtectionReusedPasswordAccountType( metrics_password_type, service->username()));
PasswordType::ENTERPRISE_PASSWORD, service->username())
: service->GetPasswordProtectionReusedPasswordAccountType(
PasswordType::PRIMARY_ACCOUNT_PASSWORD, service->username()));
return security_description; return security_description;
} }
#endif #endif
......
...@@ -104,8 +104,12 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -104,8 +104,12 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase,
const security_state::VisibleSecurityState& visible_security_state, const security_state::VisibleSecurityState& visible_security_state,
PageInfoClosingCallback closing_callback); PageInfoClosingCallback closing_callback);
protected:
const base::string16 details_text() const { return details_text_; }
private: private:
friend class PageInfoBubbleViewBrowserTest; friend class PageInfoBubbleViewBrowserTest;
friend class PageInfoBubbleViewSyncBrowserTest;
friend class test::PageInfoBubbleViewTestApi; friend class test::PageInfoBubbleViewTestApi;
PageInfoBubbleView( PageInfoBubbleView(
...@@ -159,7 +163,7 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -159,7 +163,7 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase,
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
std::unique_ptr<PageInfoUI::SecurityDescription> std::unique_ptr<PageInfoUI::SecurityDescription>
CreateSecurityDescriptionForPasswordReuse( CreateSecurityDescriptionForPasswordReuse(
bool is_enterprise_password) const override; PageInfoUI::PasswordType password_type) const override;
#endif #endif
// Creates the contents of the |site_settings_view_|. The ownership of the // Creates the contents of the |site_settings_view_|. The ownership of the
...@@ -182,6 +186,9 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -182,6 +186,9 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase,
// The header section (containing security-related information). // The header section (containing security-related information).
BubbleHeaderView* header_ = nullptr; BubbleHeaderView* header_ = nullptr;
// The raw details of the status of the identity check for this site.
base::string16 details_text_ = base::string16();
// The view that contains the certificate, cookie, and permissions sections. // The view that contains the certificate, cookie, and permissions sections.
views::View* site_settings_view_ = nullptr; views::View* site_settings_view_ = nullptr;
......
...@@ -366,6 +366,13 @@ class PageInfoBubbleViewBrowserTest : public DialogBrowserTest { ...@@ -366,6 +366,13 @@ class PageInfoBubbleViewBrowserTest : public DialogBrowserTest {
return page_info_bubble_view->certificate_button_->title()->GetText(); return page_info_bubble_view->certificate_button_->title()->GetText();
} }
const base::string16 GetPageInfoBubbleViewDetailText() {
PageInfoBubbleView* page_info_bubble_view =
static_cast<PageInfoBubbleView*>(
PageInfoBubbleView::GetPageInfoBubbleForTesting());
return page_info_bubble_view->details_text();
}
private: private:
std::vector<PageInfoBubbleView::PageInfoBubbleViewID> expected_identifiers_; std::vector<PageInfoBubbleView::PageInfoBubbleViewID> expected_identifiers_;
...@@ -487,6 +494,9 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ...@@ -487,6 +494,9 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
helper->GetVisibleSecurityState(); helper->GetVisibleSecurityState();
ASSERT_EQ(security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE, ASSERT_EQ(security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE,
visible_security_state->malicious_content_status); visible_security_state->malicious_content_status);
ASSERT_EQ(l10n_util::GetStringUTF16(
IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_ENTERPRISE),
GetPageInfoBubbleViewDetailText());
// Verify these two buttons are showing. // Verify these two buttons are showing.
EXPECT_TRUE(change_password_button->GetVisible()); EXPECT_TRUE(change_password_button->GetVisible());
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/safe_browsing/password_protection/metrics_util.h" #include "components/safe_browsing/password_protection/metrics_util.h"
#include "components/signin/public/base/signin_pref_names.h" #include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/strings/grit/components_strings.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h" #include "components/sync/driver/sync_user_settings.h"
#include "components/sync/test/fake_server/fake_server_network_resources.h" #include "components/sync/test/fake_server/fake_server_network_resources.h"
...@@ -103,7 +105,7 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest { ...@@ -103,7 +105,7 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest {
username = info.email; username = info.email;
#endif #endif
if (username.empty()) { if (username.empty()) {
username = "user@example.com"; username = "user@gmail.com";
} }
std::unique_ptr<ProfileSyncServiceHarness> harness = std::unique_ptr<ProfileSyncServiceHarness> harness =
...@@ -124,7 +126,7 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest { ...@@ -124,7 +126,7 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest {
account_info.account_id = current_info.account_id; account_info.account_id = current_info.account_id;
account_info.gaia = current_info.gaia; account_info.gaia = current_info.gaia;
account_info.email = current_info.email; account_info.email = current_info.email;
account_info.hosted_domain = "domain.com"; account_info.hosted_domain = kNoHostedDomainFound;
signin::UpdateAccountInfoForAccount( signin::UpdateAccountInfoForAccount(
IdentityManagerFactory::GetForProfile(browser()->profile()), IdentityManagerFactory::GetForProfile(browser()->profile()),
account_info); account_info);
...@@ -132,6 +134,13 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest { ...@@ -132,6 +134,13 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest {
ASSERT_TRUE(harness->SetupSync()); ASSERT_TRUE(harness->SetupSync());
} }
const base::string16 GetPageInfoBubbleViewDetailText() {
PageInfoBubbleView* page_info_bubble_view =
static_cast<PageInfoBubbleView*>(
PageInfoBubbleView::GetPageInfoBubbleForTesting());
return page_info_bubble_view->details_text();
}
DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleViewSyncBrowserTest); DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleViewSyncBrowserTest);
}; };
...@@ -140,6 +149,8 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest { ...@@ -140,6 +149,8 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest {
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSyncBrowserTest, IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSyncBrowserTest,
VerifySignInPasswordReusePageInfoBubble) { VerifySignInPasswordReusePageInfoBubble) {
Profile* profile = browser()->profile(); Profile* profile = browser()->profile();
// PageInfo calls GetPasswordProtectionReusedPasswordAccountType which checks
// to see if the account is syncing.
SetupSyncForAccount(profile); SetupSyncForAccount(profile);
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
...@@ -150,11 +161,12 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSyncBrowserTest, ...@@ -150,11 +161,12 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSyncBrowserTest,
// SB_THREAT_TYPE_GAIA_PASSWORD_REUSE. // SB_THREAT_TYPE_GAIA_PASSWORD_REUSE.
safe_browsing::ChromePasswordProtectionService* service = safe_browsing:: safe_browsing::ChromePasswordProtectionService* service = safe_browsing::
ChromePasswordProtectionService::GetPasswordProtectionService(profile); ChromePasswordProtectionService::GetPasswordProtectionService(profile);
service->set_username("user@gmail.com");
content::WebContents* contents = content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
safe_browsing::ReusedPasswordAccountType account_type; safe_browsing::ReusedPasswordAccountType account_type;
account_type.set_account_type( account_type.set_account_type(
safe_browsing::ReusedPasswordAccountType::GSUITE); safe_browsing::ReusedPasswordAccountType::GMAIL);
account_type.set_is_account_syncing(true); account_type.set_is_account_syncing(true);
service->ShowModalWarning( service->ShowModalWarning(
contents, safe_browsing::RequestOutcome::UNKNOWN, contents, safe_browsing::RequestOutcome::UNKNOWN,
...@@ -175,6 +187,9 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSyncBrowserTest, ...@@ -175,6 +187,9 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSyncBrowserTest,
ASSERT_EQ( ASSERT_EQ(
security_state::MALICIOUS_CONTENT_STATUS_SIGNED_IN_SYNC_PASSWORD_REUSE, security_state::MALICIOUS_CONTENT_STATUS_SIGNED_IN_SYNC_PASSWORD_REUSE,
visible_security_state->malicious_content_status); visible_security_state->malicious_content_status);
ASSERT_EQ(
l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_SYNC),
GetPageInfoBubbleViewDetailText());
// Verify these two buttons are showing. // Verify these two buttons are showing.
EXPECT_TRUE(change_password_button->GetVisible()); EXPECT_TRUE(change_password_button->GetVisible());
......
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