OLD | NEW |
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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const CreateCallback& callback, | 494 const CreateCallback& callback, |
495 const string16& name, | 495 const string16& name, |
496 const string16& icon_url, | 496 const string16& icon_url, |
497 bool is_managed) { | 497 bool is_managed) { |
498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
499 | 499 |
500 // Make sure that this profile is not pending deletion. | 500 // Make sure that this profile is not pending deletion. |
501 if (std::find(ProfilesToDelete().begin(), ProfilesToDelete().end(), | 501 if (std::find(ProfilesToDelete().begin(), ProfilesToDelete().end(), |
502 profile_path) != ProfilesToDelete().end()) { | 502 profile_path) != ProfilesToDelete().end()) { |
503 if (!callback.is_null()) | 503 if (!callback.is_null()) |
504 callback.Run(NULL, Profile::CREATE_STATUS_FAIL); | 504 callback.Run(NULL, Profile::CREATE_STATUS_LOCAL_FAIL); |
505 return; | 505 return; |
506 } | 506 } |
507 | 507 |
508 // Create the profile if needed and collect its ProfileInfo. | 508 // Create the profile if needed and collect its ProfileInfo. |
509 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path); | 509 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path); |
510 ProfileInfo* info = NULL; | 510 ProfileInfo* info = NULL; |
511 | 511 |
512 if (iter != profiles_info_.end()) { | 512 if (iter != profiles_info_.end()) { |
513 info = iter->second.get(); | 513 info = iter->second.get(); |
514 } else { | 514 } else { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 profiles_info_.erase(iter); | 878 profiles_info_.erase(iter); |
879 } | 879 } |
880 | 880 |
881 // Invoke CREATED callback for incognito profiles. | 881 // Invoke CREATED callback for incognito profiles. |
882 if (profile && go_off_the_record) | 882 if (profile && go_off_the_record) |
883 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED); | 883 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED); |
884 | 884 |
885 // Invoke INITIALIZED or FAIL for all profiles. | 885 // Invoke INITIALIZED or FAIL for all profiles. |
886 RunCallbacks(callbacks, profile, | 886 RunCallbacks(callbacks, profile, |
887 profile ? Profile::CREATE_STATUS_INITIALIZED : | 887 profile ? Profile::CREATE_STATUS_INITIALIZED : |
888 Profile::CREATE_STATUS_FAIL); | 888 Profile::CREATE_STATUS_LOCAL_FAIL); |
889 } | 889 } |
890 | 890 |
891 base::FilePath ProfileManager::GenerateNextProfileDirectoryPath() { | 891 base::FilePath ProfileManager::GenerateNextProfileDirectoryPath() { |
892 PrefService* local_state = g_browser_process->local_state(); | 892 PrefService* local_state = g_browser_process->local_state(); |
893 DCHECK(local_state); | 893 DCHECK(local_state); |
894 | 894 |
895 DCHECK(IsMultipleProfilesEnabled()); | 895 DCHECK(IsMultipleProfilesEnabled()); |
896 | 896 |
897 // Create the next profile in the next available directory slot. | 897 // Create the next profile in the next available directory slot. |
898 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); | 898 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 ProfileManager::ProfileInfo::ProfileInfo( | 1158 ProfileManager::ProfileInfo::ProfileInfo( |
1159 Profile* profile, | 1159 Profile* profile, |
1160 bool created) | 1160 bool created) |
1161 : profile(profile), | 1161 : profile(profile), |
1162 created(created) { | 1162 created(created) { |
1163 } | 1163 } |
1164 | 1164 |
1165 ProfileManager::ProfileInfo::~ProfileInfo() { | 1165 ProfileManager::ProfileInfo::~ProfileInfo() { |
1166 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1166 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1167 } | 1167 } |
OLD | NEW |