Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 void SetNameOfProfileAtIndex(size_t index, const string16& name); | 54 void SetNameOfProfileAtIndex(size_t index, const string16& name); |
| 55 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); | 55 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); |
| 56 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); | 56 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); |
| 57 | 57 |
| 58 // Returns unique name that can be assigned to a newly created profile. | 58 // Returns unique name that can be assigned to a newly created profile. |
| 59 string16 ChooseNameForNewProfile(); | 59 string16 ChooseNameForNewProfile(); |
| 60 | 60 |
| 61 // Returns an avatar icon index that can be assigned to a newly created | 61 // Returns an avatar icon index that can be assigned to a newly created |
| 62 // profile. Note that the icon may not be unique since there are a limited | 62 // profile. Note that the icon may not be unique since there are a limited |
| 63 // set of default icons. | 63 // set of default icons. |
| 64 int ChooseAvatarIconIndexForNewProfile(); | 64 size_t ChooseAvatarIconIndexForNewProfile() const; |
| 65 | 65 |
| 66 const FilePath& GetUserDataDir() const; | 66 const FilePath& GetUserDataDir() const; |
| 67 | 67 |
| 68 // Gets the number of default avatar icons that exist. | 68 // Gets the number of default avatar icons that exist. |
| 69 static size_t GetDefaultAvatarIconCount(); | 69 static size_t GetDefaultAvatarIconCount(); |
| 70 // Gets the resource ID of the default avatar icon at |index|. | 70 // Gets the resource ID of the default avatar icon at |index|. |
| 71 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); | 71 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index); |
| 72 // Returns a URL for the default avatar icon with specified index. | 72 // Returns a URL for the default avatar icon with specified index. |
| 73 static std::string GetDefaultAvatarIconUrl(size_t index); | 73 static std::string GetDefaultAvatarIconUrl(size_t index); |
| 74 // Checks if the given URL points to one of the default avatar icons. If it | 74 // Checks if the given URL points to one of the default avatar icons. If it |
| 75 // is, returns true and its index through |icon_index|. If not, returns false. | 75 // is, returns true and its index through |icon_index|. If not, returns false. |
| 76 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, | 76 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, |
| 77 size_t *icon_index); | 77 size_t *icon_index); |
| 78 | 78 |
| 79 // Register cache related preferences in Local State. | 79 // Register cache related preferences in Local State. |
| 80 static void RegisterPrefs(PrefService* prefs); | 80 static void RegisterPrefs(PrefService* prefs); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 83 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
| 84 // Saves the profile info to a cache and takes ownership of |info|. | 84 // Saves the profile info to a cache and takes ownership of |info|. |
| 85 // Currently the only information that is cached is the profiles name and | 85 // Currently the only information that is cached is the profiles name and |
| 86 // avatar icon. | 86 // avatar icon. |
| 87 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); | 87 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); |
| 88 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; | 88 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const; |
| 89 std::vector<std::string>::iterator FindPositionForProfile( | 89 std::vector<std::string>::iterator FindPositionForProfile( |
| 90 std::string search_key, | 90 std::string search_key, |
| 91 const string16& search_name); | 91 const string16& search_name); |
| 92 | 92 |
| 93 // Returns true if the given icon index is not in use by another other profie. | |
|
Miranda Callahan
2011/10/11 19:17:51
Remove other.
| |
| 94 bool IconIndexIsUnique(size_t icon_index) const; | |
| 95 | |
| 96 // Tries to find an icon index that satisfies all the given conditions. | |
| 97 // Returns true if an icon was found, false otherwise. | |
| 98 bool ChooseAvatarIconIndexForNewProfile(bool allow_gender_neutral, | |
| 99 bool must_be_unique, | |
| 100 size_t* out_icon_index) const; | |
| 101 | |
| 93 PrefService* prefs_; | 102 PrefService* prefs_; |
| 94 std::vector<std::string> sorted_keys_; | 103 std::vector<std::string> sorted_keys_; |
| 95 FilePath user_data_dir_; | 104 FilePath user_data_dir_; |
| 96 | 105 |
| 97 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 106 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
| 98 }; | 107 }; |
| 99 | 108 |
| 100 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 109 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| OLD | NEW |