Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 2538753002: Profile deletion: forbid fallback to guest profile. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } 1309 }
1310 return profile; 1310 return profile;
1311 } 1311 }
1312 1312
1313 #if !defined(OS_ANDROID) 1313 #if !defined(OS_ANDROID)
1314 void ProfileManager::EnsureActiveProfileExistsBeforeDeletion( 1314 void ProfileManager::EnsureActiveProfileExistsBeforeDeletion(
1315 const CreateCallback& callback, const base::FilePath& profile_dir) { 1315 const CreateCallback& callback, const base::FilePath& profile_dir) {
1316 // In case we delete non-active profile, just proceed. 1316 // In case we delete non-active profile, just proceed.
1317 const base::FilePath last_used_profile = 1317 const base::FilePath last_used_profile =
1318 GetLastUsedProfileDir(user_data_dir_); 1318 GetLastUsedProfileDir(user_data_dir_);
1319 const base::FilePath guest_profile_path = GetGuestProfilePath();
1319 if (last_used_profile != profile_dir && 1320 if (last_used_profile != profile_dir &&
1320 last_used_profile != GetGuestProfilePath()) { 1321 last_used_profile != guest_profile_path) {
1321 FinishDeletingProfile(profile_dir, last_used_profile); 1322 FinishDeletingProfile(profile_dir, last_used_profile);
1322 return; 1323 return;
1323 } 1324 }
1324 1325
1325 // Search for an active browser and use its profile as active if possible. 1326 // Search for an active browser and use its profile as active if possible.
1326 for (Browser* browser : *BrowserList::GetInstance()) { 1327 for (Browser* browser : *BrowserList::GetInstance()) {
1327 Profile* profile = browser->profile(); 1328 Profile* profile = browser->profile();
1328 base::FilePath cur_path = profile->GetPath(); 1329 base::FilePath cur_path = profile->GetPath();
1329 if (cur_path != profile_dir && 1330 if (cur_path != profile_dir &&
1331 cur_path != guest_profile_path &&
1330 !profile->IsLegacySupervised() && 1332 !profile->IsLegacySupervised() &&
1331 !IsProfileDirectoryMarkedForDeletion(cur_path)) { 1333 !IsProfileDirectoryMarkedForDeletion(cur_path)) {
1332 OnNewActiveProfileLoaded(profile_dir, cur_path, callback, profile, 1334 OnNewActiveProfileLoaded(profile_dir, cur_path, callback, profile,
1333 Profile::CREATE_STATUS_INITIALIZED); 1335 Profile::CREATE_STATUS_INITIALIZED);
1334 return; 1336 return;
1335 } 1337 }
1336 } 1338 }
1337 1339
1338 // There no valid browsers to fallback, search for any existing valid profile. 1340 // There no valid browsers to fallback, search for any existing valid profile.
1339 ProfileAttributesStorage& storage = GetProfileAttributesStorage(); 1341 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1340 base::FilePath fallback_profile_path; 1342 base::FilePath fallback_profile_path;
1341 std::vector<ProfileAttributesEntry*> entries = 1343 std::vector<ProfileAttributesEntry*> entries =
1342 storage.GetAllProfilesAttributes(); 1344 storage.GetAllProfilesAttributes();
1343 for (ProfileAttributesEntry* entry : entries) { 1345 for (ProfileAttributesEntry* entry : entries) {
1344 base::FilePath cur_path = entry->GetPath(); 1346 base::FilePath cur_path = entry->GetPath();
1345 // Make sure that this profile is not pending deletion, and is not 1347 // Make sure that this profile is not pending deletion, and is not
1346 // legacy-supervised. 1348 // legacy-supervised.
1347 if (cur_path != profile_dir && 1349 if (cur_path != profile_dir &&
1350 cur_path != guest_profile_path &&
1348 !entry->IsLegacySupervised() && 1351 !entry->IsLegacySupervised() &&
1349 !IsProfileDirectoryMarkedForDeletion(cur_path)) { 1352 !IsProfileDirectoryMarkedForDeletion(cur_path)) {
1350 fallback_profile_path = cur_path; 1353 fallback_profile_path = cur_path;
1351 break; 1354 break;
1352 } 1355 }
1353 } 1356 }
1354 1357
1355 // If we're deleting the last (non-legacy-supervised) profile, then create a 1358 // If we're deleting the last (non-legacy-supervised) profile, then create a
1356 // new profile in its place. Load existing profile otherwise. 1359 // new profile in its place. Load existing profile otherwise.
1357 std::string new_avatar_url; 1360 std::string new_avatar_url;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 1667
1665 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1668 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1666 if (!original_callback.is_null()) 1669 if (!original_callback.is_null())
1667 original_callback.Run(loaded_profile, status); 1670 original_callback.Run(loaded_profile, status);
1668 } 1671 }
1669 #endif // !defined(OS_ANDROID) 1672 #endif // !defined(OS_ANDROID)
1670 1673
1671 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1674 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1672 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1675 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1673 } 1676 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698