Chromium Code Reviews| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 218 |
| 219 void ProfileInfoCache::AddObserver(ProfileInfoCacheObserver* obs) { | 219 void ProfileInfoCache::AddObserver(ProfileInfoCacheObserver* obs) { |
| 220 observer_list_.AddObserver(obs); | 220 observer_list_.AddObserver(obs); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void ProfileInfoCache::RemoveObserver(ProfileInfoCacheObserver* obs) { | 223 void ProfileInfoCache::RemoveObserver(ProfileInfoCacheObserver* obs) { |
| 224 observer_list_.RemoveObserver(obs); | 224 observer_list_.RemoveObserver(obs); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ProfileInfoCache::DeleteProfileFromCache(const FilePath& profile_path) { | 227 void ProfileInfoCache::DeleteProfileFromCache(const FilePath& profile_path) { |
| 228 string16 name = GetNameOfProfileAtIndex( | 228 size_t profile_index = GetIndexOfProfileWithPath(profile_path); |
| 229 GetIndexOfProfileWithPath(profile_path)); | 229 if (profile_index == std::string::npos) { |
| 230 NOTREACHED(); | |
|
sail
2012/05/28 18:45:07
Hm... I don't think this NOTREACHED() is going to
Evan Stade
2012/05/29 18:12:13
this seems safer in case the code ever changes, so
sail
2012/05/29 18:38:21
makes sense!
| |
| 231 return; | |
| 232 } | |
| 233 string16 name = GetNameOfProfileAtIndex(profile_index); | |
| 230 | 234 |
| 231 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, | 235 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, |
| 232 observer_list_, | 236 observer_list_, |
| 233 OnProfileWillBeRemoved(profile_path)); | 237 OnProfileWillBeRemoved(profile_path)); |
| 234 | 238 |
| 235 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); | 239 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); |
| 236 DictionaryValue* cache = update.Get(); | 240 DictionaryValue* cache = update.Get(); |
| 237 std::string key = CacheKeyFromProfilePath(profile_path); | 241 std::string key = CacheKeyFromProfilePath(profile_path); |
| 238 cache->Remove(key, NULL); | 242 cache->Remove(key, NULL); |
| 239 sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key)); | 243 sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key)); |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 info->GetString(kNameKey, &name); | 787 info->GetString(kNameKey, &name); |
| 784 names.push_back(name); | 788 names.push_back(name); |
| 785 } | 789 } |
| 786 return names; | 790 return names; |
| 787 } | 791 } |
| 788 | 792 |
| 789 // static | 793 // static |
| 790 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { | 794 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { |
| 791 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); | 795 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 792 } | 796 } |
| OLD | NEW |