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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Image; | 17 class Image; |
18 } | 18 } |
19 | 19 |
| 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
| 22 } |
| 23 |
21 class PrefService; | 24 class PrefService; |
22 | 25 |
23 | 26 |
24 // This class saves various information about profiles to local preferences. | 27 // This class saves various information about profiles to local preferences. |
25 // This cache can be used to display a list of profiles without having to | 28 // This cache can be used to display a list of profiles without having to |
26 // actually load the profiles from disk. | 29 // actually load the profiles from disk. |
27 class ProfileInfoCache { | 30 class ProfileInfoCache { |
28 public: | 31 public: |
29 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); | 32 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); |
30 ~ProfileInfoCache(); | 33 ~ProfileInfoCache(); |
(...skipping 27 matching lines...) Expand all Loading... |
58 static size_t GetDefaultAvatarIconCount(); | 61 static size_t GetDefaultAvatarIconCount(); |
59 // Gets the resource ID of the default avatar icon at |index|. | 62 // Gets the resource ID of the default avatar icon at |index|. |
60 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); | 63 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); |
61 // Returns a URL for the default avatar icon with specified index. | 64 // Returns a URL for the default avatar icon with specified index. |
62 static std::string GetDefaultAvatarIconUrl(size_t index); | 65 static std::string GetDefaultAvatarIconUrl(size_t index); |
63 | 66 |
64 // Register cache related preferences in Local State. | 67 // Register cache related preferences in Local State. |
65 static void RegisterPrefs(PrefService* prefs); | 68 static void RegisterPrefs(PrefService* prefs); |
66 | 69 |
67 private: | 70 private: |
68 const DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 71 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
69 // Saves the profile info to a cache and takes ownership of |info|. | 72 // Saves the profile info to a cache and takes ownership of |info|. |
70 // Currently the only information that is cached is the profiles name and | 73 // Currently the only information that is cached is the profiles name and |
71 // avatar icon. | 74 // avatar icon. |
72 void SetInfoForProfileAtIndex(size_t index, DictionaryValue* info); | 75 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); |
73 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; | 76 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; |
74 std::vector<std::string>::iterator FindPositionForProfile( | 77 std::vector<std::string>::iterator FindPositionForProfile( |
75 std::string search_key, | 78 std::string search_key, |
76 const string16& search_name); | 79 const string16& search_name); |
77 | 80 |
78 PrefService* prefs_; | 81 PrefService* prefs_; |
79 std::vector<std::string> sorted_keys_; | 82 std::vector<std::string> sorted_keys_; |
80 FilePath user_data_dir_; | 83 FilePath user_data_dir_; |
81 | 84 |
82 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 85 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
83 }; | 86 }; |
84 | 87 |
85 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 88 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |