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

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

Issue 11667024: Do not return profile unless it is loaded (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Also fix ToDo Created 7 years, 11 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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 default off-the-record profile, if user profile has not fully
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698