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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 #if defined(OS_CHROMEOS) | 206 #if defined(OS_CHROMEOS) |
207 registrar_.Add( | 207 registrar_.Add( |
208 this, | 208 this, |
209 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 209 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
210 content::NotificationService::AllSources()); | 210 content::NotificationService::AllSources()); |
211 #endif | 211 #endif |
212 } | 212 } |
213 | 213 |
214 ProfileManager::~ProfileManager() { | 214 ProfileManager::~ProfileManager() { |
215 BrowserList::RemoveObserver(this); | 215 BrowserList::RemoveObserver(this); |
| 216 #if defined(OS_WIN) |
| 217 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); |
| 218 #endif |
216 } | 219 } |
217 | 220 |
218 FilePath ProfileManager::GetDefaultProfileDir( | 221 FilePath ProfileManager::GetDefaultProfileDir( |
219 const FilePath& user_data_dir) { | 222 const FilePath& user_data_dir) { |
220 FilePath default_profile_dir(user_data_dir); | 223 FilePath default_profile_dir(user_data_dir); |
221 default_profile_dir = | 224 default_profile_dir = |
222 default_profile_dir.AppendASCII(chrome::kInitialProfile); | 225 default_profile_dir.AppendASCII(chrome::kInitialProfile); |
223 return default_profile_dir; | 226 return default_profile_dir; |
224 } | 227 } |
225 | 228 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 return false; | 585 return false; |
583 } else { | 586 } else { |
584 return pair1.first < pair2.first; | 587 return pair1.first < pair2.first; |
585 } | 588 } |
586 } | 589 } |
587 | 590 |
588 ProfileInfoCache& ProfileManager::GetProfileInfoCache() { | 591 ProfileInfoCache& ProfileManager::GetProfileInfoCache() { |
589 if (!profile_info_cache_.get()) { | 592 if (!profile_info_cache_.get()) { |
590 profile_info_cache_.reset(new ProfileInfoCache( | 593 profile_info_cache_.reset(new ProfileInfoCache( |
591 g_browser_process->local_state(), user_data_dir_)); | 594 g_browser_process->local_state(), user_data_dir_)); |
| 595 #if defined(OS_WIN) |
| 596 profile_shortcut_manager_.reset(new ProfileShortcutManagerWin()); |
| 597 profile_info_cache_->AddObserver(profile_shortcut_manager_.get()); |
| 598 #endif |
592 } | 599 } |
593 return *profile_info_cache_.get(); | 600 return *profile_info_cache_.get(); |
594 } | 601 } |
595 | 602 |
596 void ProfileManager::AddProfileToCache(Profile* profile) { | 603 void ProfileManager::AddProfileToCache(Profile* profile) { |
597 ProfileInfoCache& cache = GetProfileInfoCache(); | 604 ProfileInfoCache& cache = GetProfileInfoCache(); |
598 if (profile->GetPath().DirName() != cache.GetUserDataDir()) | 605 if (profile->GetPath().DirName() != cache.GetUserDataDir()) |
599 return; | 606 return; |
600 | 607 |
601 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) | 608 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 699 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
693 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 700 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
694 } | 701 } |
695 | 702 |
696 void ProfileManager::RegisterTestingProfile(Profile* profile, | 703 void ProfileManager::RegisterTestingProfile(Profile* profile, |
697 bool add_to_cache) { | 704 bool add_to_cache) { |
698 RegisterProfile(profile, true); | 705 RegisterProfile(profile, true); |
699 if (add_to_cache) | 706 if (add_to_cache) |
700 AddProfileToCache(profile); | 707 AddProfileToCache(profile); |
701 } | 708 } |
| 709 |
| 710 #if defined(OS_WIN) |
| 711 void ProfileManager::RemoveProfileShortcutManagerForTesting() { |
| 712 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); |
| 713 } |
| 714 #endif |
OLD | NEW |