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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 int ChooseAvatarIconIndexForNewProfile(); | 56 int ChooseAvatarIconIndexForNewProfile(); |
57 | 57 |
58 const FilePath& GetUserDataDir() const; | 58 const FilePath& GetUserDataDir() const; |
59 | 59 |
60 // Gets the number of default avatar icons that exist. | 60 // Gets the number of default avatar icons that exist. |
61 static size_t GetDefaultAvatarIconCount(); | 61 static size_t GetDefaultAvatarIconCount(); |
62 // Gets the resource ID of the default avatar icon at |index|. | 62 // Gets the resource ID of the default avatar icon at |index|. |
63 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); | 63 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); |
64 // Returns a URL for the default avatar icon with specified index. | 64 // Returns a URL for the default avatar icon with specified index. |
65 static std::string GetDefaultAvatarIconUrl(size_t index); | 65 static std::string GetDefaultAvatarIconUrl(size_t index); |
| 66 // Checks if the given URL points to one of the default avatar icons. If it |
| 67 // is, returns true and its index through |icon_index|. If not, returns false. |
| 68 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, |
| 69 size_t *icon_index); |
66 | 70 |
67 // Register cache related preferences in Local State. | 71 // Register cache related preferences in Local State. |
68 static void RegisterPrefs(PrefService* prefs); | 72 static void RegisterPrefs(PrefService* prefs); |
69 | 73 |
70 private: | 74 private: |
71 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 75 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
72 // Saves the profile info to a cache and takes ownership of |info|. | 76 // Saves the profile info to a cache and takes ownership of |info|. |
73 // Currently the only information that is cached is the profiles name and | 77 // Currently the only information that is cached is the profiles name and |
74 // avatar icon. | 78 // avatar icon. |
75 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); | 79 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); |
76 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; | 80 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; |
77 std::vector<std::string>::iterator FindPositionForProfile( | 81 std::vector<std::string>::iterator FindPositionForProfile( |
78 std::string search_key, | 82 std::string search_key, |
79 const string16& search_name); | 83 const string16& search_name); |
80 | 84 |
81 PrefService* prefs_; | 85 PrefService* prefs_; |
82 std::vector<std::string> sorted_keys_; | 86 std::vector<std::string> sorted_keys_; |
83 FilePath user_data_dir_; | 87 FilePath user_data_dir_; |
84 | 88 |
85 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 89 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
86 }; | 90 }; |
87 | 91 |
88 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 92 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |