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