OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" | 20 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" |
21 #include "chrome/browser/profiles/profile_downloader_delegate.h" | 21 #include "chrome/browser/profiles/profile_downloader_delegate.h" |
22 #include "components/user_manager/user.h" | 22 #include "components/user_manager/user.h" |
23 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
24 | 24 |
25 class ProfileDownloader; | 25 class ProfileDownloader; |
(...skipping 18 matching lines...) Expand all Loading... |
44 public: | 44 public: |
45 // UserImageManager: | 45 // UserImageManager: |
46 UserImageManagerImpl(const std::string& user_id, | 46 UserImageManagerImpl(const std::string& user_id, |
47 user_manager::UserManager* user_manager); | 47 user_manager::UserManager* user_manager); |
48 ~UserImageManagerImpl() override; | 48 ~UserImageManagerImpl() override; |
49 | 49 |
50 void LoadUserImage() override; | 50 void LoadUserImage() override; |
51 void UserLoggedIn(bool user_is_new, bool user_is_local) override; | 51 void UserLoggedIn(bool user_is_new, bool user_is_local) override; |
52 void UserProfileCreated() override; | 52 void UserProfileCreated() override; |
53 void SaveUserDefaultImageIndex(int default_image_index) override; | 53 void SaveUserDefaultImageIndex(int default_image_index) override; |
54 void SaveUserImage(scoped_ptr<user_manager::UserImage> user_image) override; | 54 void SaveUserImage( |
| 55 std::unique_ptr<user_manager::UserImage> user_image) override; |
55 void SaveUserImageFromFile(const base::FilePath& path) override; | 56 void SaveUserImageFromFile(const base::FilePath& path) override; |
56 void SaveUserImageFromProfileImage() override; | 57 void SaveUserImageFromProfileImage() override; |
57 void DeleteUserImage() override; | 58 void DeleteUserImage() override; |
58 void DownloadProfileImage(const std::string& reason) override; | 59 void DownloadProfileImage(const std::string& reason) override; |
59 const gfx::ImageSkia& DownloadedProfileImage() const override; | 60 const gfx::ImageSkia& DownloadedProfileImage() const override; |
60 UserImageSyncObserver* GetSyncObserver() const override; | 61 UserImageSyncObserver* GetSyncObserver() const override; |
61 void Shutdown() override; | 62 void Shutdown() override; |
62 | 63 |
63 void OnExternalDataSet(const std::string& policy) override; | 64 void OnExternalDataSet(const std::string& policy) override; |
64 void OnExternalDataCleared(const std::string& policy) override; | 65 void OnExternalDataCleared(const std::string& policy) override; |
65 void OnExternalDataFetched(const std::string& policy, | 66 void OnExternalDataFetched(const std::string& policy, |
66 scoped_ptr<std::string> data) override; | 67 std::unique_ptr<std::string> data) override; |
67 | 68 |
68 static void IgnoreProfileDataDownloadDelayForTesting(); | 69 static void IgnoreProfileDataDownloadDelayForTesting(); |
69 | 70 |
70 // Key for a dictionary that maps user IDs to user image data with images | 71 // Key for a dictionary that maps user IDs to user image data with images |
71 // stored in JPEG format. | 72 // stored in JPEG format. |
72 static const char kUserImageProperties[]; | 73 static const char kUserImageProperties[]; |
73 // Names of user image properties. | 74 // Names of user image properties. |
74 static const char kImagePathNodeName[]; | 75 static const char kImagePathNodeName[]; |
75 static const char kImageIndexNodeName[]; | 76 static const char kImageIndexNodeName[]; |
76 static const char kImageURLNodeName[]; | 77 static const char kImageURLNodeName[]; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Only valid when a download is currently in progress and | 167 // Only valid when a download is currently in progress and |
167 // |downloading_profile_image_| is true. | 168 // |downloading_profile_image_| is true. |
168 std::string profile_image_download_reason_; | 169 std::string profile_image_download_reason_; |
169 | 170 |
170 // Time when the profile image download started. Only valid when a download is | 171 // Time when the profile image download started. Only valid when a download is |
171 // currently in progress and |downloading_profile_image_| is true. | 172 // currently in progress and |downloading_profile_image_| is true. |
172 base::TimeTicks profile_image_load_start_time_; | 173 base::TimeTicks profile_image_load_start_time_; |
173 | 174 |
174 // Downloader for the user's profile data. NULL when no download is | 175 // Downloader for the user's profile data. NULL when no download is |
175 // currently in progress. | 176 // currently in progress. |
176 scoped_ptr<ProfileDownloader> profile_downloader_; | 177 std::unique_ptr<ProfileDownloader> profile_downloader_; |
177 | 178 |
178 // The currently logged-in user's downloaded profile image, if successfully | 179 // The currently logged-in user's downloaded profile image, if successfully |
179 // downloaded or initialized from a previously downloaded and saved image. | 180 // downloaded or initialized from a previously downloaded and saved image. |
180 gfx::ImageSkia downloaded_profile_image_; | 181 gfx::ImageSkia downloaded_profile_image_; |
181 | 182 |
182 // Data URL corresponding to |downloaded_profile_image_|. Empty if no | 183 // Data URL corresponding to |downloaded_profile_image_|. Empty if no |
183 // |downloaded_profile_image_| is currently available. | 184 // |downloaded_profile_image_| is currently available. |
184 std::string downloaded_profile_image_data_url_; | 185 std::string downloaded_profile_image_data_url_; |
185 | 186 |
186 // URL from which |downloaded_profile_image_| was downloaded. Empty if no | 187 // URL from which |downloaded_profile_image_| was downloaded. Empty if no |
187 // |downloaded_profile_image_| is currently available. | 188 // |downloaded_profile_image_| is currently available. |
188 GURL profile_image_url_; | 189 GURL profile_image_url_; |
189 | 190 |
190 // Whether a download of the currently logged-in user's profile image has been | 191 // Whether a download of the currently logged-in user's profile image has been |
191 // explicitly requested by a call to DownloadProfileImage() and has not been | 192 // explicitly requested by a call to DownloadProfileImage() and has not been |
192 // satisfied by a successful download yet. | 193 // satisfied by a successful download yet. |
193 bool profile_image_requested_; | 194 bool profile_image_requested_; |
194 | 195 |
195 // Timer used to start a profile data download shortly after login and to | 196 // Timer used to start a profile data download shortly after login and to |
196 // restart the download after network errors. | 197 // restart the download after network errors. |
197 base::OneShotTimer profile_download_one_shot_timer_; | 198 base::OneShotTimer profile_download_one_shot_timer_; |
198 | 199 |
199 // Timer used to periodically start a profile data, ensuring the profile data | 200 // Timer used to periodically start a profile data, ensuring the profile data |
200 // stays up to date. | 201 // stays up to date. |
201 base::RepeatingTimer profile_download_periodic_timer_; | 202 base::RepeatingTimer profile_download_periodic_timer_; |
202 | 203 |
203 // Sync observer for the currently logged-in user. | 204 // Sync observer for the currently logged-in user. |
204 scoped_ptr<UserImageSyncObserver> user_image_sync_observer_; | 205 std::unique_ptr<UserImageSyncObserver> user_image_sync_observer_; |
205 | 206 |
206 // Background task runner on which Jobs perform file I/O and the image | 207 // Background task runner on which Jobs perform file I/O and the image |
207 // decoders run. | 208 // decoders run. |
208 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; | 209 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; |
209 | 210 |
210 // The currently running job. | 211 // The currently running job. |
211 scoped_ptr<Job> job_; | 212 std::unique_ptr<Job> job_; |
212 | 213 |
213 bool has_managed_image_; | 214 bool has_managed_image_; |
214 | 215 |
215 base::WeakPtrFactory<UserImageManagerImpl> weak_factory_; | 216 base::WeakPtrFactory<UserImageManagerImpl> weak_factory_; |
216 | 217 |
217 DISALLOW_COPY_AND_ASSIGN(UserImageManagerImpl); | 218 DISALLOW_COPY_AND_ASSIGN(UserImageManagerImpl); |
218 }; | 219 }; |
219 | 220 |
220 } // namespace chromeos | 221 } // namespace chromeos |
221 | 222 |
222 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ | 223 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ |
OLD | NEW |