| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 | 97 |
| 98 // static | 98 // static |
| 99 Profile* ProfileManager::GetLastUsedProfile() { | 99 Profile* ProfileManager::GetLastUsedProfile() { |
| 100 FilePath user_data_dir; | 100 FilePath user_data_dir; |
| 101 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 101 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 102 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 102 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 103 return profile_manager->GetLastUsedProfile(user_data_dir); | 103 return profile_manager->GetLastUsedProfile(user_data_dir); |
| 104 } | 104 } |
| 105 | 105 |
| 106 ProfileManager::ProfileManager() : logged_in_(false) { | 106 ProfileManager::ProfileManager() : logged_in_(false), |
| 107 will_import_(false) { |
| 107 BrowserList::AddObserver(this); | 108 BrowserList::AddObserver(this); |
| 108 #if defined(OS_CHROMEOS) | 109 #if defined(OS_CHROMEOS) |
| 109 registrar_.Add( | 110 registrar_.Add( |
| 110 this, | 111 this, |
| 111 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 112 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 112 NotificationService::AllSources()); | 113 NotificationService::AllSources()); |
| 113 #endif | 114 #endif |
| 114 } | 115 } |
| 115 | 116 |
| 116 ProfileManager::~ProfileManager() { | 117 ProfileManager::~ProfileManager() { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // TODO(davemoore) Once we have better api this check should ensure that | 334 // TODO(davemoore) Once we have better api this check should ensure that |
| 334 // our profile directory is the one that's mounted, and that it's mounted | 335 // our profile directory is the one that's mounted, and that it's mounted |
| 335 // as the current user. | 336 // as the current user. |
| 336 CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted()); | 337 CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted()); |
| 337 } | 338 } |
| 338 logged_in_ = true; | 339 logged_in_ = true; |
| 339 } | 340 } |
| 340 #endif | 341 #endif |
| 341 } | 342 } |
| 342 | 343 |
| 344 void ProfileManager::SetWillImport(bool will_import, Profile* profile) { |
| 345 will_import_ = will_import; |
| 346 if (!will_import) { |
| 347 DCHECK(profile); |
| 348 NotificationService::current()->Notify( |
| 349 chrome::NOTIFICATION_IMPORT_FINISHED, |
| 350 Source<Profile>(profile), |
| 351 NotificationService::NoDetails()); |
| 352 } |
| 353 } |
| 354 |
| 343 void ProfileManager::OnBrowserAdded(const Browser* browser) {} | 355 void ProfileManager::OnBrowserAdded(const Browser* browser) {} |
| 344 | 356 |
| 345 void ProfileManager::OnBrowserRemoved(const Browser* browser) {} | 357 void ProfileManager::OnBrowserRemoved(const Browser* browser) {} |
| 346 | 358 |
| 347 void ProfileManager::OnBrowserSetLastActive(const Browser* browser) { | 359 void ProfileManager::OnBrowserSetLastActive(const Browser* browser) { |
| 348 Profile* last_active = browser->GetProfile(); | 360 Profile* last_active = browser->GetProfile(); |
| 349 PrefService* local_state = g_browser_process->local_state(); | 361 PrefService* local_state = g_browser_process->local_state(); |
| 350 DCHECK(local_state); | 362 DCHECK(local_state); |
| 351 // Only keep track of profiles that we are managing; tests may create others. | 363 // Only keep track of profiles that we are managing; tests may create others. |
| 352 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) { | 364 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 cache.DeleteProfileFromCache(profile_dir); | 569 cache.DeleteProfileFromCache(profile_dir); |
| 558 } | 570 } |
| 559 | 571 |
| 560 // static | 572 // static |
| 561 bool ProfileManager::IsMultipleProfilesEnabled() { | 573 bool ProfileManager::IsMultipleProfilesEnabled() { |
| 562 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 574 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) |
| 563 return true; | 575 return true; |
| 564 #endif | 576 #endif |
| 565 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); | 577 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); |
| 566 } | 578 } |
| OLD | NEW |