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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 ++it) { | 223 ++it) { |
224 // Delete both the profile directory and its corresponding cache. | 224 // Delete both the profile directory and its corresponding cache. |
225 base::FilePath cache_path; | 225 base::FilePath cache_path; |
226 chrome::GetUserCacheDirectory(*it, &cache_path); | 226 chrome::GetUserCacheDirectory(*it, &cache_path); |
227 file_util::Delete(*it, true); | 227 file_util::Delete(*it, true); |
228 file_util::Delete(cache_path, true); | 228 file_util::Delete(cache_path, true); |
229 } | 229 } |
230 ProfilesToDelete().clear(); | 230 ProfilesToDelete().clear(); |
231 } | 231 } |
232 | 232 |
233 namespace { | |
234 // Assume "allowed" for tests; SetAllowGetDefaultProfile(false) should be called | |
sail
2013/05/23 18:20:56
new line before
stevenjb
2013/05/23 18:28:15
Done.
| |
235 // early to enable checking, e.g. from ChromeBrowserMainParts. | |
236 bool s_allow_get_default_profile = true; | |
237 } | |
sail
2013/05/23 18:20:56
new line before
stevenjb
2013/05/23 18:28:15
Done.
| |
238 | |
239 // static | |
240 void ProfileManager::SetAllowGetDefaultProfile(bool allow) { | |
241 s_allow_get_default_profile = allow; | |
242 } | |
243 | |
233 // static | 244 // static |
234 // TODO(nkostylev): Remove this method once all clients are migrated. | 245 // TODO(nkostylev): Remove this method once all clients are migrated. |
235 Profile* ProfileManager::GetDefaultProfile() { | 246 Profile* ProfileManager::GetDefaultProfile() { |
247 LOG_IF(FATAL, !s_allow_get_default_profile) | |
sail
2013/05/23 18:20:56
can we make this a CHECK() instead?
stevenjb
2013/05/23 18:28:15
Done.
| |
248 << "GetDefaultProfile() caled befofre allowed."; | |
236 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 249 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
237 return profile_manager->GetDefaultProfile(profile_manager->user_data_dir_); | 250 return profile_manager->GetDefaultProfile(profile_manager->user_data_dir_); |
238 } | 251 } |
239 | 252 |
240 // static | 253 // static |
241 // TODO(nkostylev): Remove this method once all clients are migrated. | 254 // TODO(nkostylev): Remove this method once all clients are migrated. |
242 Profile* ProfileManager::GetDefaultProfileOrOffTheRecord() { | 255 Profile* ProfileManager::GetDefaultProfileOrOffTheRecord() { |
256 LOG_IF(FATAL, !s_allow_get_default_profile) | |
257 << "GetDefaultProfileOrOffTheRecord() caled befofre allowed."; | |
243 // TODO (mukai,nkostylev): In the long term we should fix those cases that | 258 // TODO (mukai,nkostylev): In the long term we should fix those cases that |
244 // crash on Guest mode and have only one GetDefaultProfile() method. | 259 // crash on Guest mode and have only one GetDefaultProfile() method. |
245 Profile* profile = GetDefaultProfile(); | 260 Profile* profile = GetDefaultProfile(); |
246 #if defined(OS_CHROMEOS) | 261 #if defined(OS_CHROMEOS) |
247 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) | 262 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) |
248 profile = profile->GetOffTheRecordProfile(); | 263 profile = profile->GetOffTheRecordProfile(); |
249 #endif | 264 #endif |
250 return profile; | 265 return profile; |
251 } | 266 } |
252 | 267 |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1164 ProfileManager::ProfileInfo::ProfileInfo( | 1179 ProfileManager::ProfileInfo::ProfileInfo( |
1165 Profile* profile, | 1180 Profile* profile, |
1166 bool created) | 1181 bool created) |
1167 : profile(profile), | 1182 : profile(profile), |
1168 created(created) { | 1183 created(created) { |
1169 } | 1184 } |
1170 | 1185 |
1171 ProfileManager::ProfileInfo::~ProfileInfo() { | 1186 ProfileManager::ProfileInfo::~ProfileInfo() { |
1172 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1187 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1173 } | 1188 } |
OLD | NEW |