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

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

Issue 119593002: Getting rid of temporary IsGetDefaultProfileAllowed instrumentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void ProfileManager::NukeDeletedProfilesFromDisk() { 206 void ProfileManager::NukeDeletedProfilesFromDisk() {
207 for (std::vector<base::FilePath>::iterator it = 207 for (std::vector<base::FilePath>::iterator it =
208 ProfilesToDelete().begin(); 208 ProfilesToDelete().begin();
209 it != ProfilesToDelete().end(); 209 it != ProfilesToDelete().end();
210 ++it) { 210 ++it) {
211 NukeProfileFromDisk(*it); 211 NukeProfileFromDisk(*it);
212 } 212 }
213 ProfilesToDelete().clear(); 213 ProfilesToDelete().clear();
214 } 214 }
215 215
216 namespace {
217
218 bool s_allow_get_default_profile = false;
219
220 } // namespace
221
222 // static
223 void ProfileManager::AllowGetDefaultProfile() {
224 s_allow_get_default_profile = true;
225 }
226
227 // static
228 bool ProfileManager::IsGetDefaultProfileAllowed() {
229 return s_allow_get_default_profile;
230 }
231
232 // static 216 // static
233 // TODO(skuhne): Remove this method once all clients are migrated. 217 // TODO(skuhne): Remove this method once all clients are migrated.
234 Profile* ProfileManager::GetDefaultProfile() { 218 Profile* ProfileManager::GetDefaultProfile() {
235 CHECK(s_allow_get_default_profile)
236 << "GetDefaultProfile() called before allowed.";
237 ProfileManager* profile_manager = g_browser_process->profile_manager(); 219 ProfileManager* profile_manager = g_browser_process->profile_manager();
238 return profile_manager->GetDefaultProfile(profile_manager->user_data_dir_); 220 return profile_manager->GetDefaultProfile(profile_manager->user_data_dir_);
239 } 221 }
240 222
241 // static 223 // static
242 // TODO(skuhne): Remove this method once all clients are migrated. 224 // TODO(skuhne): Remove this method once all clients are migrated.
243 Profile* ProfileManager::GetDefaultProfileOrOffTheRecord() { 225 Profile* ProfileManager::GetDefaultProfileOrOffTheRecord() {
244 return GetDefaultProfile(); 226 return GetDefaultProfile();
245 } 227 }
246 228
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 continue; 397 continue;
416 } 398 }
417 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile))); 399 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile)));
418 } 400 }
419 } 401 }
420 return to_return; 402 return to_return;
421 } 403 }
422 404
423 Profile* ProfileManager::GetPrimaryUserProfile() { 405 Profile* ProfileManager::GetPrimaryUserProfile() {
424 #if defined(OS_CHROMEOS) 406 #if defined(OS_CHROMEOS)
425 // TODO(skuhne): Remove once GetDefaultProfile is removed.
426 CHECK(s_allow_get_default_profile)
427 << "GetPrimaryUserProfile() called before allowed.";
428 ProfileManager* profile_manager = g_browser_process->profile_manager(); 407 ProfileManager* profile_manager = g_browser_process->profile_manager();
429 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized()) 408 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized())
430 return GetDefaultProfile(); 409 return GetDefaultProfile();
431 chromeos::UserManager* manager = chromeos::UserManager::Get(); 410 chromeos::UserManager* manager = chromeos::UserManager::Get();
432 // Note: The user manager will take care of guest profiles. 411 // Note: The user manager will take care of guest profiles.
433 return manager->GetProfileByUser(manager->GetPrimaryUser()); 412 return manager->GetProfileByUser(manager->GetPrimaryUser());
434 #else 413 #else
435 return GetDefaultProfile(); 414 return GetDefaultProfile();
436 #endif 415 #endif
437 } 416 }
438 417
439 Profile* ProfileManager::GetActiveUserProfile() { 418 Profile* ProfileManager::GetActiveUserProfile() {
440 #if defined(OS_CHROMEOS) 419 #if defined(OS_CHROMEOS)
441 // TODO(skuhne): Remove once GetDefaultProfile is removed.
442 CHECK(s_allow_get_default_profile)
443 << "GetActiveUserProfile() called before allowed.";
444 ProfileManager* profile_manager = g_browser_process->profile_manager(); 420 ProfileManager* profile_manager = g_browser_process->profile_manager();
445 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized()) 421 if (!profile_manager->IsLoggedIn() || !chromeos::UserManager::IsInitialized())
446 return GetDefaultProfile(); 422 return GetDefaultProfile();
447 chromeos::UserManager* manager = chromeos::UserManager::Get(); 423 chromeos::UserManager* manager = chromeos::UserManager::Get();
448 // Note: The user manager will take care of guest profiles. 424 // Note: The user manager will take care of guest profiles.
449 return manager->GetProfileByUser(manager->GetActiveUser()); 425 return manager->GetProfileByUser(manager->GetActiveUser());
450 #else 426 #else
451 return GetDefaultProfile(); 427 return GetDefaultProfile();
452 #endif 428 #endif
453 } 429 }
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 ProfileManager::ProfileInfo::ProfileInfo( 1255 ProfileManager::ProfileInfo::ProfileInfo(
1280 Profile* profile, 1256 Profile* profile,
1281 bool created) 1257 bool created)
1282 : profile(profile), 1258 : profile(profile),
1283 created(created) { 1259 created(created) {
1284 } 1260 }
1285 1261
1286 ProfileManager::ProfileInfo::~ProfileInfo() { 1262 ProfileManager::ProfileInfo::~ProfileInfo() {
1287 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1263 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1288 } 1264 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/ui/ash/chrome_shell_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698