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 "chrome/browser/profiles/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 const char kNameKey[] = "name"; | 27 const char kNameKey[] = "name"; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return info; | 238 return info; |
238 } | 239 } |
239 | 240 |
240 void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index, | 241 void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index, |
241 DictionaryValue* info) { | 242 DictionaryValue* info) { |
242 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); | 243 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); |
243 DictionaryValue* cache = update.Get(); | 244 DictionaryValue* cache = update.Get(); |
244 cache->Set(sorted_keys_[index], info); | 245 cache->Set(sorted_keys_[index], info); |
245 | 246 |
246 NotificationService::current()->Notify( | 247 NotificationService::current()->Notify( |
247 NotificationType::PROFILE_CACHED_INFO_CHANGED, | 248 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
248 NotificationService::AllSources(), | 249 NotificationService::AllSources(), |
249 NotificationService::NoDetails()); | 250 NotificationService::NoDetails()); |
250 } | 251 } |
251 | 252 |
252 std::string ProfileInfoCache::CacheKeyFromProfilePath( | 253 std::string ProfileInfoCache::CacheKeyFromProfilePath( |
253 const FilePath& profile_path) const { | 254 const FilePath& profile_path) const { |
254 DCHECK(user_data_dir_ == profile_path.DirName()); | 255 DCHECK(user_data_dir_ == profile_path.DirName()); |
255 FilePath base_name = profile_path.BaseName(); | 256 FilePath base_name = profile_path.BaseName(); |
256 return base_name.MaybeAsASCII(); | 257 return base_name.MaybeAsASCII(); |
257 } | 258 } |
(...skipping 10 matching lines...) Expand all Loading... |
268 if (key_compare < 0) | 269 if (key_compare < 0) |
269 return sorted_keys_.begin() + i; | 270 return sorted_keys_.begin() + i; |
270 } | 271 } |
271 } | 272 } |
272 return sorted_keys_.end(); | 273 return sorted_keys_.end(); |
273 } | 274 } |
274 | 275 |
275 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { | 276 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { |
276 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); | 277 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); |
277 } | 278 } |
OLD | NEW |