| 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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 19 #include "chrome/browser/profiles/profile_info_cache.h" | 19 #include "chrome/browser/profiles/profile_info_cache.h" |
| 20 #include "chrome/browser/sessions/session_service_factory.h" | 20 #include "chrome/browser/sessions/session_service_factory.h" |
| 21 #include "chrome/browser/sync/profile_sync_service.h" | 21 #include "chrome/browser/sync/profile_sync_service.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/logging_chrome.h" | 26 #include "chrome/common/logging_chrome.h" |
| 27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "content/browser/browser_thread.h" | 29 #include "content/browser/browser_thread.h" |
| 30 #include "content/common/content_notification_types.h" |
| 30 #include "content/common/notification_service.h" | 31 #include "content/common/notification_service.h" |
| 31 #include "content/common/notification_type.h" | |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "net/http/http_transaction_factory.h" | 33 #include "net/http/http_transaction_factory.h" |
| 34 #include "net/url_request/url_request_context.h" | 34 #include "net/url_request/url_request_context.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 35 #include "net/url_request/url_request_context_getter.h" |
| 36 #include "net/url_request/url_request_job.h" | 36 #include "net/url_request/url_request_job.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 38 | 38 |
| 39 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
| 40 #include "chrome/browser/chromeos/cros/cros_library.h" | 40 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 41 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 41 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 97 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 98 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 98 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 99 return profile_manager->GetLastUsedProfile(user_data_dir); | 99 return profile_manager->GetLastUsedProfile(user_data_dir); |
| 100 } | 100 } |
| 101 | 101 |
| 102 ProfileManager::ProfileManager() : logged_in_(false) { | 102 ProfileManager::ProfileManager() : logged_in_(false) { |
| 103 BrowserList::AddObserver(this); | 103 BrowserList::AddObserver(this); |
| 104 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
| 105 registrar_.Add( | 105 registrar_.Add( |
| 106 this, | 106 this, |
| 107 NotificationType::LOGIN_USER_CHANGED, | 107 chrome::LOGIN_USER_CHANGED, |
| 108 NotificationService::AllSources()); | 108 NotificationService::AllSources()); |
| 109 #endif | 109 #endif |
| 110 } | 110 } |
| 111 | 111 |
| 112 ProfileManager::~ProfileManager() { | 112 ProfileManager::~ProfileManager() { |
| 113 BrowserList::RemoveObserver(this); | 113 BrowserList::RemoveObserver(this); |
| 114 | 114 |
| 115 // TODO(sail): fix http://crbug.com/88586 | 115 // TODO(sail): fix http://crbug.com/88586 |
| 116 if (profiles_to_delete_.size()) { | 116 if (profiles_to_delete_.size()) { |
| 117 BrowserThread::PostTask( | 117 BrowserThread::PostTask( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 profiles_info_.insert(std::make_pair(profile->GetPath(), info)); | 335 profiles_info_.insert(std::make_pair(profile->GetPath(), info)); |
| 336 return info; | 336 return info; |
| 337 } | 337 } |
| 338 | 338 |
| 339 Profile* ProfileManager::GetProfileByPath(const FilePath& path) const { | 339 Profile* ProfileManager::GetProfileByPath(const FilePath& path) const { |
| 340 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); | 340 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); |
| 341 return (iter == profiles_info_.end()) ? NULL : iter->second->profile.get(); | 341 return (iter == profiles_info_.end()) ? NULL : iter->second->profile.get(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void ProfileManager::Observe( | 344 void ProfileManager::Observe( |
| 345 NotificationType type, | 345 int type, |
| 346 const NotificationSource& source, | 346 const NotificationSource& source, |
| 347 const NotificationDetails& details) { | 347 const NotificationDetails& details) { |
| 348 #if defined(OS_CHROMEOS) | 348 #if defined(OS_CHROMEOS) |
| 349 if (type == NotificationType::LOGIN_USER_CHANGED) { | 349 if (type == chrome::LOGIN_USER_CHANGED) { |
| 350 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 350 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 351 if (!command_line.HasSwitch(switches::kTestType)) { | 351 if (!command_line.HasSwitch(switches::kTestType)) { |
| 352 // This will fail when running on non cros os. | 352 // This will fail when running on non cros os. |
| 353 // TODO(davemoore) Need to mock this enough to enable testing. | 353 // TODO(davemoore) Need to mock this enough to enable testing. |
| 354 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); | 354 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); |
| 355 // If we don't have a mounted profile directory we're in trouble. | 355 // If we don't have a mounted profile directory we're in trouble. |
| 356 // TODO(davemoore) Once we have better api this check should ensure that | 356 // TODO(davemoore) Once we have better api this check should ensure that |
| 357 // our profile directory is the one that's mounted, and that it's mounted | 357 // our profile directory is the one that's mounted, and that it's mounted |
| 358 // as the current user. | 358 // as the current user. |
| 359 CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted()); | 359 CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 568 } |
| 569 | 569 |
| 570 // static | 570 // static |
| 571 bool ProfileManager::IsMultipleProfilesEnabled() { | 571 bool ProfileManager::IsMultipleProfilesEnabled() { |
| 572 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 572 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) |
| 573 return true; | 573 return true; |
| 574 #else | 574 #else |
| 575 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); | 575 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); |
| 576 #endif | 576 #endif |
| 577 } | 577 } |
| OLD | NEW |