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 <set> | 5 #include <set> |
6 | 6 |
7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 Profile* profile = GetProfile(default_profile_dir); | 355 Profile* profile = GetProfile(default_profile_dir); |
356 // For cros, return the OTR profile so we never accidentally keep | 356 // For cros, return the OTR profile so we never accidentally keep |
357 // user data in an unencrypted profile. But doing this makes | 357 // user data in an unencrypted profile. But doing this makes |
358 // many of the browser and ui tests fail. We do return the OTR profile | 358 // many of the browser and ui tests fail. We do return the OTR profile |
359 // if the login-profile switch is passed so that we can test this. | 359 // if the login-profile switch is passed so that we can test this. |
360 // TODO(davemoore) Fix the tests so they allow OTR profiles. | 360 // TODO(davemoore) Fix the tests so they allow OTR profiles. |
361 if (ShouldGoOffTheRecord()) | 361 if (ShouldGoOffTheRecord()) |
362 return profile->GetOffTheRecordProfile(); | 362 return profile->GetOffTheRecordProfile(); |
363 return profile; | 363 return profile; |
364 } | 364 } |
365 | |
366 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); | |
367 // Fallback to actual initial profile, if profile for user was not fully | |
Nikita (slow)
2013/01/09 13:54:33
nit: "actual initial profile" > "default OTR login
Denis Kuznetsov (DE-MUC)
2013/01/09 14:10:49
Done.
| |
368 // loaded yet. | |
369 if (profile_info && !profile_info->created) | |
370 default_profile_dir = GetDefaultProfileDir(user_data_dir); | |
365 #endif | 371 #endif |
366 return GetProfile(default_profile_dir); | 372 return GetProfile(default_profile_dir); |
367 } | 373 } |
368 | 374 |
369 bool ProfileManager::IsValidProfile(Profile* profile) { | 375 bool ProfileManager::IsValidProfile(Profile* profile) { |
370 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); | 376 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); |
371 iter != profiles_info_.end(); ++iter) { | 377 iter != profiles_info_.end(); ++iter) { |
372 if (iter->second->created) { | 378 if (iter->second->created) { |
373 Profile* candidate = iter->second->profile.get(); | 379 Profile* candidate = iter->second->profile.get(); |
374 if (candidate == profile || | 380 if (candidate == profile || |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 | 488 |
483 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( | 489 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( |
484 Profile* profile, | 490 Profile* profile, |
485 bool created) { | 491 bool created) { |
486 ProfileInfo* info = new ProfileInfo(profile, created); | 492 ProfileInfo* info = new ProfileInfo(profile, created); |
487 profiles_info_.insert( | 493 profiles_info_.insert( |
488 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); | 494 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); |
489 return info; | 495 return info; |
490 } | 496 } |
491 | 497 |
498 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath( | |
499 const FilePath& path) const { | |
500 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); | |
501 return (iter == profiles_info_.end()) ? NULL : iter->second.get(); | |
502 } | |
503 | |
492 Profile* ProfileManager::GetProfileByPath(const FilePath& path) const { | 504 Profile* ProfileManager::GetProfileByPath(const FilePath& path) const { |
493 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); | 505 ProfileInfo* profile_info = GetProfileInfoByPath(path); |
494 return (iter == profiles_info_.end()) ? NULL : iter->second->profile.get(); | 506 return profile_info ? profile_info->profile.get() : NULL; |
495 } | 507 } |
496 | 508 |
497 // static | 509 // static |
498 void ProfileManager::FindOrCreateNewWindowForProfile( | 510 void ProfileManager::FindOrCreateNewWindowForProfile( |
499 Profile* profile, | 511 Profile* profile, |
500 chrome::startup::IsProcessStartup process_startup, | 512 chrome::startup::IsProcessStartup process_startup, |
501 chrome::startup::IsFirstRun is_first_run, | 513 chrome::startup::IsFirstRun is_first_run, |
502 chrome::HostDesktopType desktop_type, | 514 chrome::HostDesktopType desktop_type, |
503 bool always_create) { | 515 bool always_create) { |
504 #if defined(OS_IOS) | 516 #if defined(OS_IOS) |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 ProfileManager::ProfileInfo::ProfileInfo( | 1071 ProfileManager::ProfileInfo::ProfileInfo( |
1060 Profile* profile, | 1072 Profile* profile, |
1061 bool created) | 1073 bool created) |
1062 : profile(profile), | 1074 : profile(profile), |
1063 created(created) { | 1075 created(created) { |
1064 } | 1076 } |
1065 | 1077 |
1066 ProfileManager::ProfileInfo::~ProfileInfo() { | 1078 ProfileManager::ProfileInfo::~ProfileInfo() { |
1067 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1079 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1068 } | 1080 } |
OLD | NEW |