Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: similarity Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "extensions/browser/extension_system.h" 75 #include "extensions/browser/extension_system.h"
76 #endif // !defined (OS_IOS) 76 #endif // !defined (OS_IOS)
77 77
78 #if defined(OS_WIN) 78 #if defined(OS_WIN)
79 #include "base/win/metro.h" 79 #include "base/win/metro.h"
80 #include "chrome/installer/util/browser_distribution.h" 80 #include "chrome/installer/util/browser_distribution.h"
81 #endif 81 #endif
82 82
83 #if defined(OS_CHROMEOS) 83 #if defined(OS_CHROMEOS)
84 #include "chrome/browser/browser_process_platform_part_chromeos.h" 84 #include "chrome/browser/browser_process_platform_part_chromeos.h"
85 #include "chrome/browser/chromeos/login/users/user_manager.h"
86 #include "chrome/browser/chromeos/profiles/profile_helper.h" 85 #include "chrome/browser/chromeos/profiles/profile_helper.h"
87 #include "chrome/browser/profiles/profiles_state.h" 86 #include "chrome/browser/profiles/profiles_state.h"
88 #include "chromeos/chromeos_switches.h" 87 #include "chromeos/chromeos_switches.h"
89 #include "chromeos/dbus/cryptohome_client.h" 88 #include "chromeos/dbus/cryptohome_client.h"
90 #include "chromeos/dbus/dbus_thread_manager.h" 89 #include "chromeos/dbus/dbus_thread_manager.h"
91 #include "components/user_manager/user.h" 90 #include "components/user_manager/user.h"
91 #include "components/user_manager/user_manager.h"
92 #endif 92 #endif
93 93
94 using base::UserMetricsAction; 94 using base::UserMetricsAction;
95 using content::BrowserThread; 95 using content::BrowserThread;
96 96
97 namespace { 97 namespace {
98 98
99 // Profiles that should be deleted on shutdown. 99 // Profiles that should be deleted on shutdown.
100 std::vector<base::FilePath>& ProfilesToDelete() { 100 std::vector<base::FilePath>& ProfilesToDelete() {
101 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ()); 101 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles() { 306 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles() {
307 ProfileManager* profile_manager = g_browser_process->profile_manager(); 307 ProfileManager* profile_manager = g_browser_process->profile_manager();
308 return profile_manager->GetLastOpenedProfiles( 308 return profile_manager->GetLastOpenedProfiles(
309 profile_manager->user_data_dir_); 309 profile_manager->user_data_dir_);
310 } 310 }
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() ||
317 !user_manager::UserManager::IsInitialized())
317 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( 318 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
318 profile_manager->user_data_dir()); 319 profile_manager->user_data_dir());
319 chromeos::UserManager* manager = chromeos::UserManager::Get(); 320 user_manager::UserManager* manager = user_manager::UserManager::Get();
320 // Note: The ProfileHelper will take care of guest profiles. 321 // Note: The ProfileHelper will take care of guest profiles.
321 return chromeos::ProfileHelper::Get()->GetProfileByUser( 322 return chromeos::ProfileHelper::Get()->GetProfileByUser(
322 manager->GetPrimaryUser()); 323 manager->GetPrimaryUser());
323 #else 324 #else
324 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( 325 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
325 profile_manager->user_data_dir()); 326 profile_manager->user_data_dir());
326 #endif 327 #endif
327 } 328 }
328 329
329 // static 330 // static
330 Profile* ProfileManager::GetActiveUserProfile() { 331 Profile* ProfileManager::GetActiveUserProfile() {
331 ProfileManager* profile_manager = g_browser_process->profile_manager(); 332 ProfileManager* profile_manager = g_browser_process->profile_manager();
332 #if defined(OS_CHROMEOS) 333 #if defined(OS_CHROMEOS)
333 if (!profile_manager->IsLoggedIn() || 334 if (!profile_manager->IsLoggedIn() ||
334 !chromeos::UserManager::IsInitialized()) { 335 !user_manager::UserManager::IsInitialized()) {
335 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( 336 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
336 profile_manager->user_data_dir()); 337 profile_manager->user_data_dir());
337 } 338 }
338 339
339 chromeos::UserManager* manager = chromeos::UserManager::Get(); 340 user_manager::UserManager* manager = user_manager::UserManager::Get();
340 const user_manager::User* user = manager->GetActiveUser(); 341 const user_manager::User* user = manager->GetActiveUser();
341 // To avoid an endless loop (crbug.com/334098) we have to additionally check 342 // 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 343 // 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. 344 // created we load the profile using the profile directly.
344 // TODO: This should be cleaned up with the new profile manager. 345 // TODO: This should be cleaned up with the new profile manager.
345 if (user && user->is_profile_created()) 346 if (user && user->is_profile_created())
346 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); 347 return chromeos::ProfileHelper::Get()->GetProfileByUser(user);
347 348
348 #endif 349 #endif
349 Profile* profile = 350 Profile* profile =
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 base::FilePath default_profile_dir(user_data_dir); 1049 base::FilePath default_profile_dir(user_data_dir);
1049 if (!logged_in_) { 1050 if (!logged_in_) {
1050 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); 1051 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir);
1051 Profile* profile = GetProfile(default_profile_dir); 1052 Profile* profile = GetProfile(default_profile_dir);
1052 // For cros, return the OTR profile so we never accidentally keep 1053 // For cros, return the OTR profile so we never accidentally keep
1053 // user data in an unencrypted profile. But doing this makes 1054 // user data in an unencrypted profile. But doing this makes
1054 // many of the browser and ui tests fail. We do return the OTR profile 1055 // many of the browser and ui tests fail. We do return the OTR profile
1055 // if the login-profile switch is passed so that we can test this. 1056 // if the login-profile switch is passed so that we can test this.
1056 if (ShouldGoOffTheRecord(profile)) 1057 if (ShouldGoOffTheRecord(profile))
1057 return profile->GetOffTheRecordProfile(); 1058 return profile->GetOffTheRecordProfile();
1058 DCHECK(!chromeos::UserManager::Get()->IsLoggedInAsGuest()); 1059 DCHECK(!user_manager::UserManager::Get()->IsLoggedInAsGuest());
1059 return profile; 1060 return profile;
1060 } 1061 }
1061 1062
1062 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); 1063 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
1063 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); 1064 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir);
1064 // Fallback to default off-the-record profile, if user profile has not fully 1065 // Fallback to default off-the-record profile, if user profile has not fully
1065 // loaded yet. 1066 // loaded yet.
1066 if (profile_info && !profile_info->created) 1067 if (profile_info && !profile_info->created)
1067 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); 1068 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir);
1068 1069
1069 Profile* profile = GetProfile(default_profile_dir); 1070 Profile* profile = GetProfile(default_profile_dir);
1070 // Some unit tests didn't initialize the UserManager. 1071 // Some unit tests didn't initialize the UserManager.
1071 if (chromeos::UserManager::IsInitialized() && 1072 if (user_manager::UserManager::IsInitialized() &&
1072 chromeos::UserManager::Get()->IsLoggedInAsGuest()) 1073 user_manager::UserManager::Get()->IsLoggedInAsGuest())
1073 return profile->GetOffTheRecordProfile(); 1074 return profile->GetOffTheRecordProfile();
1074 return profile; 1075 return profile;
1075 #else 1076 #else
1076 base::FilePath default_profile_dir(user_data_dir); 1077 base::FilePath default_profile_dir(user_data_dir);
1077 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); 1078 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
1078 return GetProfile(default_profile_dir); 1079 return GetProfile(default_profile_dir);
1079 #endif 1080 #endif
1080 } 1081 }
1081 1082
1082 bool ProfileManager::AddProfile(Profile* profile) { 1083 bool ProfileManager::AddProfile(Profile* profile) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); 1325 last_non_supervised_profile_path.BaseName().MaybeAsASCII());
1325 FinishDeletingProfile(profile_to_delete_path); 1326 FinishDeletingProfile(profile_to_delete_path);
1326 } 1327 }
1327 } 1328 }
1328 } 1329 }
1329 #endif 1330 #endif
1330 1331
1331 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1332 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1332 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1333 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1333 } 1334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698