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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 // static | 312 // static |
313 Profile* ProfileManager::GetPrimaryUserProfile() { | 313 Profile* ProfileManager::GetPrimaryUserProfile() { |
314 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 314 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
315 #if defined(OS_CHROMEOS) | 315 #if defined(OS_CHROMEOS) |
316 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized()) | 316 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized()) |
317 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 317 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
318 profile_manager->user_data_dir()); | 318 profile_manager->user_data_dir()); |
319 chromeos::UserManager* manager = chromeos::UserManager::Get(); | 319 chromeos::UserManager* manager = chromeos::UserManager::Get(); |
320 // Note: The ProfileHelper will take care of guest profiles. | 320 // Note: The ProfileHelper will take care of guest profiles. |
321 return chromeos::ProfileHelper::Get()->GetProfileByUser( | 321 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe( |
322 manager->GetPrimaryUser()); | 322 manager->GetPrimaryUser()); |
323 #else | 323 #else |
324 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 324 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
325 profile_manager->user_data_dir()); | 325 profile_manager->user_data_dir()); |
326 #endif | 326 #endif |
327 } | 327 } |
328 | 328 |
329 // static | 329 // static |
330 Profile* ProfileManager::GetActiveUserProfile() { | 330 Profile* ProfileManager::GetActiveUserProfile() { |
331 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 331 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
332 #if defined(OS_CHROMEOS) | 332 #if defined(OS_CHROMEOS) |
333 if (!profile_manager->IsLoggedIn() || | 333 if (!profile_manager->IsLoggedIn() || |
334 !chromeos::UserManager::IsInitialized()) { | 334 !chromeos::UserManager::IsInitialized()) { |
335 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 335 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
336 profile_manager->user_data_dir()); | 336 profile_manager->user_data_dir()); |
337 } | 337 } |
338 | 338 |
339 chromeos::UserManager* manager = chromeos::UserManager::Get(); | 339 chromeos::UserManager* manager = chromeos::UserManager::Get(); |
340 const user_manager::User* user = manager->GetActiveUser(); | 340 const user_manager::User* user = manager->GetActiveUser(); |
341 // To avoid an endless loop (crbug.com/334098) we have to additionally check | 341 // To avoid an endless loop (crbug.com/334098) we have to additionally check |
342 // if the profile of the user was already created. If the profile was not yet | 342 // if the profile of the user was already created. If the profile was not yet |
343 // created we load the profile using the profile directly. | 343 // created we load the profile using the profile directly. |
344 // TODO: This should be cleaned up with the new profile manager. | 344 // TODO: This should be cleaned up with the new profile manager. |
345 if (user && user->is_profile_created()) | 345 if (user && user->is_profile_created()) |
346 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); | 346 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
347 | 347 |
348 #endif | 348 #endif |
349 Profile* profile = | 349 Profile* profile = |
350 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 350 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
351 profile_manager->user_data_dir()); | 351 profile_manager->user_data_dir()); |
352 // |profile| could be null if the user doesn't have a profile yet and the path | 352 // |profile| could be null if the user doesn't have a profile yet and the path |
353 // is on a read-only volume (preventing Chrome from making a new one). | 353 // is on a read-only volume (preventing Chrome from making a new one). |
354 // However, most callers of this function immediately dereference the result | 354 // However, most callers of this function immediately dereference the result |
355 // which would lead to crashes in a variety of call sites. Assert here to | 355 // which would lead to crashes in a variety of call sites. Assert here to |
356 // figure out how common this is. http://crbug.com/383019 | 356 // figure out how common this is. http://crbug.com/383019 |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); | 1324 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); |
1325 FinishDeletingProfile(profile_to_delete_path); | 1325 FinishDeletingProfile(profile_to_delete_path); |
1326 } | 1326 } |
1327 } | 1327 } |
1328 } | 1328 } |
1329 #endif | 1329 #endif |
1330 | 1330 |
1331 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1331 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1332 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1332 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1333 } | 1333 } |
OLD | NEW |