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) | |
360 Profile* profile = | 359 Profile* profile = |
361 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 360 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
362 profile_manager->user_data_dir()); | 361 profile_manager->user_data_dir()); |
363 // |profile| could be null if the user doesn't have a profile yet and the path | 362 // |profile| could be null if the user doesn't have a profile yet and the path |
364 // is on a read-only volume (preventing Chrome from making a new one). | 363 // is on a read-only volume (preventing Chrome from making a new one). |
365 // However, most callers of this function immediately dereference the result | 364 // However, most callers of this function immediately dereference the result |
366 // which would lead to crashes in a variety of call sites. Assert here to | 365 // which would lead to crashes in a variety of call sites. Assert here to |
367 // figure out how common this is. http://crbug.com/383019 | 366 // figure out how common this is. http://crbug.com/383019 |
368 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe(); | 367 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe(); |
369 return profile; | 368 return profile; |
370 #else | |
371 return profile_manager->GetProfile( | |
372 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir())); | |
373 #endif | |
374 } | 369 } |
375 | 370 |
376 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { | 371 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { |
377 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); | 372 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); |
378 | 373 |
379 // If the profile is already loaded (e.g., chrome.exe launched twice), just | 374 // If the profile is already loaded (e.g., chrome.exe launched twice), just |
380 // return it. | 375 // return it. |
381 Profile* profile = GetProfileByPath(profile_dir); | 376 Profile* profile = GetProfileByPath(profile_dir); |
382 if (profile) | 377 if (profile) |
383 return profile; | 378 return profile; |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 } | 1393 } |
1399 | 1394 |
1400 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1395 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1401 if (!original_callback.is_null()) | 1396 if (!original_callback.is_null()) |
1402 original_callback.Run(loaded_profile, status); | 1397 original_callback.Run(loaded_profile, status); |
1403 } | 1398 } |
1404 | 1399 |
1405 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1400 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1406 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1401 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1407 } | 1402 } |
OLD | NEW |