Chromium Code Reviews| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 (candidate->HasOffTheRecordProfile() && | 453 (candidate->HasOffTheRecordProfile() && |
| 454 candidate->GetOffTheRecordProfile() == profile)) { | 454 candidate->GetOffTheRecordProfile() == profile)) { |
| 455 return true; | 455 return true; |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 return false; | 459 return false; |
| 460 } | 460 } |
| 461 | 461 |
| 462 base::FilePath ProfileManager::GetInitialProfileDir() { | 462 base::FilePath ProfileManager::GetInitialProfileDir() { |
| 463 base::FilePath relative_profile_dir; | |
| 464 #if defined(OS_CHROMEOS) | 463 #if defined(OS_CHROMEOS) |
| 465 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 466 if (logged_in_) { | 464 if (logged_in_) { |
|
Mr4D (OOO till 08-26)
2014/08/15 14:27:56
I was wondering about guest mode. Looking at the G
dzhioev (left Google)
2014/08/15 16:11:25
Yep, guest mode still works. Guest mode starts in
| |
| 467 base::FilePath profile_dir; | 465 return chromeos::ProfileHelper::Get()->GetActiveUserProfileDir(); |
| 468 // If the user has logged in, pick up the new profile. | |
| 469 if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { | |
| 470 // TODO(nkostylev): Remove this code completely once we eliminate | |
| 471 // legacy --login-profile=user switch and enable multi-profiles on CrOS | |
| 472 // by default. http://crbug.com/294628 | |
| 473 profile_dir = chromeos::ProfileHelper:: | |
| 474 GetProfileDirByLegacyLoginProfileSwitch(); | |
| 475 } | |
| 476 // In case of multi-profiles ignore --login-profile switch. | |
| 477 // TODO(nkostylev): Some cases like Guest mode will have empty username_hash | |
| 478 // so default kLoginProfile dir will be used. | |
| 479 std::string user_id_hash = | |
| 480 chromeos::ProfileHelper::Get()->active_user_id_hash(); | |
| 481 if (!user_id_hash.empty()) | |
| 482 profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir(); | |
| 483 | |
| 484 relative_profile_dir = relative_profile_dir.Append(profile_dir); | |
| 485 return relative_profile_dir; | |
| 486 } | 466 } |
| 487 #endif | 467 #endif |
| 468 base::FilePath relative_profile_dir; | |
| 488 // TODO(mirandac): should not automatically be default profile. | 469 // TODO(mirandac): should not automatically be default profile. |
| 489 relative_profile_dir = | 470 return relative_profile_dir.AppendASCII(chrome::kInitialProfile); |
| 490 relative_profile_dir.AppendASCII(chrome::kInitialProfile); | |
| 491 return relative_profile_dir; | |
| 492 } | 471 } |
| 493 | 472 |
| 494 Profile* ProfileManager::GetLastUsedProfile( | 473 Profile* ProfileManager::GetLastUsedProfile( |
| 495 const base::FilePath& user_data_dir) { | 474 const base::FilePath& user_data_dir) { |
| 496 #if defined(OS_CHROMEOS) | 475 #if defined(OS_CHROMEOS) |
| 497 // Use default login profile if user has not logged in yet. | 476 // Use default login profile if user has not logged in yet. |
| 498 if (!logged_in_) { | 477 if (!logged_in_) { |
| 499 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir); | 478 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir); |
| 500 } else { | 479 } else { |
| 501 // CrOS multi-profiles implementation is different so GetLastUsedProfile | 480 // CrOS multi-profiles implementation is different so GetLastUsedProfile |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1197 prefs->SetBoolean(prefs::kEditBookmarksEnabled, false); | 1176 prefs->SetBoolean(prefs::kEditBookmarksEnabled, false); |
| 1198 prefs->SetBoolean(prefs::kShowBookmarkBar, false); | 1177 prefs->SetBoolean(prefs::kShowBookmarkBar, false); |
| 1199 // This can be removed in the future but needs to be present through | 1178 // This can be removed in the future but needs to be present through |
| 1200 // a release (or two) so that any existing installs get switched to | 1179 // a release (or two) so that any existing installs get switched to |
| 1201 // the new state and away from the previous "forced" state. | 1180 // the new state and away from the previous "forced" state. |
| 1202 IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::ENABLED); | 1181 IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::ENABLED); |
| 1203 } | 1182 } |
| 1204 | 1183 |
| 1205 bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) { | 1184 bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) { |
| 1206 #if defined(OS_CHROMEOS) | 1185 #if defined(OS_CHROMEOS) |
| 1207 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1186 if (profile->GetPath().BaseName().value() == chrome::kInitialProfile) { |
| 1208 if (profile->GetPath().BaseName().value() == chrome::kInitialProfile && | |
| 1209 (!command_line.HasSwitch(switches::kTestType) || | |
| 1210 command_line.HasSwitch(chromeos::switches::kLoginProfile))) { | |
| 1211 return true; | 1187 return true; |
| 1212 } | 1188 } |
| 1213 #endif | 1189 #endif |
| 1214 return profile->IsGuestSession(); | 1190 return profile->IsGuestSession(); |
| 1215 } | 1191 } |
| 1216 | 1192 |
| 1217 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, | 1193 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, |
| 1218 Profile* profile, | 1194 Profile* profile, |
| 1219 Profile::CreateStatus status) { | 1195 Profile::CreateStatus status) { |
| 1220 for (size_t i = 0; i < callbacks.size(); ++i) | 1196 for (size_t i = 0; i < callbacks.size(); ++i) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1322 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); | 1298 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); |
| 1323 FinishDeletingProfile(profile_to_delete_path); | 1299 FinishDeletingProfile(profile_to_delete_path); |
| 1324 } | 1300 } |
| 1325 } | 1301 } |
| 1326 } | 1302 } |
| 1327 #endif | 1303 #endif |
| 1328 | 1304 |
| 1329 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1305 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1330 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1306 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1331 } | 1307 } |
| OLD | NEW |