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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 profile_manager->user_data_dir_); | 307 profile_manager->user_data_dir_); |
308 } | 308 } |
309 | 309 |
310 // static | 310 // static |
311 Profile* ProfileManager::GetPrimaryUserProfile() { | 311 Profile* ProfileManager::GetPrimaryUserProfile() { |
312 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 312 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
313 #if defined(OS_CHROMEOS) | 313 #if defined(OS_CHROMEOS) |
314 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized()) | 314 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized()) |
315 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 315 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
316 profile_manager->user_data_dir()); | 316 profile_manager->user_data_dir()); |
317 chromeos::UserManager* manager = chromeos::UserManager::Get(); | 317 chromeos::UserManager* manager = chromeos::GetUserManager(); |
318 // Note: The ProfileHelper will take care of guest profiles. | 318 // Note: The ProfileHelper will take care of guest profiles. |
319 return chromeos::ProfileHelper::Get()->GetProfileByUser( | 319 return chromeos::ProfileHelper::Get()->GetProfileByUser( |
320 manager->GetPrimaryUser()); | 320 manager->GetPrimaryUser()); |
321 #else | 321 #else |
322 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 322 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
323 profile_manager->user_data_dir()); | 323 profile_manager->user_data_dir()); |
324 #endif | 324 #endif |
325 } | 325 } |
326 | 326 |
327 // static | 327 // static |
328 Profile* ProfileManager::GetActiveUserProfile() { | 328 Profile* ProfileManager::GetActiveUserProfile() { |
329 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 329 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
330 #if defined(OS_CHROMEOS) | 330 #if defined(OS_CHROMEOS) |
331 if (!profile_manager->IsLoggedIn() || | 331 if (!profile_manager->IsLoggedIn() || |
332 !chromeos::UserManager::IsInitialized()) { | 332 !chromeos::UserManager::IsInitialized()) { |
333 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 333 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
334 profile_manager->user_data_dir()); | 334 profile_manager->user_data_dir()); |
335 } | 335 } |
336 | 336 |
337 chromeos::UserManager* manager = chromeos::UserManager::Get(); | 337 chromeos::UserManager* manager = chromeos::GetUserManager(); |
338 const chromeos::User* user = manager->GetActiveUser(); | 338 const chromeos::User* user = manager->GetActiveUser(); |
339 // To avoid an endless loop (crbug.com/334098) we have to additionally check | 339 // To avoid an endless loop (crbug.com/334098) we have to additionally check |
340 // if the profile of the user was already created. If the profile was not yet | 340 // if the profile of the user was already created. If the profile was not yet |
341 // created we load the profile using the profile directly. | 341 // created we load the profile using the profile directly. |
342 // TODO: This should be cleaned up with the new profile manager. | 342 // TODO: This should be cleaned up with the new profile manager. |
343 if (user && user->is_profile_created()) | 343 if (user && user->is_profile_created()) |
344 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); | 344 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); |
345 | 345 |
346 #endif | 346 #endif |
347 Profile* profile = | 347 Profile* profile = |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 base::FilePath default_profile_dir(user_data_dir); | 1029 base::FilePath default_profile_dir(user_data_dir); |
1030 if (!logged_in_) { | 1030 if (!logged_in_) { |
1031 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); | 1031 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); |
1032 Profile* profile = GetProfile(default_profile_dir); | 1032 Profile* profile = GetProfile(default_profile_dir); |
1033 // For cros, return the OTR profile so we never accidentally keep | 1033 // For cros, return the OTR profile so we never accidentally keep |
1034 // user data in an unencrypted profile. But doing this makes | 1034 // user data in an unencrypted profile. But doing this makes |
1035 // many of the browser and ui tests fail. We do return the OTR profile | 1035 // many of the browser and ui tests fail. We do return the OTR profile |
1036 // if the login-profile switch is passed so that we can test this. | 1036 // if the login-profile switch is passed so that we can test this. |
1037 if (ShouldGoOffTheRecord(profile)) | 1037 if (ShouldGoOffTheRecord(profile)) |
1038 return profile->GetOffTheRecordProfile(); | 1038 return profile->GetOffTheRecordProfile(); |
1039 DCHECK(!chromeos::UserManager::Get()->IsLoggedInAsGuest()); | 1039 DCHECK(!chromeos::GetUserManager()->IsLoggedInAsGuest()); |
1040 return profile; | 1040 return profile; |
1041 } | 1041 } |
1042 | 1042 |
1043 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); | 1043 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); |
1044 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); | 1044 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); |
1045 // Fallback to default off-the-record profile, if user profile has not fully | 1045 // Fallback to default off-the-record profile, if user profile has not fully |
1046 // loaded yet. | 1046 // loaded yet. |
1047 if (profile_info && !profile_info->created) | 1047 if (profile_info && !profile_info->created) |
1048 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); | 1048 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); |
1049 | 1049 |
1050 Profile* profile = GetProfile(default_profile_dir); | 1050 Profile* profile = GetProfile(default_profile_dir); |
1051 // Some unit tests didn't initialize the UserManager. | 1051 // Some unit tests didn't initialize the UserManager. |
1052 if (chromeos::UserManager::IsInitialized() && | 1052 if (chromeos::UserManager::IsInitialized() && |
1053 chromeos::UserManager::Get()->IsLoggedInAsGuest()) | 1053 chromeos::GetUserManager()->IsLoggedInAsGuest()) |
1054 return profile->GetOffTheRecordProfile(); | 1054 return profile->GetOffTheRecordProfile(); |
1055 return profile; | 1055 return profile; |
1056 #else | 1056 #else |
1057 base::FilePath default_profile_dir(user_data_dir); | 1057 base::FilePath default_profile_dir(user_data_dir); |
1058 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); | 1058 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); |
1059 return GetProfile(default_profile_dir); | 1059 return GetProfile(default_profile_dir); |
1060 #endif | 1060 #endif |
1061 } | 1061 } |
1062 | 1062 |
1063 bool ProfileManager::AddProfile(Profile* profile) { | 1063 bool ProfileManager::AddProfile(Profile* profile) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); | 1297 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); |
1298 FinishDeletingProfile(profile_to_delete_path); | 1298 FinishDeletingProfile(profile_to_delete_path); |
1299 } | 1299 } |
1300 } | 1300 } |
1301 } | 1301 } |
1302 #endif | 1302 #endif |
1303 | 1303 |
1304 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1304 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1305 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1305 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1306 } | 1306 } |
OLD | NEW |