Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 18 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 19 #include "chrome/browser/profiles/profile_info_interface.h" | 19 #include "chrome/browser/profiles/profile_info_interface.h" |
| 20 #include "chrome/browser/profiles/profile_metadata_storage.h" | |
| 20 | 21 |
| 21 namespace gfx { | 22 namespace gfx { |
| 22 class Image; | 23 class Image; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class DictionaryValue; | 27 class DictionaryValue; |
| 27 } | 28 } |
| 28 | 29 |
| 29 class PrefService; | 30 class PrefService; |
| 30 class PrefRegistrySimple; | 31 class PrefRegistrySimple; |
| 31 class ProfileAvatarDownloader; | 32 class ProfileAvatarDownloader; |
| 32 | 33 |
| 33 // This class saves various information about profiles to local preferences. | 34 // This class saves various information about profiles to local preferences. |
| 34 // This cache can be used to display a list of profiles without having to | 35 // This cache can be used to display a list of profiles without having to |
| 35 // actually load the profiles from disk. | 36 // actually load the profiles from disk. |
| 36 class ProfileInfoCache : public ProfileInfoInterface, | 37 class ProfileInfoCache : public ProfileInfoInterface, |
| 38 public ProfileMetadataStorage, | |
| 37 public base::SupportsWeakPtr<ProfileInfoCache> { | 39 public base::SupportsWeakPtr<ProfileInfoCache> { |
| 38 public: | 40 public: |
| 39 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); | 41 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); |
| 40 ~ProfileInfoCache() override; | 42 ~ProfileInfoCache() override; |
| 41 | 43 |
| 42 // If the |supervised_user_id| is non-empty, the profile will be marked to be | 44 // If the |supervised_user_id| is non-empty, the profile will be marked to be |
| 43 // omitted from the avatar-menu list on desktop versions. This is used while a | 45 // omitted from the avatar-menu list on desktop versions. This is used while a |
| 44 // supervised user is in the process of being registered with the server. Use | 46 // supervised user is in the process of being registered with the server. Use |
| 45 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to | 47 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to |
| 46 // be shown in the menu. | 48 // be shown in the menu. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 const base::FilePath& profile_path); | 156 const base::FilePath& profile_path); |
| 155 | 157 |
| 156 void AddObserver(ProfileInfoCacheObserver* obs); | 158 void AddObserver(ProfileInfoCacheObserver* obs); |
| 157 void RemoveObserver(ProfileInfoCacheObserver* obs); | 159 void RemoveObserver(ProfileInfoCacheObserver* obs); |
| 158 | 160 |
| 159 void set_disable_avatar_download_for_testing( | 161 void set_disable_avatar_download_for_testing( |
| 160 bool disable_avatar_download_for_testing) { | 162 bool disable_avatar_download_for_testing) { |
| 161 disable_avatar_download_for_testing_ = disable_avatar_download_for_testing; | 163 disable_avatar_download_for_testing_ = disable_avatar_download_for_testing; |
| 162 } | 164 } |
| 163 | 165 |
| 166 // ProfileMetadataStorage implementation | |
|
Mike Lerman
2015/06/29 19:14:37
nit: I think the style standard is
// ProfileMetad
anthonyvd
2015/06/30 21:24:52
Done.
| |
| 167 void AddProfile(const base::FilePath& profile_path, | |
| 168 const base::string16& name, | |
| 169 const std::string& gaia_id, | |
| 170 const base::string16& user_name, | |
| 171 size_t icon_index, | |
| 172 const std::string& supervised_user_id) override; | |
| 173 void DeleteProfile(const base::FilePath& profile_path) override; | |
| 174 std::vector<ProfileMetadataStorage::ProfileMetadataEntry> | |
| 175 GetAllProfilesMetadata() override; | |
|
Mike Lerman
2015/06/29 19:14:37
nit: indent 4 spaces please.
anthonyvd
2015/06/30 21:24:52
Done.
| |
| 176 bool GetProfileMetadataWithPath( | |
| 177 const base::FilePath& path, | |
| 178 ProfileMetadataStorage::ProfileMetadataEntry* entry) override; | |
| 179 | |
| 164 private: | 180 private: |
| 165 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest); | 181 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest); |
| 166 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, | 182 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, |
| 167 NothingToDownloadHighResAvatarTest); | 183 NothingToDownloadHighResAvatarTest); |
| 168 | 184 |
| 169 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 185 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
| 170 // Saves the profile info to a cache and takes ownership of |info|. | 186 // Saves the profile info to a cache and takes ownership of |info|. |
| 171 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); | 187 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); |
| 172 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const; | 188 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const; |
| 173 std::vector<std::string>::iterator FindPositionForProfile( | 189 std::vector<std::string>::iterator FindPositionForProfile( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 avatar_images_downloads_in_progress_; | 256 avatar_images_downloads_in_progress_; |
| 241 | 257 |
| 242 // Determines of the ProfileAvatarDownloader should be created and executed | 258 // Determines of the ProfileAvatarDownloader should be created and executed |
| 243 // or not. Only set to true for tests. | 259 // or not. Only set to true for tests. |
| 244 bool disable_avatar_download_for_testing_; | 260 bool disable_avatar_download_for_testing_; |
| 245 | 261 |
| 246 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 262 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
| 247 }; | 263 }; |
| 248 | 264 |
| 249 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 265 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| OLD | NEW |