Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: chrome/browser/profiles/profile_info_cache.h

Issue 1242793005: Refactor most c/b/profiles calls to ProfileInfoCache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows unit test and ChromeOS build Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 const base::string16& name); 128 const base::string16& name);
129 void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image); 129 void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image);
130 void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value); 130 void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
131 void SetProfileSigninRequiredAtIndex(size_t index, bool value); 131 void SetProfileSigninRequiredAtIndex(size_t index, bool value);
132 void SetProfileIsEphemeralAtIndex(size_t index, bool value); 132 void SetProfileIsEphemeralAtIndex(size_t index, bool value);
133 void SetProfileIsUsingDefaultNameAtIndex(size_t index, bool value); 133 void SetProfileIsUsingDefaultNameAtIndex(size_t index, bool value);
134 void SetProfileIsUsingDefaultAvatarAtIndex(size_t index, bool value); 134 void SetProfileIsUsingDefaultAvatarAtIndex(size_t index, bool value);
135 void SetProfileIsAuthErrorAtIndex(size_t index, bool value); 135 void SetProfileIsAuthErrorAtIndex(size_t index, bool value);
136 136
137 // Determines whether |name| is one of the default assigned names. 137 // Determines whether |name| is one of the default assigned names.
138 bool IsDefaultProfileName(const base::string16& name) const; 138 bool IsDefaultProfileName(const base::string16& name) const override;
139 139
140 // Returns unique name that can be assigned to a newly created profile. 140 // Returns unique name that can be assigned to a newly created profile.
141 base::string16 ChooseNameForNewProfile(size_t icon_index) const; 141 base::string16 ChooseNameForNewProfile(size_t icon_index) const override;
142 142
143 // Returns an avatar icon index that can be assigned to a newly created 143 // Returns an avatar icon index that can be assigned to a newly created
144 // profile. Note that the icon may not be unique since there are a limited 144 // profile. Note that the icon may not be unique since there are a limited
145 // set of default icons. 145 // set of default icons.
146 size_t ChooseAvatarIconIndexForNewProfile() const; 146 size_t ChooseAvatarIconIndexForNewProfile() const;
147 147
148 const base::FilePath& GetUserDataDir() const; 148 const base::FilePath& GetUserDataDir() const override;
149 149
150 // Register cache related preferences in Local State. 150 // Register cache related preferences in Local State.
151 static void RegisterPrefs(PrefRegistrySimple* registry); 151 static void RegisterPrefs(PrefRegistrySimple* registry);
152 152
153 // Checks whether the high res avatar at index |icon_index| exists, and 153 // Checks whether the high res avatar at index |icon_index| exists, and
154 // if it does not, calls |DownloadHighResAvatar|. 154 // if it does not, calls |DownloadHighResAvatar|.
155 void DownloadHighResAvatarIfNeeded(size_t icon_index, 155 void DownloadHighResAvatarIfNeeded(size_t icon_index,
156 const base::FilePath& profile_path); 156 const base::FilePath& profile_path);
157 157
158 // Saves the avatar |image| at |image_path|. This is used both for the 158 // Saves the avatar |image| at |image_path|. This is used both for the
159 // GAIA profile pictures and the ProfileAvatarDownloader that is used to 159 // GAIA profile pictures and the ProfileAvatarDownloader that is used to
160 // download the high res avatars. 160 // download the high res avatars.
161 void SaveAvatarImageAtPath(const gfx::Image* image, 161 void SaveAvatarImageAtPath(const gfx::Image* image,
162 const std::string& key, 162 const std::string& key,
163 const base::FilePath& image_path, 163 const base::FilePath& image_path,
164 const base::FilePath& profile_path); 164 const base::FilePath& profile_path) override;
165 165
166 void AddObserver(ProfileInfoCacheObserver* obs); 166 void AddObserver(ProfileInfoCacheObserver* obs) override;
167 void RemoveObserver(ProfileInfoCacheObserver* obs); 167 void RemoveObserver(ProfileInfoCacheObserver* obs) override;
168 168
169 void set_disable_avatar_download_for_testing( 169 void set_disable_avatar_download_for_testing(
170 bool disable_avatar_download_for_testing) { 170 bool disable_avatar_download_for_testing) {
171 disable_avatar_download_for_testing_ = disable_avatar_download_for_testing; 171 disable_avatar_download_for_testing_ = disable_avatar_download_for_testing;
172 } 172 }
173 173
174 // ProfileAttributesStorage: 174 // ProfileAttributesStorage:
175 void AddProfile(const base::FilePath& profile_path, 175 void AddProfile(const base::FilePath& profile_path,
176 const base::string16& name, 176 const base::string16& name,
177 const std::string& gaia_id, 177 const std::string& gaia_id,
178 const base::string16& user_name, 178 const base::string16& user_name,
179 size_t icon_index, 179 size_t icon_index,
180 const std::string& supervised_user_id) override; 180 const std::string& supervised_user_id) override;
181 void RemoveProfile(const base::FilePath& profile_path) override; 181 void RemoveProfile(const base::FilePath& profile_path) override;
182 // Returns a vector containing one attributes entry per known profile. They 182 // Returns a vector containing one attributes entry per known profile. They
183 // are not sorted in any particular order. 183 // are not sorted in any particular order.
184 std::vector<ProfileAttributesEntry*> GetAllProfilesAttributes() override; 184 std::vector<ProfileAttributesEntry*> GetAllProfilesAttributes() override;
185 bool GetProfileAttributesWithPath( 185 bool GetProfileAttributesWithPath(
186 const base::FilePath& path, 186 const base::FilePath& path,
187 ProfileAttributesEntry** entry) override; 187 ProfileAttributesEntry** entry) override;
188 188
189 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const;
189 private: 190 private:
190 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest); 191 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest);
191 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, 192 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest,
192 NothingToDownloadHighResAvatarTest); 193 NothingToDownloadHighResAvatarTest);
193 194
194 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; 195 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
195 // Saves the profile info to a cache and takes ownership of |info|. 196 // Saves the profile info to a cache and takes ownership of |info|.
196 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); 197 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info);
197 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const;
198 std::vector<std::string>::iterator FindPositionForProfile( 198 std::vector<std::string>::iterator FindPositionForProfile(
199 const std::string& search_key, 199 const std::string& search_key,
200 const base::string16& search_name); 200 const base::string16& search_name);
201 201
202 // Returns true if the given icon index is not in use by another profie. 202 // Returns true if the given icon index is not in use by another profie.
203 bool IconIndexIsUnique(size_t icon_index) const; 203 bool IconIndexIsUnique(size_t icon_index) const;
204 204
205 // Tries to find an icon index that satisfies all the given conditions. 205 // Tries to find an icon index that satisfies all the given conditions.
206 // Returns true if an icon was found, false otherwise. 206 // Returns true if an icon was found, false otherwise.
207 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon, 207 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 avatar_images_downloads_in_progress_; 267 avatar_images_downloads_in_progress_;
268 268
269 // Determines of the ProfileAvatarDownloader should be created and executed 269 // Determines of the ProfileAvatarDownloader should be created and executed
270 // or not. Only set to true for tests. 270 // or not. Only set to true for tests.
271 bool disable_avatar_download_for_testing_; 271 bool disable_avatar_download_for_testing_;
272 272
273 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); 273 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
274 }; 274 };
275 275
276 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ 276 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698