OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_util.h" | 10 #include "base/file_util.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 return profile; | 132 return profile; |
133 } | 133 } |
134 #endif | 134 #endif |
135 return GetProfile(default_profile_dir); | 135 return GetProfile(default_profile_dir); |
136 } | 136 } |
137 | 137 |
138 Profile* ProfileManager::GetProfile(const FilePath& profile_dir) { | 138 Profile* ProfileManager::GetProfile(const FilePath& profile_dir) { |
139 return GetProfile(profile_dir, true); | 139 return GetProfile(profile_dir, true); |
140 } | 140 } |
141 | 141 |
| 142 Profile* ProfileManager::GetProfileWithId(ProfileId profile_id) { |
| 143 DCHECK_NE(Profile::kInvalidProfileId, profile_id); |
| 144 for (iterator i = begin(); i != end(); ++i) { |
| 145 if ((*i)->GetRuntimeId() == profile_id) |
| 146 return *i; |
| 147 if ((*i)->HasOffTheRecordProfile() && |
| 148 (*i)->GetOffTheRecordProfile()->GetRuntimeId() == profile_id) { |
| 149 return (*i)->GetOffTheRecordProfile(); |
| 150 } |
| 151 } |
| 152 return NULL; |
| 153 } |
| 154 |
142 bool ProfileManager::IsValidProfile(Profile* profile) { | 155 bool ProfileManager::IsValidProfile(Profile* profile) { |
143 for (iterator i = begin(); i != end(); ++i) { | 156 for (iterator i = begin(); i != end(); ++i) { |
144 if (*i == profile) | 157 if (*i == profile) |
145 return true; | 158 return true; |
146 if ((*i)->HasOffTheRecordProfile() && | 159 if ((*i)->HasOffTheRecordProfile() && |
147 (*i)->GetOffTheRecordProfile() == profile) { | 160 (*i)->GetOffTheRecordProfile() == profile) { |
148 return true; | 161 return true; |
149 } | 162 } |
150 } | 163 } |
151 return false; | 164 return false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (!file_util::PathExists(path)) { | 302 if (!file_util::PathExists(path)) { |
290 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 303 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
291 // profile directory. We should eventually be able to run in this | 304 // profile directory. We should eventually be able to run in this |
292 // situation. | 305 // situation. |
293 if (!file_util::CreateDirectory(path)) | 306 if (!file_util::CreateDirectory(path)) |
294 return NULL; | 307 return NULL; |
295 } | 308 } |
296 | 309 |
297 return Profile::CreateProfile(path); | 310 return Profile::CreateProfile(path); |
298 } | 311 } |
OLD | NEW |