| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 profile = profile->GetOffTheRecordProfile(); | 206 profile = profile->GetOffTheRecordProfile(); |
| 207 } else { | 207 } else { |
| 208 profile = GetProfile(default_profile_dir); | 208 profile = GetProfile(default_profile_dir); |
| 209 } | 209 } |
| 210 return profile; | 210 return profile; |
| 211 } | 211 } |
| 212 #endif | 212 #endif |
| 213 return GetProfile(default_profile_dir); | 213 return GetProfile(default_profile_dir); |
| 214 } | 214 } |
| 215 | 215 |
| 216 Profile* ProfileManager::GetProfileWithId(ProfileId profile_id) { | |
| 217 DCHECK_NE(Profile::kInvalidProfileId, profile_id); | |
| 218 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); | |
| 219 iter != profiles_info_.end(); ++iter) { | |
| 220 if (iter->second->created) { | |
| 221 Profile* candidate = iter->second->profile.get(); | |
| 222 if (candidate->GetRuntimeId() == profile_id) | |
| 223 return candidate; | |
| 224 if (candidate->HasOffTheRecordProfile()) { | |
| 225 candidate = candidate->GetOffTheRecordProfile(); | |
| 226 if (candidate->GetRuntimeId() == profile_id) | |
| 227 return candidate; | |
| 228 } | |
| 229 } | |
| 230 } | |
| 231 return NULL; | |
| 232 } | |
| 233 | |
| 234 bool ProfileManager::IsValidProfile(Profile* profile) { | 216 bool ProfileManager::IsValidProfile(Profile* profile) { |
| 235 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); | 217 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); |
| 236 iter != profiles_info_.end(); ++iter) { | 218 iter != profiles_info_.end(); ++iter) { |
| 237 if (iter->second->created) { | 219 if (iter->second->created) { |
| 238 Profile* candidate = iter->second->profile.get(); | 220 Profile* candidate = iter->second->profile.get(); |
| 239 if (candidate == profile || | 221 if (candidate == profile || |
| 240 (candidate->HasOffTheRecordProfile() && | 222 (candidate->HasOffTheRecordProfile() && |
| 241 candidate->GetOffTheRecordProfile() == profile)) { | 223 candidate->GetOffTheRecordProfile() == profile)) { |
| 242 return true; | 224 return true; |
| 243 } | 225 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 550 } |
| 569 | 551 |
| 570 // static | 552 // static |
| 571 bool ProfileManager::IsMultipleProfilesEnabled() { | 553 bool ProfileManager::IsMultipleProfilesEnabled() { |
| 572 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 554 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) |
| 573 return true; | 555 return true; |
| 574 #else | 556 #else |
| 575 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); | 557 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); |
| 576 #endif | 558 #endif |
| 577 } | 559 } |
| OLD | NEW |