Commit a93f94f7 authored by Ramin Halavati's avatar Ramin Halavati Committed by Chromium LUCI CQ

Update PasswordManager for ephemeral Guest profiles.

Password manager client and and generated password leak pref are updated
to be disabled for ephemeral Guest profiles, similar to off-the-record
Guest profiles.

Please see go/ephemeral-guest-profiles for more context.

Bug: 1125474
Change-Id: I3a2187c25f5940047d61722769f8d286886818e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577501
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834672}
parent 45436b09
......@@ -311,9 +311,10 @@ bool ChromePasswordManagerClient::IsFillingEnabled(const GURL& url) const {
bool ChromePasswordManagerClient::IsFillingFallbackEnabled(
const GURL& url) const {
return IsFillingEnabled(url) &&
!Profile::FromBrowserContext(web_contents()->GetBrowserContext())
->IsGuestSession();
const Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
return IsFillingEnabled(url) && !profile->IsGuestSession() &&
!profile->IsEphemeralGuestProfile();
}
bool ChromePasswordManagerClient::PromptUserToSaveOrUpdatePassword(
......@@ -714,7 +715,13 @@ void ChromePasswordManagerClient::PromptUserToEnableAutosignin() {
}
bool ChromePasswordManagerClient::IsIncognito() const {
return web_contents()->GetBrowserContext()->IsOffTheRecord();
// TODO(https://crbug.com/1125474): After deprecating off-the-record Guest
// profile, update this function for better readability.
content::BrowserContext* browser_context =
web_contents()->GetBrowserContext();
const Profile* profile = Profile::FromBrowserContext(browser_context);
return browser_context->IsOffTheRecord() ||
profile->IsEphemeralGuestProfile();
}
const password_manager::PasswordManager*
......
......@@ -399,7 +399,7 @@ TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) {
}
TEST_F(ChromePasswordManagerClientTest,
SavingAndFillingDisabledConditionsInIncognito) {
SavingAndFillingDisabledConditionsInOffTheRecord) {
std::unique_ptr<WebContents> incognito_web_contents(
content::WebContentsTester::CreateTestWebContents(
profile()->GetPrimaryOTRProfile(), nullptr));
......@@ -423,6 +423,9 @@ TEST_F(ChromePasswordManagerClientTest,
// In guest mode saving is disabled, filling is enabled but there is in fact
// nothing to fill, manual filling is disabled.
base::test::ScopedFeatureList scoped_feature_list;
TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list, /*enabled=*/false);
profile()->SetGuestSession(true);
profile()->GetPrimaryOTRProfile()->AsTestingProfile()->SetGuestSession(true);
EXPECT_FALSE(client->IsSavingAndFillingEnabled(kUrlOn));
......@@ -430,6 +433,30 @@ TEST_F(ChromePasswordManagerClientTest,
EXPECT_FALSE(client->IsFillingFallbackEnabled(kUrlOn));
}
TEST_F(ChromePasswordManagerClientTest,
SavingAndFillingDisabledConditionsInEphemeralGuest) {
base::test::ScopedFeatureList scoped_feature_list;
if (!TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list, /*enabled=*/true)) {
return;
}
std::unique_ptr<WebContents> web_contents =
content::WebContentsTester::CreateTestWebContents(profile(), nullptr);
auto client =
std::make_unique<MockChromePasswordManagerClient>(web_contents.get());
EXPECT_CALL(*client, GetMainFrameCertStatus()).WillRepeatedly(Return(0));
// In guest mode saving is disabled, filling is enabled but there is in fact
// nothing to fill, manual filling is disabled.
const GURL kUrlOn("https://accounts.google.com");
profile()->SetGuestSession(true);
profile()->AsTestingProfile()->SetGuestSession(true);
EXPECT_FALSE(client->IsSavingAndFillingEnabled(kUrlOn));
EXPECT_TRUE(client->IsFillingEnabled(kUrlOn));
EXPECT_FALSE(client->IsFillingFallbackEnabled(kUrlOn));
}
TEST_F(ChromePasswordManagerClientTest, SavingDependsOnAutomation) {
// Test that saving passwords UI is disabled for automated tests.
ChromePasswordManagerClient* client = GetClient();
......
......@@ -20,7 +20,7 @@ namespace {
// Returns whether a primary account is present and syncing successfully.
bool IsUserSignedInAndSyncing(Profile* profile) {
if (profile->IsGuestSession())
if (profile->IsGuestSession() || profile->IsEphemeralGuestProfile())
return false;
auto* identity_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