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> |
| 11 #include <map> | |
|
Miranda Callahan
2011/11/17 15:21:10
nit: alpha order
sail
2011/11/21 23:52:47
Done.
| |
| 11 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 15 #include "base/string16.h" | 16 #include "base/string16.h" |
| 16 #include "chrome/browser/profiles/profile_info_interface.h" | 17 #include "chrome/browser/profiles/profile_info_interface.h" |
| 17 | 18 |
| 19 namespace base { | |
| 20 class DictionaryValue; | |
| 21 } | |
|
Robert Sesek
2011/11/17 20:42:04
nit: blank line after
sail
2011/11/21 23:52:47
Done.
| |
| 18 namespace gfx { | 22 namespace gfx { |
| 19 class Image; | 23 class Image; |
| 20 } | 24 } |
| 21 | 25 |
| 22 namespace base { | |
| 23 class DictionaryValue; | |
| 24 } | |
| 25 | |
| 26 class PrefService; | 26 class PrefService; |
| 27 | 27 |
| 28 | 28 |
| 29 // This class saves various information about profiles to local preferences. | 29 // This class saves various information about profiles to local preferences. |
| 30 // This cache can be used to display a list of profiles without having to | 30 // This cache can be used to display a list of profiles without having to |
| 31 // actually load the profiles from disk. | 31 // actually load the profiles from disk. |
| 32 class ProfileInfoCache : public ProfileInfoInterface { | 32 class ProfileInfoCache : public ProfileInfoInterface { |
| 33 public: | 33 public: |
| 34 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); | 34 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); |
| 35 virtual ~ProfileInfoCache(); | 35 virtual ~ProfileInfoCache(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 46 // the item being referred to to change out from under you. | 46 // the item being referred to to change out from under you. |
| 47 virtual size_t GetIndexOfProfileWithPath( | 47 virtual size_t GetIndexOfProfileWithPath( |
| 48 const FilePath& profile_path) const OVERRIDE; | 48 const FilePath& profile_path) const OVERRIDE; |
| 49 virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE; | 49 virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE; |
| 50 virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE; | 50 virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE; |
| 51 virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE; | 51 virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE; |
| 52 virtual const gfx::Image& GetAvatarIconOfProfileAtIndex( | 52 virtual const gfx::Image& GetAvatarIconOfProfileAtIndex( |
| 53 size_t index) const OVERRIDE; | 53 size_t index) const OVERRIDE; |
| 54 virtual bool GetBackgroundStatusOfProfileAtIndex( | 54 virtual bool GetBackgroundStatusOfProfileAtIndex( |
| 55 size_t index) const OVERRIDE; | 55 size_t index) const OVERRIDE; |
| 56 virtual string16 GetGAIANameOfProfileAtIndex(size_t index) const OVERRIDE; | |
| 57 virtual bool GetIsUsingGAIANameOfProfileAtIndex(size_t index) const OVERRIDE; | |
|
Robert Sesek
2011/11/17 20:42:04
When you return bool, I don't think you need the G
sail
2011/11/21 23:52:47
Done.
| |
| 58 virtual const gfx::Image& GetGAIAPictureOfProfileAtIndex( | |
| 59 size_t index) const OVERRIDE; | |
| 60 virtual bool GetIsUsingGAIAPictureOfProfileAtIndex( | |
|
Robert Sesek
2011/11/17 20:42:04
Same here.
sail
2011/11/21 23:52:47
Done.
| |
| 61 size_t index) const OVERRIDE; | |
| 56 | 62 |
| 57 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; | 63 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; |
| 58 | 64 |
| 59 void SetNameOfProfileAtIndex(size_t index, const string16& name); | 65 void SetNameOfProfileAtIndex(size_t index, const string16& name); |
| 60 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); | 66 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); |
| 61 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); | 67 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); |
| 62 void SetBackgroundStatusOfProfileAtIndex(size_t index, | 68 void SetBackgroundStatusOfProfileAtIndex(size_t index, |
| 63 bool running_background_apps); | 69 bool running_background_apps); |
| 70 void SetGAIANameOfProfileAtIndex(size_t index, const string16& name); | |
| 71 void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value); | |
| 72 void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image& image); | |
| 73 void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value); | |
| 64 | 74 |
| 65 // Returns unique name that can be assigned to a newly created profile. | 75 // Returns unique name that can be assigned to a newly created profile. |
| 66 string16 ChooseNameForNewProfile(size_t icon_index); | 76 string16 ChooseNameForNewProfile(size_t icon_index); |
| 67 | 77 |
| 78 bool GetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index) const; | |
|
Miranda Callahan
2011/11/17 15:21:10
Could you add a comment for these two?
Robert Sesek
2011/11/17 20:42:04
And here.
sail
2011/11/21 23:52:47
Done.
sail
2011/11/21 23:52:47
Done.
| |
| 79 void SetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index, bool value); | |
| 80 | |
| 68 // Returns an avatar icon index that can be assigned to a newly created | 81 // Returns an avatar icon index that can be assigned to a newly created |
| 69 // profile. Note that the icon may not be unique since there are a limited | 82 // profile. Note that the icon may not be unique since there are a limited |
| 70 // set of default icons. | 83 // set of default icons. |
| 71 size_t ChooseAvatarIconIndexForNewProfile() const; | 84 size_t ChooseAvatarIconIndexForNewProfile() const; |
| 72 | 85 |
| 73 const FilePath& GetUserDataDir() const; | 86 const FilePath& GetUserDataDir() const; |
| 74 | 87 |
| 75 // Gets the number of default avatar icons that exist. | 88 // Gets the number of default avatar icons that exist. |
| 76 static size_t GetDefaultAvatarIconCount(); | 89 static size_t GetDefaultAvatarIconCount(); |
| 77 // Gets the resource ID of the default avatar icon at |index|. | 90 // Gets the resource ID of the default avatar icon at |index|. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 99 | 112 |
| 100 // Returns true if the given icon index is not in use by another profie. | 113 // Returns true if the given icon index is not in use by another profie. |
| 101 bool IconIndexIsUnique(size_t icon_index) const; | 114 bool IconIndexIsUnique(size_t icon_index) const; |
| 102 | 115 |
| 103 // Tries to find an icon index that satisfies all the given conditions. | 116 // Tries to find an icon index that satisfies all the given conditions. |
| 104 // Returns true if an icon was found, false otherwise. | 117 // Returns true if an icon was found, false otherwise. |
| 105 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon, | 118 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon, |
| 106 bool must_be_unique, | 119 bool must_be_unique, |
| 107 size_t* out_icon_index) const; | 120 size_t* out_icon_index) const; |
| 108 | 121 |
| 122 void UpdateSortForProfileIndex(size_t index); | |
|
Miranda Callahan
2011/11/17 15:21:10
Comment for this one, too.
sail
2011/11/21 23:52:47
Done.
| |
| 123 | |
| 124 void OnGAIAPictureLoaded(FilePath path, gfx::Image* image) const; | |
| 125 void OnGAIAPictureSaved(FilePath path, bool success) const; | |
| 126 | |
| 109 PrefService* prefs_; | 127 PrefService* prefs_; |
| 110 std::vector<std::string> sorted_keys_; | 128 std::vector<std::string> sorted_keys_; |
| 111 FilePath user_data_dir_; | 129 FilePath user_data_dir_; |
| 112 | 130 |
| 131 // A cache of gaia profile pictures. This cache is updated lazily so it needs | |
| 132 // to be mutable. | |
| 133 mutable std::map<std::string, gfx::Image*> gaia_pictures_; | |
| 134 | |
| 113 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 135 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
| 114 }; | 136 }; |
| 115 | 137 |
| 116 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 138 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| OLD | NEW |