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

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

Issue 271533004: Turning on MultiProfile by default for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #if defined(OS_WIN) 76 #if defined(OS_WIN)
77 #include "base/win/metro.h" 77 #include "base/win/metro.h"
78 #include "chrome/installer/util/browser_distribution.h" 78 #include "chrome/installer/util/browser_distribution.h"
79 #endif 79 #endif
80 80
81 #if defined(OS_CHROMEOS) 81 #if defined(OS_CHROMEOS)
82 #include "chrome/browser/browser_process_platform_part_chromeos.h" 82 #include "chrome/browser/browser_process_platform_part_chromeos.h"
83 #include "chrome/browser/chromeos/login/user.h" 83 #include "chrome/browser/chromeos/login/user.h"
84 #include "chrome/browser/chromeos/login/user_manager.h" 84 #include "chrome/browser/chromeos/login/user_manager.h"
85 #include "chrome/browser/chromeos/profiles/profile_helper.h" 85 #include "chrome/browser/chromeos/profiles/profile_helper.h"
86 #include "chrome/browser/profiles/profiles_state.h"
86 #include "chromeos/chromeos_switches.h" 87 #include "chromeos/chromeos_switches.h"
87 #include "chromeos/dbus/cryptohome_client.h" 88 #include "chromeos/dbus/cryptohome_client.h"
88 #include "chromeos/dbus/dbus_thread_manager.h" 89 #include "chromeos/dbus/dbus_thread_manager.h"
89 #endif 90 #endif
90 91
91 using base::UserMetricsAction; 92 using base::UserMetricsAction;
92 using content::BrowserThread; 93 using content::BrowserThread;
93 94
94 namespace { 95 namespace {
95 96
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 #else 320 #else
320 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( 321 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
321 profile_manager->user_data_dir()); 322 profile_manager->user_data_dir());
322 #endif 323 #endif
323 } 324 }
324 325
325 // static 326 // static
326 Profile* ProfileManager::GetActiveUserProfile() { 327 Profile* ProfileManager::GetActiveUserProfile() {
327 ProfileManager* profile_manager = g_browser_process->profile_manager(); 328 ProfileManager* profile_manager = g_browser_process->profile_manager();
328 #if defined(OS_CHROMEOS) 329 #if defined(OS_CHROMEOS)
329 if (!chromeos::UserManager::IsMultipleProfilesAllowed() || 330 if (!chromeos::UserManager::IsInitialized())
330 !profile_manager->IsLoggedIn() ||
331 !chromeos::UserManager::IsInitialized())
332 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( 331 return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
333 profile_manager->user_data_dir()); 332 profile_manager->user_data_dir());
334 chromeos::UserManager* manager = chromeos::UserManager::Get(); 333 chromeos::UserManager* manager = chromeos::UserManager::Get();
335 const chromeos::User* user = manager->GetActiveUser(); 334 const chromeos::User* user = manager->GetActiveUser();
336 // To avoid an endless loop (crbug.com/334098) we have to additionally check 335 // To avoid an endless loop (crbug.com/334098) we have to additionally check
337 // if the profile of the user was already created. If the profile was not yet 336 // if the profile of the user was already created. If the profile was not yet
338 // created we load the profile using the profile directly. 337 // created we load the profile using the profile directly.
339 // TODO: This should be cleaned up with the new profile manager. 338 // TODO: This should be cleaned up with the new profile manager.
340 if (user && user->is_profile_created()) 339 if (user && user->is_profile_created())
341 return manager->GetProfileByUser(user); 340 return manager->GetProfileByUser(user);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 446 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
448 if (logged_in_) { 447 if (logged_in_) {
449 base::FilePath profile_dir; 448 base::FilePath profile_dir;
450 // If the user has logged in, pick up the new profile. 449 // If the user has logged in, pick up the new profile.
451 if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { 450 if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) {
452 // TODO(nkostylev): Remove this code completely once we eliminate 451 // TODO(nkostylev): Remove this code completely once we eliminate
453 // legacy --login-profile=user switch and enable multi-profiles on CrOS 452 // legacy --login-profile=user switch and enable multi-profiles on CrOS
454 // by default. http://crbug.com/294628 453 // by default. http://crbug.com/294628
455 profile_dir = chromeos::ProfileHelper:: 454 profile_dir = chromeos::ProfileHelper::
456 GetProfileDirByLegacyLoginProfileSwitch(); 455 GetProfileDirByLegacyLoginProfileSwitch();
457 } else if (!command_line.HasSwitch(switches::kMultiProfiles)) {
458 // We should never be logged in with no profile dir unless
459 // multi-profiles are enabled.
460 // In that case profile dir will be defined by user_id hash.
461 NOTREACHED();
462 return base::FilePath("");
463 } 456 }
464 // In case of multi-profiles ignore --login-profile switch. 457 // In case of multi-profiles ignore --login-profile switch.
465 // TODO(nkostylev): Some cases like Guest mode will have empty username_hash 458 // TODO(nkostylev): Some cases like Guest mode will have empty username_hash
466 // so default kLoginProfile dir will be used. 459 // so default kLoginProfile dir will be used.
467 std::string user_id_hash = g_browser_process->platform_part()-> 460 std::string user_id_hash = g_browser_process->platform_part()->
468 profile_helper()->active_user_id_hash(); 461 profile_helper()->active_user_id_hash();
469 if (command_line.HasSwitch(switches::kMultiProfiles) && 462 if (!user_id_hash.empty()) {
470 !user_id_hash.empty()) {
471 profile_dir = g_browser_process->platform_part()-> 463 profile_dir = g_browser_process->platform_part()->
472 profile_helper()->GetActiveUserProfileDir(); 464 profile_helper()->GetActiveUserProfileDir();
473 } 465 }
474 relative_profile_dir = relative_profile_dir.Append(profile_dir); 466 relative_profile_dir = relative_profile_dir.Append(profile_dir);
475 return relative_profile_dir; 467 return relative_profile_dir;
476 } 468 }
477 #endif 469 #endif
478 // TODO(mirandac): should not automatically be default profile. 470 // TODO(mirandac): should not automatically be default profile.
479 relative_profile_dir = 471 relative_profile_dir =
480 relative_profile_dir.AppendASCII(chrome::kInitialProfile); 472 relative_profile_dir.AppendASCII(chrome::kInitialProfile);
481 return relative_profile_dir; 473 return relative_profile_dir;
482 } 474 }
483 475
484 Profile* ProfileManager::GetLastUsedProfile( 476 Profile* ProfileManager::GetLastUsedProfile(
485 const base::FilePath& user_data_dir) { 477 const base::FilePath& user_data_dir) {
486 #if defined(OS_CHROMEOS) 478 #if defined(OS_CHROMEOS)
487 // Use default login profile if user has not logged in yet. 479 // Use default login profile if user has not logged in yet.
488 if (!logged_in_) { 480 if (!logged_in_) {
489 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir); 481 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir);
490 } else { 482 } else {
491 // CrOS multi-profiles implementation is different so GetLastUsedProfile 483 // CrOS multi-profiles implementation is different so GetLastUsedProfile
492 // has custom implementation too. 484 // has custom implementation too.
493 base::FilePath profile_dir; 485 base::FilePath profile_dir;
494 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 486 // In case of multi-profiles we ignore "last used profile" preference
495 if (command_line.HasSwitch(switches::kMultiProfiles)) { 487 // since it may refer to profile that has been in use in previous session.
496 // In case of multi-profiles we ignore "last used profile" preference 488 // That profile dir may not be mounted in this session so instead return
497 // since it may refer to profile that has been in use in previous session. 489 // active profile from current session.
498 // That profile dir may not be mounted in this session so instead return 490 profile_dir = g_browser_process->platform_part()->
499 // active profile from current session. 491 profile_helper()->GetActiveUserProfileDir();
500 profile_dir = g_browser_process->platform_part()->
501 profile_helper()->GetActiveUserProfileDir();
502 } else {
503 // For legacy (not multi-profiles) implementation always default to
504 // --login-profile value.
505 profile_dir =
506 chromeos::ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch();
507 }
508 492
509 base::FilePath profile_path(user_data_dir); 493 base::FilePath profile_path(user_data_dir);
510 Profile* profile = GetProfile(profile_path.Append(profile_dir)); 494 Profile* profile = GetProfile(profile_path.Append(profile_dir));
511 return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : 495 return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() :
512 profile; 496 profile;
513 } 497 }
514 #endif 498 #endif
515 499
516 return GetProfile(GetLastUsedProfileDir(user_data_dir)); 500 return GetProfile(GetLastUsedProfileDir(user_data_dir));
517 } 501 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 last_non_managed_profile_path.BaseName().MaybeAsASCII()); 1270 last_non_managed_profile_path.BaseName().MaybeAsASCII());
1287 FinishDeletingProfile(profile_to_delete_path); 1271 FinishDeletingProfile(profile_to_delete_path);
1288 } 1272 }
1289 } 1273 }
1290 } 1274 }
1291 #endif 1275 #endif
1292 1276
1293 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1277 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1294 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1278 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1295 } 1279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698