Commit 7b6bec63 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Prevent browser creation for profiles that are scheduled for deletion.

Profiles that are scheduled for deletion cannot be used to create new
browser windows.

Bug: 1141551, 1125474
Change-Id: I0239b4b51c09be7dc0ff2c3189972dfa75a2ca00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2497446
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822170}
parent c6225e49
......@@ -269,12 +269,6 @@ void CancelProfileDeletion(const base::FilePath& path) {
}
#endif
bool IsProfileDirectoryMarkedForDeletion(const base::FilePath& profile_path) {
auto it = ProfilesToDelete().find(profile_path);
return it != ProfilesToDelete().end() &&
it->second == ProfileDeletionStage::MARKED;
}
// Physically remove deleted profile directories from disk.
void NukeProfileFromDisk(const base::FilePath& profile_path) {
// Delete both the profile directory and its corresponding cache.
......@@ -382,6 +376,14 @@ ProfileManager::~ProfileManager() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
// static
bool ProfileManager::IsProfileDirectoryMarkedForDeletion(
const base::FilePath& profile_path) {
const auto it = ProfilesToDelete().find(profile_path);
return it != ProfilesToDelete().end() &&
it->second == ProfileDeletionStage::MARKED;
}
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
// static
void ProfileManager::ShutdownSessionServices() {
......
......@@ -224,6 +224,10 @@ class ProfileManager : public content::NotificationObserver,
static void CleanUpGuestProfile();
#endif
// Returns if profile is marked for deletion.
static bool IsProfileDirectoryMarkedForDeletion(
const base::FilePath& profile_dir);
// Autoloads profiles if they are running background apps.
void AutoloadProfiles();
......
......@@ -309,9 +309,17 @@ IN_PROC_BROWSER_TEST_P(GuestProfileWindowBrowserTest,
// Open a new guest browser window. Since this is a separate session, the find
// in page text should have been cleared (along with all other browsing data).
profiles::FindOrCreateNewWindowForProfile(
guest_profile, chrome::startup::IS_NOT_PROCESS_STARTUP,
chrome::startup::IS_NOT_FIRST_RUN, true /*always_create*/);
// For ephemeral Guest profiles, after closing the last Guest browser the
// Guest profile is scheduled for deletion and is not considered a Guest
// profile anymore. Therefore the next Guest window requires opening a new
// browser and refreshing the profile object.
if (IsEphemeral()) {
guest_profile = CreateGuestBrowser()->profile();
} else {
profiles::FindOrCreateNewWindowForProfile(
guest_profile, chrome::startup::IS_NOT_PROCESS_STARTUP,
chrome::startup::IS_NOT_FIRST_RUN, true /*always_create*/);
}
EXPECT_EQ(base::string16(),
FindBarStateFactory::GetForBrowserContext(guest_profile)
->GetSearchPrepopulateText());
......
......@@ -73,6 +73,7 @@
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_destroyer.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/repost_form_warning_controller.h"
......@@ -326,7 +327,9 @@ const extensions::Extension* GetExtensionForOrigin(
bool CanCreateBrowserForProfile(Profile* profile) {
return IncognitoModePrefs::CanOpenBrowser(profile) &&
(!profile->IsGuestSession() || profile->IsOffTheRecord()) &&
profile->AllowsBrowserWindows();
profile->AllowsBrowserWindows() &&
!ProfileManager::IsProfileDirectoryMarkedForDeletion(
profile->GetPath());
}
bool IsOnKioskSplashScreen() {
#if defined(OS_CHROMEOS)
......
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