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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 return false; | 586 return false; |
584 } else { | 587 } else { |
585 return pair1.first < pair2.first; | 588 return pair1.first < pair2.first; |
586 } | 589 } |
587 } | 590 } |
588 | 591 |
589 ProfileInfoCache& ProfileManager::GetProfileInfoCache() { | 592 ProfileInfoCache& ProfileManager::GetProfileInfoCache() { |
590 if (!profile_info_cache_.get()) { | 593 if (!profile_info_cache_.get()) { |
591 profile_info_cache_.reset(new ProfileInfoCache( | 594 profile_info_cache_.reset(new ProfileInfoCache( |
592 g_browser_process->local_state(), user_data_dir_)); | 595 g_browser_process->local_state(), user_data_dir_)); |
| 596 #if defined(OS_WIN) |
| 597 profile_shortcut_manager_.reset(new ProfileShortcutManagerWin()); |
| 598 profile_info_cache_->AddObserver(profile_shortcut_manager_.get()); |
| 599 #endif |
593 } | 600 } |
594 return *profile_info_cache_.get(); | 601 return *profile_info_cache_.get(); |
595 } | 602 } |
596 | 603 |
597 void ProfileManager::AddProfileToCache(Profile* profile) { | 604 void ProfileManager::AddProfileToCache(Profile* profile) { |
598 ProfileInfoCache& cache = GetProfileInfoCache(); | 605 ProfileInfoCache& cache = GetProfileInfoCache(); |
599 if (profile->GetPath().DirName() != cache.GetUserDataDir()) | 606 if (profile->GetPath().DirName() != cache.GetUserDataDir()) |
600 return; | 607 return; |
601 | 608 |
602 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) | 609 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 684 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
678 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 685 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
679 } | 686 } |
680 | 687 |
681 void ProfileManager::RegisterTestingProfile(Profile* profile, | 688 void ProfileManager::RegisterTestingProfile(Profile* profile, |
682 bool add_to_cache) { | 689 bool add_to_cache) { |
683 RegisterProfile(profile, true); | 690 RegisterProfile(profile, true); |
684 if (add_to_cache) | 691 if (add_to_cache) |
685 AddProfileToCache(profile); | 692 AddProfileToCache(profile); |
686 } | 693 } |
OLD | NEW |