| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/profiles/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); | 208 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); |
| 209 DictionaryValue* cache = update.Get(); | 209 DictionaryValue* cache = update.Get(); |
| 210 | 210 |
| 211 scoped_ptr<DictionaryValue> info(new DictionaryValue); | 211 scoped_ptr<DictionaryValue> info(new DictionaryValue); |
| 212 info->SetString(kNameKey, name); | 212 info->SetString(kNameKey, name); |
| 213 info->SetString(kUserNameKey, username); | 213 info->SetString(kUserNameKey, username); |
| 214 info->SetString(kAvatarIconKey, GetDefaultAvatarIconUrl(icon_index)); | 214 info->SetString(kAvatarIconKey, GetDefaultAvatarIconUrl(icon_index)); |
| 215 // Default value for whether background apps are running is false. | 215 // Default value for whether background apps are running is false. |
| 216 info->SetBoolean(kBackgroundAppsKey, false); | 216 info->SetBoolean(kBackgroundAppsKey, false); |
| 217 info->SetString(kManagedUserId, managed_user_id); | 217 info->SetString(kManagedUserId, managed_user_id); |
| 218 cache->Set(key, info.release()); | 218 cache->SetWithoutPathExpansion(key, info.release()); |
| 219 | 219 |
| 220 sorted_keys_.insert(FindPositionForProfile(key, name), key); | 220 sorted_keys_.insert(FindPositionForProfile(key, name), key); |
| 221 | 221 |
| 222 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, | 222 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, |
| 223 observer_list_, | 223 observer_list_, |
| 224 OnProfileAdded(profile_path)); | 224 OnProfileAdded(profile_path)); |
| 225 | 225 |
| 226 content::NotificationService::current()->Notify( | 226 content::NotificationService::current()->Notify( |
| 227 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 227 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 228 content::NotificationService::AllSources(), | 228 content::NotificationService::AllSources(), |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 | 777 |
| 778 return false; | 778 return false; |
| 779 } | 779 } |
| 780 | 780 |
| 781 const DictionaryValue* ProfileInfoCache::GetInfoForProfileAtIndex( | 781 const DictionaryValue* ProfileInfoCache::GetInfoForProfileAtIndex( |
| 782 size_t index) const { | 782 size_t index) const { |
| 783 DCHECK_LT(index, GetNumberOfProfiles()); | 783 DCHECK_LT(index, GetNumberOfProfiles()); |
| 784 const DictionaryValue* cache = | 784 const DictionaryValue* cache = |
| 785 prefs_->GetDictionary(prefs::kProfileInfoCache); | 785 prefs_->GetDictionary(prefs::kProfileInfoCache); |
| 786 const DictionaryValue* info = NULL; | 786 const DictionaryValue* info = NULL; |
| 787 cache->GetDictionary(sorted_keys_[index], &info); | 787 cache->GetDictionaryWithoutPathExpansion(sorted_keys_[index], &info); |
| 788 return info; | 788 return info; |
| 789 } | 789 } |
| 790 | 790 |
| 791 void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index, | 791 void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index, |
| 792 DictionaryValue* info) { | 792 DictionaryValue* info) { |
| 793 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); | 793 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); |
| 794 DictionaryValue* cache = update.Get(); | 794 DictionaryValue* cache = update.Get(); |
| 795 cache->Set(sorted_keys_[index], info); | 795 cache->SetWithoutPathExpansion(sorted_keys_[index], info); |
| 796 | 796 |
| 797 content::NotificationService::current()->Notify( | 797 content::NotificationService::current()->Notify( |
| 798 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 798 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 799 content::NotificationService::AllSources(), | 799 content::NotificationService::AllSources(), |
| 800 content::NotificationService::NoDetails()); | 800 content::NotificationService::NoDetails()); |
| 801 } | 801 } |
| 802 | 802 |
| 803 std::string ProfileInfoCache::CacheKeyFromProfilePath( | 803 std::string ProfileInfoCache::CacheKeyFromProfilePath( |
| 804 const base::FilePath& profile_path) const { | 804 const base::FilePath& profile_path) const { |
| 805 DCHECK(user_data_dir_ == profile_path.DirName()); | 805 DCHECK(user_data_dir_ == profile_path.DirName()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 info->GetString(kNameKey, &name); | 856 info->GetString(kNameKey, &name); |
| 857 names.push_back(name); | 857 names.push_back(name); |
| 858 } | 858 } |
| 859 return names; | 859 return names; |
| 860 } | 860 } |
| 861 | 861 |
| 862 // static | 862 // static |
| 863 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { | 863 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { |
| 864 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); | 864 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 865 } | 865 } |
| OLD | NEW |