| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 return relative_profile_dir; | 303 return relative_profile_dir; |
| 304 } | 304 } |
| 305 | 305 |
| 306 Profile* ProfileManager::GetLastUsedProfile(const FilePath& user_data_dir) { | 306 Profile* ProfileManager::GetLastUsedProfile(const FilePath& user_data_dir) { |
| 307 #if defined(OS_CHROMEOS) | 307 #if defined(OS_CHROMEOS) |
| 308 // Use default login profile if user has not logged in yet. | 308 // Use default login profile if user has not logged in yet. |
| 309 if (!logged_in_) | 309 if (!logged_in_) |
| 310 return GetDefaultProfile(user_data_dir); | 310 return GetDefaultProfile(user_data_dir); |
| 311 #endif | 311 #endif |
| 312 | 312 |
| 313 return GetProfile(GetLastUsedProfileDir(user_data_dir)); |
| 314 } |
| 315 |
| 316 FilePath ProfileManager::GetLastUsedProfileDir(const FilePath& user_data_dir) { |
| 313 FilePath last_used_profile_dir(user_data_dir); | 317 FilePath last_used_profile_dir(user_data_dir); |
| 314 std::string last_profile_used; | 318 std::string last_used_profile; |
| 315 PrefService* local_state = g_browser_process->local_state(); | 319 PrefService* local_state = g_browser_process->local_state(); |
| 316 DCHECK(local_state); | 320 DCHECK(local_state); |
| 317 | 321 |
| 318 if (local_state->HasPrefPath(prefs::kProfileLastUsed)) | 322 if (local_state->HasPrefPath(prefs::kProfileLastUsed)) { |
| 319 last_profile_used = local_state->GetString(prefs::kProfileLastUsed); | 323 return last_used_profile_dir.AppendASCII( |
| 320 last_used_profile_dir = last_profile_used.empty() ? | 324 local_state->GetString(prefs::kProfileLastUsed)); |
| 321 last_used_profile_dir.AppendASCII(chrome::kInitialProfile) : | 325 } |
| 322 last_used_profile_dir.AppendASCII(last_profile_used); | 326 |
| 323 return GetProfile(last_used_profile_dir); | 327 return last_used_profile_dir.AppendASCII(chrome::kInitialProfile); |
| 324 } | 328 } |
| 325 | 329 |
| 326 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles( | 330 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles( |
| 327 const FilePath& user_data_dir) { | 331 const FilePath& user_data_dir) { |
| 328 PrefService* local_state = g_browser_process->local_state(); | 332 PrefService* local_state = g_browser_process->local_state(); |
| 329 DCHECK(local_state); | 333 DCHECK(local_state); |
| 330 | 334 |
| 331 std::vector<Profile*> to_return; | 335 std::vector<Profile*> to_return; |
| 332 if (local_state->HasPrefPath(prefs::kProfilesLastActive)) { | 336 if (local_state->HasPrefPath(prefs::kProfilesLastActive)) { |
| 333 const ListValue* profile_list = | 337 const ListValue* profile_list = |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 ProfileManager::ProfileInfo::ProfileInfo( | 1075 ProfileManager::ProfileInfo::ProfileInfo( |
| 1072 Profile* profile, | 1076 Profile* profile, |
| 1073 bool created) | 1077 bool created) |
| 1074 : profile(profile), | 1078 : profile(profile), |
| 1075 created(created) { | 1079 created(created) { |
| 1076 } | 1080 } |
| 1077 | 1081 |
| 1078 ProfileManager::ProfileInfo::~ProfileInfo() { | 1082 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1079 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1083 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1080 } | 1084 } |
| OLD | NEW |