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> |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); | 29 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); |
30 ~ProfileInfoCache(); | 30 ~ProfileInfoCache(); |
31 | 31 |
32 void AddProfileToCache(const FilePath& profile_path, | 32 void AddProfileToCache(const FilePath& profile_path, |
33 const string16& name, | 33 const string16& name, |
34 size_t icon_index); | 34 size_t icon_index); |
35 void DeleteProfileFromCache(const FilePath& profile_path); | 35 void DeleteProfileFromCache(const FilePath& profile_path); |
36 | 36 |
37 size_t GetNumberOfProfiles() const; | 37 size_t GetNumberOfProfiles() const; |
38 size_t GetIndexOfProfileWithPath(const FilePath& profile_path) const; | |
39 string16 GetNameOfProfileAtIndex(size_t index) const; | 38 string16 GetNameOfProfileAtIndex(size_t index) const; |
40 FilePath GetPathOfProfileAtIndex(size_t index) const; | 39 FilePath GetPathOfProfileAtIndex(size_t index) const; |
41 const gfx::Image& GetAvatarIconOfProfileAtIndex(size_t index) const; | 40 const gfx::Image& GetAvatarIconOfProfileAtIndex(size_t index) const; |
42 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; | |
43 | 41 |
44 void SetNameOfProfileAtIndex(size_t index, const string16& name); | 42 void SetNameOfProfileAtIndex(size_t index, const string16& name); |
45 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); | 43 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); |
46 | 44 |
47 // Gets the number of default avatar icons that exist. | 45 // Gets the number of default avatar icons that exist. |
48 static size_t GetDefaultAvatarIconCount(); | 46 static size_t GetDefaultAvatarIconCount(); |
49 // Gets the resource ID of the default avatar icon at |index|. | 47 // Gets the resource ID of the default avatar icon at |index|. |
50 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); | 48 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); |
51 // Returns a URL for the default avatar icon with specified index. | |
52 static std::string GetDefaultAvatarIconUrl(size_t index); | |
53 | 49 |
54 // Register cache related preferences in Local State. | 50 // Register cache related preferences in Local State. |
55 static void RegisterPrefs(PrefService* prefs); | 51 static void RegisterPrefs(PrefService* prefs); |
56 | 52 |
57 private: | 53 private: |
58 const DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 54 const DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
59 // Saves the profile info to a cache and takes ownership of |info|. | 55 // Saves the profile info to a cache and takes ownership of |info|. |
60 // Currently the only information that is cached is the profiles name and | 56 // Currently the only information that is cached is the profiles name and |
61 // avatar icon. | 57 // avatar icon. |
62 void SetInfoForProfileAtIndex(size_t index, DictionaryValue* info); | 58 void SetInfoForProfileAtIndex(size_t index, DictionaryValue* info); |
63 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; | 59 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; |
64 std::vector<std::string>::iterator FindPositionForProfile( | 60 std::vector<std::string>::iterator FindPositionForProfile( |
65 std::string search_key, | 61 std::string search_key, |
66 const string16& search_name); | 62 const string16& search_name); |
67 | 63 |
68 PrefService* prefs_; | 64 PrefService* prefs_; |
69 std::vector<std::string> sorted_keys_; | 65 std::vector<std::string> sorted_keys_; |
70 FilePath user_data_dir_; | 66 FilePath user_data_dir_; |
71 | 67 |
72 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 68 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
73 }; | 69 }; |
74 | 70 |
75 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 71 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |