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