| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 user_manager::UserManager* manager = user_manager::UserManager::Get(); | 349 user_manager::UserManager* manager = user_manager::UserManager::Get(); |
| 350 const user_manager::User* user = manager->GetActiveUser(); | 350 const user_manager::User* user = manager->GetActiveUser(); |
| 351 // To avoid an endless loop (crbug.com/334098) we have to additionally check | 351 // To avoid an endless loop (crbug.com/334098) we have to additionally check |
| 352 // if the profile of the user was already created. If the profile was not yet | 352 // if the profile of the user was already created. If the profile was not yet |
| 353 // created we load the profile using the profile directly. | 353 // created we load the profile using the profile directly. |
| 354 // TODO: This should be cleaned up with the new profile manager. | 354 // TODO: This should be cleaned up with the new profile manager. |
| 355 if (user && user->is_profile_created()) | 355 if (user && user->is_profile_created()) |
| 356 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 356 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
| 357 | 357 |
| 358 #endif | 358 #endif |
| 359 #if !defined(OS_WIN) |
| 359 Profile* profile = | 360 Profile* profile = |
| 360 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 361 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
| 361 profile_manager->user_data_dir()); | 362 profile_manager->user_data_dir()); |
| 362 // |profile| could be null if the user doesn't have a profile yet and the path | 363 // |profile| could be null if the user doesn't have a profile yet and the path |
| 363 // is on a read-only volume (preventing Chrome from making a new one). | 364 // is on a read-only volume (preventing Chrome from making a new one). |
| 364 // However, most callers of this function immediately dereference the result | 365 // However, most callers of this function immediately dereference the result |
| 365 // which would lead to crashes in a variety of call sites. Assert here to | 366 // which would lead to crashes in a variety of call sites. Assert here to |
| 366 // figure out how common this is. http://crbug.com/383019 | 367 // figure out how common this is. http://crbug.com/383019 |
| 367 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe(); | 368 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe(); |
| 368 return profile; | 369 return profile; |
| 370 #else |
| 371 return profile_manager->GetProfile( |
| 372 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir())); |
| 373 #endif |
| 369 } | 374 } |
| 370 | 375 |
| 371 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { | 376 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { |
| 372 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); | 377 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); |
| 373 | 378 |
| 374 // If the profile is already loaded (e.g., chrome.exe launched twice), just | 379 // If the profile is already loaded (e.g., chrome.exe launched twice), just |
| 375 // return it. | 380 // return it. |
| 376 Profile* profile = GetProfileByPath(profile_dir); | 381 Profile* profile = GetProfileByPath(profile_dir); |
| 377 if (profile) | 382 if (profile) |
| 378 return profile; | 383 return profile; |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 } | 1398 } |
| 1394 | 1399 |
| 1395 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1400 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
| 1396 if (!original_callback.is_null()) | 1401 if (!original_callback.is_null()) |
| 1397 original_callback.Run(loaded_profile, status); | 1402 original_callback.Run(loaded_profile, status); |
| 1398 } | 1403 } |
| 1399 | 1404 |
| 1400 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1405 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1401 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1406 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1402 } | 1407 } |
| OLD | NEW |