| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 85 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 86 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 86 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 87 return profile_manager->GetLastUsedProfile(user_data_dir); | 87 return profile_manager->GetLastUsedProfile(user_data_dir); |
| 88 } | 88 } |
| 89 | 89 |
| 90 ProfileManager::ProfileManager() : logged_in_(false) { | 90 ProfileManager::ProfileManager() : logged_in_(false) { |
| 91 BrowserList::AddObserver(this); | 91 BrowserList::AddObserver(this); |
| 92 #if defined(OS_CHROMEOS) | 92 #if defined(OS_CHROMEOS) |
| 93 registrar_.Add( | 93 registrar_.Add( |
| 94 this, | 94 this, |
| 95 NotificationType::LOGIN_USER_CHANGED, | 95 chrome::LOGIN_USER_CHANGED, |
| 96 NotificationService::AllSources()); | 96 NotificationService::AllSources()); |
| 97 #endif | 97 #endif |
| 98 } | 98 } |
| 99 | 99 |
| 100 ProfileManager::~ProfileManager() { | 100 ProfileManager::~ProfileManager() { |
| 101 BrowserList::RemoveObserver(this); | 101 BrowserList::RemoveObserver(this); |
| 102 } | 102 } |
| 103 | 103 |
| 104 FilePath ProfileManager::GetDefaultProfileDir( | 104 FilePath ProfileManager::GetDefaultProfileDir( |
| 105 const FilePath& user_data_dir) { | 105 const FilePath& user_data_dir) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 Profile* ProfileManager::GetProfileByPath(const FilePath& path) const { | 319 Profile* ProfileManager::GetProfileByPath(const FilePath& path) const { |
| 320 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); | 320 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); |
| 321 return (iter == profiles_info_.end()) ? NULL : iter->second->profile.get(); | 321 return (iter == profiles_info_.end()) ? NULL : iter->second->profile.get(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void ProfileManager::Observe( | 324 void ProfileManager::Observe( |
| 325 NotificationType type, | 325 NotificationType type, |
| 326 const NotificationSource& source, | 326 const NotificationSource& source, |
| 327 const NotificationDetails& details) { | 327 const NotificationDetails& details) { |
| 328 #if defined(OS_CHROMEOS) | 328 #if defined(OS_CHROMEOS) |
| 329 if (type == NotificationType::LOGIN_USER_CHANGED) { | 329 if (type == chrome::LOGIN_USER_CHANGED) { |
| 330 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 330 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 331 if (!command_line.HasSwitch(switches::kTestType)) { | 331 if (!command_line.HasSwitch(switches::kTestType)) { |
| 332 // This will fail when running on non cros os. | 332 // This will fail when running on non cros os. |
| 333 // TODO(davemoore) Need to mock this enough to enable testing. | 333 // TODO(davemoore) Need to mock this enough to enable testing. |
| 334 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); | 334 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); |
| 335 // If we don't have a mounted profile directory we're in trouble. | 335 // If we don't have a mounted profile directory we're in trouble. |
| 336 // TODO(davemoore) Once we have better api this check should ensure that | 336 // TODO(davemoore) Once we have better api this check should ensure that |
| 337 // our profile directory is the one that's mounted, and that it's mounted | 337 // our profile directory is the one that's mounted, and that it's mounted |
| 338 // as the current user. | 338 // as the current user. |
| 339 CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted()); | 339 CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 cache.AddProfileToCache( | 528 cache.AddProfileToCache( |
| 529 profile->GetPath(), | 529 profile->GetPath(), |
| 530 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); | 530 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); |
| 531 } else { | 531 } else { |
| 532 cache.AddProfileToCache( | 532 cache.AddProfileToCache( |
| 533 profile->GetPath(), | 533 profile->GetPath(), |
| 534 cache.ChooseNameForNewProfile(), | 534 cache.ChooseNameForNewProfile(), |
| 535 cache.ChooseAvatarIconIndexForNewProfile()); | 535 cache.ChooseAvatarIconIndexForNewProfile()); |
| 536 } | 536 } |
| 537 } | 537 } |
| OLD | NEW |