Commit 278e90da authored by Sahel Sharify's avatar Sahel Sharify Committed by Chromium LUCI CQ

[Seriff] Revert "Update ephemeral Guest Profile handling when policy is set."

This reverts commit 46d850ca.

Reason for revert: The newly added TestsForceEphemeralProfilesPolicy
times out on Windows.
https://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=AllGuestProfileTypes%2FEphemeralGuestProfilePolicyTest.TestsForceEphemeralProfilesPolicy%2F1&testType=browser_tests

Original change's description:
> Update ephemeral Guest Profile handling when policy is set.
>
> When |ForceEphemeralProfiles| is set to false, ProfileManager cannot
> overwrite the pref for ephemeral Guest profiles.
> To overcome the issue, a new |IsEphemeral| function is added to the
> ProfileManager which not only checks for the pref value, but also
> consider profile type.
>
> Bug: 1125474
> Change-Id: Ieb22c22d4ed5ac63abe0c01096e10397eb0b6531
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2584025
> Reviewed-by: Dominic Battré <battre@chromium.org>
> Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
> Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#840017}

TBR=battre@chromium.org,msarda@chromium.org,rhalavati@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1125474
Change-Id: Ifcd0bfe22022db12e0d042ec734573256a59de1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2605358Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Commit-Queue: Sahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840233}
parent f0fce1b6
......@@ -363,11 +363,6 @@ bool IsLoggedIn() {
}
#endif
bool IsEphemeral(Profile* profile) {
return profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) ||
profile->IsEphemeralGuestProfile();
}
} // namespace
ProfileManager::ProfileManager(const base::FilePath& user_data_dir)
......@@ -1559,7 +1554,8 @@ void ProfileManager::RemoveProfile(const base::FilePath& profile_dir) {
DCHECK(base::Contains(profiles_info_, profile_dir));
Profile* profile = GetProfileByPath(profile_dir);
bool ephemeral = IsEphemeral(profile);
bool ephemeral =
profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles);
// Remove from |profiles_info_|, eventually causing the Profile object's
// destruction.
......@@ -1908,10 +1904,12 @@ void ProfileManager::AddProfileToStorage(Profile* profile) {
storage.GetProfileAttributesWithPath(profile->GetPath(), &entry);
DCHECK(has_entry);
if (profile->IsEphemeralGuestProfile())
if (profile->IsEphemeralGuestProfile()) {
profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true);
entry->SetIsGuest(true);
}
if (IsEphemeral(profile))
if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles))
entry->SetIsEphemeral(true);
entry->SetSignedInWithCredentialProvider(
......@@ -1968,7 +1966,7 @@ void ProfileManager::SaveActiveProfiles() {
// Some profiles might become ephemeral after they are created.
// Don't persist the System Profile as one of the last actives, it should
// never get a browser.
if (!IsEphemeral(*it) &&
if (!(*it)->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) &&
profile_paths.find(profile_path) == profile_paths.end() &&
profile_path !=
base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) {
......@@ -1983,8 +1981,10 @@ void ProfileManager::OnBrowserOpened(Browser* browser) {
DCHECK(browser);
Profile* profile = browser->profile();
DCHECK(profile);
if (!profile->IsOffTheRecord() && !IsEphemeral(profile) &&
!browser->is_type_app() && ++browser_counts_[profile] == 1) {
bool is_ephemeral =
profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles);
if (!profile->IsOffTheRecord() && !is_ephemeral && !browser->is_type_app() &&
++browser_counts_[profile] == 1) {
active_profiles_.push_back(profile);
SaveActiveProfiles();
}
......@@ -2031,7 +2031,7 @@ void ProfileManager::OnBrowserClosed(Browser* browser) {
base::FilePath path = profile->GetPath();
if (IsProfileDirectoryMarkedForDeletion(path)) {
// Do nothing if the profile is already being deleted.
} else if (IsEphemeral(profile)) {
} else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
// Avoid scheduling deletion if it's a testing profile that is not
// registered with profile manager.
if (profile->AsTestingProfile() &&
......@@ -2111,7 +2111,7 @@ void ProfileManager::BrowserListObserver::OnBrowserSetLastActive(
// Don't remember ephemeral profiles as last because they are not going to
// persist after restart.
if (IsEphemeral(last_active))
if (last_active->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles))
return;
profile_manager_->UpdateLastUser(last_active);
......
......@@ -17,7 +17,6 @@
#include "build/chromeos_buildflags.h"
#include "chrome/browser/apps/platform_apps/shortcut_manager.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/policy/policy_test_utils.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -26,7 +25,6 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_browser_process.h"
......@@ -35,8 +33,6 @@
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/test/browser_test.h"
......@@ -752,41 +748,3 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, IncognitoProfile) {
->GetFilePath(prefs::kSaveFileDefaultDirectory)
.empty());
}
#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
class EphemeralGuestProfilePolicyTest
: public policy::PolicyTest,
public ::testing::WithParamInterface<bool> {
public:
EphemeralGuestProfilePolicyTest() {
scoped_feature_list_.InitAndEnableFeature(
features::kEnableEphemeralGuestProfilesOnDesktop);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
IN_PROC_BROWSER_TEST_P(EphemeralGuestProfilePolicyTest,
TestsForceEphemeralProfilesPolicy) {
policy::PolicyMap policies;
SetPolicy(&policies, policy::key::kForceEphemeralProfiles,
base::Value(GetParam()));
UpdateProviderPolicy(policies);
Profile* guest = CreateGuestBrowser()->profile();
EXPECT_TRUE(guest->IsEphemeralGuestProfile());
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileAttributesEntry* entry;
EXPECT_TRUE(profile_manager->GetProfileAttributesStorage()
.GetProfileAttributesWithPath(guest->GetPath(), &entry));
EXPECT_TRUE(entry->IsGuest());
EXPECT_TRUE(entry->IsEphemeral());
}
INSTANTIATE_TEST_SUITE_P(AllGuestProfileTypes,
EphemeralGuestProfilePolicyTest,
/*policy_is_enforced=*/testing::Bool());
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
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