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

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

Issue 2061593002: Fix crash when switching to a profile that cannot be opened (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug-614753-fix
Patch Set: Move DenyFilePermission to match the place in test_file_util.h Created 4 years, 5 months 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
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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/deferred_sequenced_task_runner.h" 14 #include "base/deferred_sequenced_task_runner.h"
15 #include "base/feature_list.h" 15 #include "base/feature_list.h"
16 #include "base/files/file_enumerator.h" 16 #include "base/files/file_enumerator.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/threading/sequenced_task_runner_handle.h"
23 #include "base/trace_event/trace_event.h" 24 #include "base/trace_event/trace_event.h"
24 #include "build/build_config.h" 25 #include "build/build_config.h"
25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 26 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
26 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" 27 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h"
27 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h" 29 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 30 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
30 #include "chrome/browser/download/download_service.h" 31 #include "chrome/browser/download/download_service.h"
31 #include "chrome/browser/download/download_service_factory.h" 32 #include "chrome/browser/download/download_service_factory.h"
32 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 if (success && !go_off_the_record) 1097 if (success && !go_off_the_record)
1097 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED); 1098 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED);
1098 1099
1099 // Perform initialization. 1100 // Perform initialization.
1100 if (success) { 1101 if (success) {
1101 DoFinalInit(profile, go_off_the_record); 1102 DoFinalInit(profile, go_off_the_record);
1102 if (go_off_the_record) 1103 if (go_off_the_record)
1103 profile = profile->GetOffTheRecordProfile(); 1104 profile = profile->GetOffTheRecordProfile();
1104 info->created = true; 1105 info->created = true;
1105 } else { 1106 } else {
1106 profile = NULL; 1107 profile = nullptr;
1108 // Unmap the profile from |profiles_info_|. Delete the profile
1109 // asynchronously because it may be referenced in some asynchronous tasks.
1110 base::SequencedTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
1111 info->profile.release());
1107 profiles_info_.erase(iter); 1112 profiles_info_.erase(iter);
1108 // TODO(yiyaoliu): This is temporary, remove it after it's not used. 1113 // TODO(yiyaoliu): This is temporary, remove it after it's not used.
1109 UMA_HISTOGRAM_COUNTS_100("UMA.ProfilesCount.AfterErase", 1114 UMA_HISTOGRAM_COUNTS_100("UMA.ProfilesCount.AfterErase",
1110 profiles_info_.size()); 1115 profiles_info_.size());
1111 } 1116 }
1112 1117
1113 if (profile) { 1118 if (profile) {
1114 // If this was the guest or system profile, finish setting its special 1119 // If this was the guest or system profile, finish setting its special
1115 // status. 1120 // status.
1116 if (profile->IsGuestSession() || profile->IsSystemProfile()) 1121 if (profile->IsGuestSession() || profile->IsSystemProfile())
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 } 1514 }
1510 1515
1511 ProfileManager::ProfileInfo::ProfileInfo( 1516 ProfileManager::ProfileInfo::ProfileInfo(
1512 Profile* profile, 1517 Profile* profile,
1513 bool created) 1518 bool created)
1514 : profile(profile), 1519 : profile(profile),
1515 created(created) { 1520 created(created) {
1516 } 1521 }
1517 1522
1518 ProfileManager::ProfileInfo::~ProfileInfo() { 1523 ProfileManager::ProfileInfo::~ProfileInfo() {
1519 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1524 if (profile)
1525 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1520 } 1526 }
1521 1527
1522 #if !defined(OS_ANDROID) 1528 #if !defined(OS_ANDROID)
1523 void ProfileManager::UpdateLastUser(Profile* last_active) { 1529 void ProfileManager::UpdateLastUser(Profile* last_active) {
1524 PrefService* local_state = g_browser_process->local_state(); 1530 PrefService* local_state = g_browser_process->local_state();
1525 DCHECK(local_state); 1531 DCHECK(local_state);
1526 // Only keep track of profiles that we are managing; tests may create others. 1532 // Only keep track of profiles that we are managing; tests may create others.
1527 // Also never consider the SystemProfile as "active". 1533 // Also never consider the SystemProfile as "active".
1528 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() && 1534 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() &&
1529 !last_active->IsSystemProfile()) { 1535 !last_active->IsSystemProfile()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1638
1633 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1639 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1634 if (!original_callback.is_null()) 1640 if (!original_callback.is_null())
1635 original_callback.Run(loaded_profile, status); 1641 original_callback.Run(loaded_profile, status);
1636 } 1642 }
1637 #endif // !defined(OS_ANDROID) 1643 #endif // !defined(OS_ANDROID)
1638 1644
1639 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1645 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1640 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1646 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1641 } 1647 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698