| 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 491 } |
| 492 | 492 |
| 493 void ProfileManager::AddProfileToCache(Profile* profile) { | 493 void ProfileManager::AddProfileToCache(Profile* profile) { |
| 494 ProfileInfoCache& cache = GetProfileInfoCache(); | 494 ProfileInfoCache& cache = GetProfileInfoCache(); |
| 495 if (profile->GetPath().DirName() != cache.GetUserDataDir()) | 495 if (profile->GetPath().DirName() != cache.GetUserDataDir()) |
| 496 return; | 496 return; |
| 497 | 497 |
| 498 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) | 498 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) |
| 499 return; | 499 return; |
| 500 | 500 |
| 501 string16 username = UTF8ToUTF16(profile->GetPrefs()->GetString( |
| 502 prefs::kGoogleServicesUsername)); |
| 503 |
| 501 if (profile->GetPath() == GetDefaultProfileDir(cache.GetUserDataDir())) { | 504 if (profile->GetPath() == GetDefaultProfileDir(cache.GetUserDataDir())) { |
| 502 cache.AddProfileToCache( | 505 cache.AddProfileToCache( |
| 503 profile->GetPath(), | 506 profile->GetPath(), |
| 504 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); | 507 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), username, 0); |
| 505 } else { | 508 } else { |
| 506 cache.AddProfileToCache( | 509 cache.AddProfileToCache( |
| 507 profile->GetPath(), | 510 profile->GetPath(), cache.ChooseNameForNewProfile(), username, |
| 508 cache.ChooseNameForNewProfile(), | |
| 509 cache.ChooseAvatarIconIndexForNewProfile()); | 511 cache.ChooseAvatarIconIndexForNewProfile()); |
| 510 } | 512 } |
| 511 } | 513 } |
| 512 | 514 |
| 513 bool ProfileManager::ShouldGoOffTheRecord() { | 515 bool ProfileManager::ShouldGoOffTheRecord() { |
| 514 bool go_off_the_record = false; | 516 bool go_off_the_record = false; |
| 515 #if defined(OS_CHROMEOS) | 517 #if defined(OS_CHROMEOS) |
| 516 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 518 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 517 if (!logged_in_ && | 519 if (!logged_in_ && |
| 518 (!command_line.HasSwitch(switches::kTestType) || | 520 (!command_line.HasSwitch(switches::kTestType) || |
| (...skipping 27 matching lines...) Expand all Loading... |
| 546 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 548 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 547 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 549 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 548 } | 550 } |
| 549 | 551 |
| 550 void ProfileManager::RegisterTestingProfile(Profile* profile, | 552 void ProfileManager::RegisterTestingProfile(Profile* profile, |
| 551 bool add_to_cache) { | 553 bool add_to_cache) { |
| 552 RegisterProfile(profile, true); | 554 RegisterProfile(profile, true); |
| 553 if (add_to_cache) | 555 if (add_to_cache) |
| 554 AddProfileToCache(profile); | 556 AddProfileToCache(profile); |
| 555 } | 557 } |
| OLD | NEW |