| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 void CheckCryptohomeIsMounted(chromeos::DBusMethodCallStatus call_status, | 191 void CheckCryptohomeIsMounted(chromeos::DBusMethodCallStatus call_status, |
| 192 bool is_mounted) { | 192 bool is_mounted) { |
| 193 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { | 193 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { |
| 194 LOG(ERROR) << "IsMounted call failed."; | 194 LOG(ERROR) << "IsMounted call failed."; |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 if (!is_mounted) | 197 if (!is_mounted) |
| 198 LOG(ERROR) << "Cryptohome is not mounted."; | 198 LOG(ERROR) << "Cryptohome is not mounted."; |
| 199 } | 199 } |
| 200 | 200 |
| 201 // TODO(nkostylev): Remove this hack when http://crbug.com/224291 is fixed. | |
| 202 // Now user homedirs are mounted to /home/user which is different from | |
| 203 // user data dir (/home/chronos). | |
| 204 base::FilePath GetChromeOSProfileDir(const base::FilePath& path) { | |
| 205 base::FilePath profile_dir(FILE_PATH_LITERAL("/home/user/")); | |
| 206 profile_dir = profile_dir.Append(path); | |
| 207 return profile_dir; | |
| 208 } | |
| 209 #endif | 201 #endif |
| 210 | 202 |
| 211 } // namespace | 203 } // namespace |
| 212 | 204 |
| 213 #if defined(ENABLE_SESSION_SERVICE) | 205 #if defined(ENABLE_SESSION_SERVICE) |
| 214 // static | 206 // static |
| 215 void ProfileManager::ShutdownSessionServices() { | 207 void ProfileManager::ShutdownSessionServices() { |
| 216 ProfileManager* pm = g_browser_process->profile_manager(); | 208 ProfileManager* pm = g_browser_process->profile_manager(); |
| 217 if (!pm) // Is NULL when running unit tests. | 209 if (!pm) // Is NULL when running unit tests. |
| 218 return; | 210 return; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 NOTREACHED(); | 334 NOTREACHED(); |
| 343 return base::FilePath(""); | 335 return base::FilePath(""); |
| 344 } | 336 } |
| 345 // In case of multi-profiles ignore --login-profile switch. | 337 // In case of multi-profiles ignore --login-profile switch. |
| 346 // TODO(nkostylev): Some cases like Guest mode will have empty username_hash | 338 // TODO(nkostylev): Some cases like Guest mode will have empty username_hash |
| 347 // so default kLoginProfile dir will be used. | 339 // so default kLoginProfile dir will be used. |
| 348 std::string user_id_hash = g_browser_process->platform_part()-> | 340 std::string user_id_hash = g_browser_process->platform_part()-> |
| 349 profile_helper()->active_user_id_hash(); | 341 profile_helper()->active_user_id_hash(); |
| 350 if (command_line.HasSwitch(switches::kMultiProfiles) && | 342 if (command_line.HasSwitch(switches::kMultiProfiles) && |
| 351 !user_id_hash.empty()) { | 343 !user_id_hash.empty()) { |
| 352 profile_dir = base::FilePath(user_id_hash); | 344 profile_dir = g_browser_process->platform_part()-> |
| 345 profile_helper()->GetActiveUserProfileDir(); |
| 353 } | 346 } |
| 354 relative_profile_dir = relative_profile_dir.Append(profile_dir); | 347 relative_profile_dir = relative_profile_dir.Append(profile_dir); |
| 355 return relative_profile_dir; | 348 return relative_profile_dir; |
| 356 } | 349 } |
| 357 #endif | 350 #endif |
| 358 // TODO(mirandac): should not automatically be default profile. | 351 // TODO(mirandac): should not automatically be default profile. |
| 359 relative_profile_dir = | 352 relative_profile_dir = |
| 360 relative_profile_dir.AppendASCII(chrome::kInitialProfile); | 353 relative_profile_dir.AppendASCII(chrome::kInitialProfile); |
| 361 return relative_profile_dir; | 354 return relative_profile_dir; |
| 362 } | 355 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 } | 402 } |
| 410 } | 403 } |
| 411 return to_return; | 404 return to_return; |
| 412 } | 405 } |
| 413 | 406 |
| 414 Profile* ProfileManager::GetDefaultProfile( | 407 Profile* ProfileManager::GetDefaultProfile( |
| 415 const base::FilePath& user_data_dir) { | 408 const base::FilePath& user_data_dir) { |
| 416 #if defined(OS_CHROMEOS) | 409 #if defined(OS_CHROMEOS) |
| 417 base::FilePath default_profile_dir(user_data_dir); | 410 base::FilePath default_profile_dir(user_data_dir); |
| 418 if (logged_in_) { | 411 if (logged_in_) { |
| 419 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles) && | 412 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); |
| 420 base::chromeos::IsRunningOnChromeOS()) { | |
| 421 // TODO(nkostylev): Change to [user_data_dir]/profile-[hash] | |
| 422 default_profile_dir = GetChromeOSProfileDir(GetInitialProfileDir()); | |
| 423 } else { | |
| 424 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); | |
| 425 } | |
| 426 } else { | 413 } else { |
| 427 default_profile_dir = GetDefaultProfileDir(user_data_dir); | 414 default_profile_dir = GetDefaultProfileDir(user_data_dir); |
| 428 } | 415 } |
| 429 #else | 416 #else |
| 430 base::FilePath default_profile_dir(user_data_dir); | 417 base::FilePath default_profile_dir(user_data_dir); |
| 431 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); | 418 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); |
| 432 #endif | 419 #endif |
| 433 #if defined(OS_CHROMEOS) | 420 #if defined(OS_CHROMEOS) |
| 434 if (!logged_in_) { | 421 if (!logged_in_) { |
| 435 Profile* profile = GetProfile(default_profile_dir); | 422 Profile* profile = GetProfile(default_profile_dir); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 // static | 530 // static |
| 544 void ProfileManager::CreateDefaultProfileAsync(const CreateCallback& callback) { | 531 void ProfileManager::CreateDefaultProfileAsync(const CreateCallback& callback) { |
| 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 532 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 546 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 533 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 547 | 534 |
| 548 base::FilePath default_profile_dir = profile_manager->user_data_dir_; | 535 base::FilePath default_profile_dir = profile_manager->user_data_dir_; |
| 549 // TODO(mirandac): current directory will not always be default in the future | 536 // TODO(mirandac): current directory will not always be default in the future |
| 550 default_profile_dir = default_profile_dir.Append( | 537 default_profile_dir = default_profile_dir.Append( |
| 551 profile_manager->GetInitialProfileDir()); | 538 profile_manager->GetInitialProfileDir()); |
| 552 | 539 |
| 553 #if defined(OS_CHROMEOS) | |
| 554 // TODO(nkostylev): Change to [user_data_dir]/profile-[hash] | |
| 555 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles) && | |
| 556 base::chromeos::IsRunningOnChromeOS()) { | |
| 557 default_profile_dir = GetChromeOSProfileDir( | |
| 558 profile_manager->GetInitialProfileDir()); | |
| 559 } | |
| 560 #endif | |
| 561 | |
| 562 // Chrome OS specific note: since we pass string16() here as the icon_url, | 540 // Chrome OS specific note: since we pass string16() here as the icon_url, |
| 563 // profile cache information will not get updated with the is_managed value | 541 // profile cache information will not get updated with the is_managed value |
| 564 // so we're fine with passing all default values here. | 542 // so we're fine with passing all default values here. |
| 565 // On Chrome OS |is_managed| preference will get initialized in | 543 // On Chrome OS |is_managed| preference will get initialized in |
| 566 // Profile::CREATE_STATUS_CREATED callback. | 544 // Profile::CREATE_STATUS_CREATED callback. |
| 567 profile_manager->CreateProfileAsync( | 545 profile_manager->CreateProfileAsync( |
| 568 default_profile_dir, callback, string16(), string16(), false); | 546 default_profile_dir, callback, string16(), string16(), false); |
| 569 } | 547 } |
| 570 | 548 |
| 571 bool ProfileManager::AddProfile(Profile* profile) { | 549 bool ProfileManager::AddProfile(Profile* profile) { |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 ProfileManager::ProfileInfo::ProfileInfo( | 1163 ProfileManager::ProfileInfo::ProfileInfo( |
| 1186 Profile* profile, | 1164 Profile* profile, |
| 1187 bool created) | 1165 bool created) |
| 1188 : profile(profile), | 1166 : profile(profile), |
| 1189 created(created) { | 1167 created(created) { |
| 1190 } | 1168 } |
| 1191 | 1169 |
| 1192 ProfileManager::ProfileInfo::~ProfileInfo() { | 1170 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1193 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1171 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1194 } | 1172 } |
| OLD | NEW |