Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/profiles/profile_info_cache.cc

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ProfileInfoCache::ProfileInfoCache(PrefService* prefs, 168 ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
169 const FilePath& user_data_dir) 169 const FilePath& user_data_dir)
170 : prefs_(prefs), 170 : prefs_(prefs),
171 user_data_dir_(user_data_dir) { 171 user_data_dir_(user_data_dir) {
172 // Populate the cache 172 // Populate the cache
173 const DictionaryValue* cache = 173 const DictionaryValue* cache =
174 prefs_->GetDictionary(prefs::kProfileInfoCache); 174 prefs_->GetDictionary(prefs::kProfileInfoCache);
175 for (DictionaryValue::key_iterator it = cache->begin_keys(); 175 for (DictionaryValue::key_iterator it = cache->begin_keys();
176 it != cache->end_keys(); ++it) { 176 it != cache->end_keys(); ++it) {
177 std::string key = *it; 177 std::string key = *it;
178 DictionaryValue* info = NULL; 178 const DictionaryValue* info = NULL;
179 cache->GetDictionary(key, &info); 179 cache->GetDictionary(key, &info);
180 string16 name; 180 string16 name;
181 info->GetString(kNameKey, &name); 181 info->GetString(kNameKey, &name);
182 sorted_keys_.insert(FindPositionForProfile(key, name), key); 182 sorted_keys_.insert(FindPositionForProfile(key, name), key);
183 } 183 }
184 } 184 }
185 185
186 ProfileInfoCache::~ProfileInfoCache() { 186 ProfileInfoCache::~ProfileInfoCache() {
187 STLDeleteContainerPairSecondPointers( 187 STLDeleteContainerPairSecondPointers(
188 gaia_pictures_.begin(), gaia_pictures_.end()); 188 gaia_pictures_.begin(), gaia_pictures_.end());
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 706 }
707 707
708 return false; 708 return false;
709 } 709 }
710 710
711 const DictionaryValue* ProfileInfoCache::GetInfoForProfileAtIndex( 711 const DictionaryValue* ProfileInfoCache::GetInfoForProfileAtIndex(
712 size_t index) const { 712 size_t index) const {
713 DCHECK_LT(index, GetNumberOfProfiles()); 713 DCHECK_LT(index, GetNumberOfProfiles());
714 const DictionaryValue* cache = 714 const DictionaryValue* cache =
715 prefs_->GetDictionary(prefs::kProfileInfoCache); 715 prefs_->GetDictionary(prefs::kProfileInfoCache);
716 DictionaryValue* info = NULL; 716 const DictionaryValue* info = NULL;
717 cache->GetDictionary(sorted_keys_[index], &info); 717 cache->GetDictionary(sorted_keys_[index], &info);
718 return info; 718 return info;
719 } 719 }
720 720
721 void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index, 721 void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index,
722 DictionaryValue* info) { 722 DictionaryValue* info) {
723 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); 723 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
724 DictionaryValue* cache = update.Get(); 724 DictionaryValue* cache = update.Get();
725 cache->Set(sorted_keys_[index], info); 725 cache->Set(sorted_keys_[index], info);
726 726
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // static 775 // static
776 std::vector<string16> ProfileInfoCache::GetProfileNames() { 776 std::vector<string16> ProfileInfoCache::GetProfileNames() {
777 std::vector<string16> names; 777 std::vector<string16> names;
778 PrefService* local_state = g_browser_process->local_state(); 778 PrefService* local_state = g_browser_process->local_state();
779 const DictionaryValue* cache = local_state->GetDictionary( 779 const DictionaryValue* cache = local_state->GetDictionary(
780 prefs::kProfileInfoCache); 780 prefs::kProfileInfoCache);
781 string16 name; 781 string16 name;
782 for (base::DictionaryValue::key_iterator it = cache->begin_keys(); 782 for (base::DictionaryValue::key_iterator it = cache->begin_keys();
783 it != cache->end_keys(); 783 it != cache->end_keys();
784 ++it) { 784 ++it) {
785 base::DictionaryValue* info = NULL; 785 const base::DictionaryValue* info = NULL;
786 cache->GetDictionary(*it, &info); 786 cache->GetDictionary(*it, &info);
787 info->GetString(kNameKey, &name); 787 info->GetString(kNameKey, &name);
788 names.push_back(name); 788 names.push_back(name);
789 } 789 }
790 return names; 790 return names;
791 } 791 }
792 792
793 // static 793 // static
794 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { 794 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) {
795 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); 795 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache);
796 } 796 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_job_worker.cc ('k') | chrome/browser/ui/webui/print_preview/print_preview_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698