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

Side by Side Diff: chrome/browser/chromeos/login/user_manager_impl.h

Issue 10832019: Speed up custom wallpaper switching time and wallpaper manager code refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // UserManager implementation: 45 // UserManager implementation:
46 virtual ~UserManagerImpl(); 46 virtual ~UserManagerImpl();
47 47
48 virtual const UserList& GetUsers() const OVERRIDE; 48 virtual const UserList& GetUsers() const OVERRIDE;
49 virtual void UserLoggedIn(const std::string& email, 49 virtual void UserLoggedIn(const std::string& email,
50 bool browser_restart) OVERRIDE; 50 bool browser_restart) OVERRIDE;
51 virtual void DemoUserLoggedIn() OVERRIDE; 51 virtual void DemoUserLoggedIn() OVERRIDE;
52 virtual void GuestUserLoggedIn() OVERRIDE; 52 virtual void GuestUserLoggedIn() OVERRIDE;
53 virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE; 53 virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE;
54 virtual void InitializeWallpaper() OVERRIDE; 54 virtual void InitializeWallpaper() OVERRIDE;
55 virtual void UserSelected(const std::string& email) OVERRIDE;
56 virtual void SessionStarted() OVERRIDE; 55 virtual void SessionStarted() OVERRIDE;
57 virtual void RemoveUser(const std::string& email, 56 virtual void RemoveUser(const std::string& email,
58 RemoveUserDelegate* delegate) OVERRIDE; 57 RemoveUserDelegate* delegate) OVERRIDE;
59 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; 58 virtual void RemoveUserFromList(const std::string& email) OVERRIDE;
60 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; 59 virtual bool IsKnownUser(const std::string& email) const OVERRIDE;
61 virtual const User* FindUser(const std::string& email) const OVERRIDE; 60 virtual const User* FindUser(const std::string& email) const OVERRIDE;
62 virtual const User& GetLoggedInUser() const OVERRIDE; 61 virtual const User& GetLoggedInUser() const OVERRIDE;
63 virtual User& GetLoggedInUser() OVERRIDE; 62 virtual User& GetLoggedInUser() OVERRIDE;
64 virtual void SaveUserOAuthStatus( 63 virtual void SaveUserOAuthStatus(
65 const std::string& username, 64 const std::string& username,
66 User::OAuthTokenStatus oauth_token_status) OVERRIDE; 65 User::OAuthTokenStatus oauth_token_status) OVERRIDE;
67 virtual void SaveUserDisplayName(const std::string& username, 66 virtual void SaveUserDisplayName(const std::string& username,
68 const string16& display_name) OVERRIDE; 67 const string16& display_name) OVERRIDE;
69 virtual string16 GetUserDisplayName( 68 virtual string16 GetUserDisplayName(
70 const std::string& username) const OVERRIDE; 69 const std::string& username) const OVERRIDE;
71 virtual void SaveUserDisplayEmail(const std::string& username, 70 virtual void SaveUserDisplayEmail(const std::string& username,
72 const std::string& display_email) OVERRIDE; 71 const std::string& display_email) OVERRIDE;
73 virtual std::string GetUserDisplayEmail( 72 virtual std::string GetUserDisplayEmail(
74 const std::string& username) const OVERRIDE; 73 const std::string& username) const OVERRIDE;
75 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type,
76 int* index,
77 base::Time* last_modification_date) OVERRIDE;
78 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, 74 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type,
79 int index) OVERRIDE; 75 int index) OVERRIDE;
80 virtual void SaveUserDefaultImageIndex(const std::string& username, 76 virtual void SaveUserDefaultImageIndex(const std::string& username,
81 int image_index) OVERRIDE; 77 int image_index) OVERRIDE;
82 virtual void SaveUserImage(const std::string& username, 78 virtual void SaveUserImage(const std::string& username,
83 const UserImage& user_image) OVERRIDE; 79 const UserImage& user_image) OVERRIDE;
84 virtual void SetLoggedInUserCustomWallpaperLayout( 80 virtual void SetLoggedInUserCustomWallpaperLayout(
85 ash::WallpaperLayout layout) OVERRIDE; 81 ash::WallpaperLayout layout) OVERRIDE;
86 virtual void SaveUserImageFromFile(const std::string& username, 82 virtual void SaveUserImageFromFile(const std::string& username,
87 const FilePath& path) OVERRIDE; 83 const FilePath& path) OVERRIDE;
88 virtual void SaveUserWallpaperFromFile(
89 const std::string& username,
90 const FilePath& path,
91 ash::WallpaperLayout layout,
92 base::WeakPtr<WallpaperDelegate> delegate) OVERRIDE;
93 virtual void SaveUserImageFromProfileImage( 84 virtual void SaveUserImageFromProfileImage(
94 const std::string& username) OVERRIDE; 85 const std::string& username) OVERRIDE;
95 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; 86 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE;
96 virtual bool IsCurrentUserOwner() const OVERRIDE; 87 virtual bool IsCurrentUserOwner() const OVERRIDE;
97 virtual bool IsCurrentUserNew() const OVERRIDE; 88 virtual bool IsCurrentUserNew() const OVERRIDE;
98 virtual bool IsCurrentUserEphemeral() const OVERRIDE; 89 virtual bool IsCurrentUserEphemeral() const OVERRIDE;
99 virtual bool IsUserLoggedIn() const OVERRIDE; 90 virtual bool IsUserLoggedIn() const OVERRIDE;
100 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; 91 virtual bool IsLoggedInAsDemoUser() const OVERRIDE;
101 virtual bool IsLoggedInAsGuest() const OVERRIDE; 92 virtual bool IsLoggedInAsGuest() const OVERRIDE;
102 virtual bool IsLoggedInAsStub() const OVERRIDE; 93 virtual bool IsLoggedInAsStub() const OVERRIDE;
(...skipping 23 matching lines...) Expand all
126 117
127 private: 118 private:
128 friend class UserManagerImplWrapper; 119 friend class UserManagerImplWrapper;
129 friend class UserManagerTest; 120 friend class UserManagerTest;
130 friend class WallpaperManager; 121 friend class WallpaperManager;
131 122
132 // Loads |users_| from Local State if the list has not been loaded yet. 123 // Loads |users_| from Local State if the list has not been loaded yet.
133 // Subsequent calls have no effect. Must be called on the UI thread. 124 // Subsequent calls have no effect. Must be called on the UI thread.
134 void EnsureUsersLoaded(); 125 void EnsureUsersLoaded();
135 126
136 // Loads wallpaper asynchronously if the current wallpaper is not the
137 // wallpaper of logged in user.
138 void EnsureLoggedInUserWallpaperLoaded();
139
140 // Retrieves trusted device policies and removes users from the persistent 127 // Retrieves trusted device policies and removes users from the persistent
141 // list if ephemeral users are enabled. Schedules a callback to itself if 128 // list if ephemeral users are enabled. Schedules a callback to itself if
142 // trusted device policies are not yet available. 129 // trusted device policies are not yet available.
143 void RetrieveTrustedDevicePolicies(); 130 void RetrieveTrustedDevicePolicies();
144 131
145 // Returns true if trusted device policies have successfully been retrieved 132 // Returns true if trusted device policies have successfully been retrieved
146 // and ephemeral users are enabled. 133 // and ephemeral users are enabled.
147 bool AreEphemeralUsersEnabled() const; 134 bool AreEphemeralUsersEnabled() const;
148 135
149 // Returns true if the user with the given email address is to be treated as 136 // Returns true if the user with the given email address is to be treated as
(...skipping 10 matching lines...) Expand all
160 // Reads user's oauth token status from local state preferences. 147 // Reads user's oauth token status from local state preferences.
161 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; 148 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const;
162 149
163 void SetCurrentUserIsOwner(bool is_current_user_owner); 150 void SetCurrentUserIsOwner(bool is_current_user_owner);
164 151
165 // Sets one of the default images for the specified user and saves this 152 // Sets one of the default images for the specified user and saves this
166 // setting in local state. 153 // setting in local state.
167 // Does not send LOGIN_USER_IMAGE_CHANGED notification. 154 // Does not send LOGIN_USER_IMAGE_CHANGED notification.
168 void SetInitialUserImage(const std::string& username); 155 void SetInitialUserImage(const std::string& username);
169 156
170 // Sets one of the default wallpapers for the specified user and saves this
171 // settings in local state.
172 void SetInitialUserWallpaper(const std::string& username);
173
174 // Migrate the old wallpaper index to a new wallpaper structure. 157 // Migrate the old wallpaper index to a new wallpaper structure.
175 // The new wallpaper structure is: 158 // The new wallpaper structure is:
176 // { WallpaperType: DAILY|CUSTOMIZED|DEFAULT, 159 // { WallpaperType: DAILY|CUSTOMIZED|DEFAULT,
177 // index: index of the default wallpapers } 160 // index: index of the default wallpapers }
178 void MigrateWallpaperData(); 161 void MigrateWallpaperData();
179 162
180 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED 163 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED
181 // notification unless this is a new user and image is set for the first time. 164 // notification unless this is a new user and image is set for the first time.
182 // If |image| is empty, sets a stub image for the user. 165 // If |image| is empty, sets a stub image for the user.
183 void SetUserImage(const std::string& username, 166 void SetUserImage(const std::string& username,
184 int image_index, 167 int image_index,
185 const GURL& image_url, 168 const GURL& image_url,
186 const UserImage& user_image); 169 const UserImage& user_image);
187 170
188 // Get wallpaper |type|, |index| and |last_modification_date| of |username|
189 // from local state.
190 void GetUserWallpaperProperties(const std::string& username,
191 User::WallpaperType* type,
192 int* index,
193 base::Time* last_modification_date);
194
195 // Set |username|'s wallpaper |type|, |index| and local date to local state.
196 void SaveUserWallpaperProperties(const std::string& username,
197 User::WallpaperType type,
198 int index);
199
200 // Saves image to file, updates local state preferences to given image index 171 // Saves image to file, updates local state preferences to given image index
201 // and sends LOGIN_USER_IMAGE_CHANGED notification. 172 // and sends LOGIN_USER_IMAGE_CHANGED notification.
202 void SaveUserImageInternal(const std::string& username, 173 void SaveUserImageInternal(const std::string& username,
203 int image_index, 174 int image_index,
204 const GURL& image_url, 175 const GURL& image_url,
205 const UserImage& user_image); 176 const UserImage& user_image);
206 177
207 // Saves wallpaper to file, post task to generate thumbnail and updates local
208 // state preferences.
209 void SaveUserWallpaperInternal(const std::string& username,
210 ash::WallpaperLayout layout,
211 User::WallpaperType type,
212 base::WeakPtr<WallpaperDelegate> delegate,
213 const UserImage& user_image);
214
215 // Sets desktop background to custom wallpaper and loads wallpaper thumbnail
216 // asynchronously.
217 void OnCustomWallpaperLoaded(const std::string& email,
218 ash::WallpaperLayout layout,
219 const UserImage& wallpaper);
220
221 // Caches the loaded wallpaper for the given user.
222 void OnCustomWallpaperThumbnailLoaded(const std::string& email,
223 const UserImage& user_image);
224
225 // Updates the custom wallpaper thumbnail in wallpaper picker UI.
226 void OnThumbnailUpdated(base::WeakPtr<WallpaperDelegate> delegate);
227
228 // Generates a 128x80 thumbnail and saves it to local file system.
229 void GenerateUserWallpaperThumbnail(const std::string& username,
230 User::WallpaperType type,
231 base::WeakPtr<WallpaperDelegate> delegate,
232 const SkBitmap& wallpaper);
233
234 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED 178 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED
235 // notification. Runs on FILE thread. Posts task for saving image info to 179 // notification. Runs on FILE thread. Posts task for saving image info to
236 // Local State on UI thread. 180 // Local State on UI thread.
237 void SaveImageToFile(const std::string& username, 181 void SaveImageToFile(const std::string& username,
238 const UserImage& user_image, 182 const UserImage& user_image,
239 const FilePath& image_path, 183 const FilePath& image_path,
240 int image_index, 184 int image_index,
241 const GURL& image_url); 185 const GURL& image_url);
242 186
243 // Saves wallpaper to file with specified path. Runs on FILE thread. Posts
244 // task for saving wallpaper info to Local State on UI thread.
245 void SaveWallpaperToFile(const std::string& username,
246 const SkBitmap& wallpaper,
247 const FilePath& wallpaper_path,
248 ash::WallpaperLayout layout,
249 User::WallpaperType type);
250
251 // Stores path to the image and its index in local state. Runs on UI thread. 187 // Stores path to the image and its index in local state. Runs on UI thread.
252 // If |is_async| is true, it has been posted from the FILE thread after 188 // If |is_async| is true, it has been posted from the FILE thread after
253 // saving the image. 189 // saving the image.
254 void SaveImageToLocalState(const std::string& username, 190 void SaveImageToLocalState(const std::string& username,
255 const std::string& image_path, 191 const std::string& image_path,
256 int image_index, 192 int image_index,
257 const GURL& image_url, 193 const GURL& image_url,
258 bool is_async); 194 bool is_async);
259 195
260 // Stores layout and type preference in local state. Runs on UI thread. 196 // Stores layout and type preference in local state. Runs on UI thread.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Cached flag of whether the currently logged-in user existed before this 263 // Cached flag of whether the currently logged-in user existed before this
328 // login. 264 // login.
329 bool is_current_user_new_; 265 bool is_current_user_new_;
330 266
331 // Cached flag of whether the currently logged-in user is ephemeral. Storage 267 // Cached flag of whether the currently logged-in user is ephemeral. Storage
332 // of persistent information is avoided for such users by not adding them to 268 // of persistent information is avoided for such users by not adding them to
333 // the user list in local state, not downloading their custom user images and 269 // the user list in local state, not downloading their custom user images and
334 // mounting their cryptohomes using tmpfs. 270 // mounting their cryptohomes using tmpfs.
335 bool is_current_user_ephemeral_; 271 bool is_current_user_ephemeral_;
336 272
337 User::WallpaperType current_user_wallpaper_type_;
338
339 int current_user_wallpaper_index_;
340
341 // Cached flag indicating whether ephemeral users are enabled. Defaults to 273 // Cached flag indicating whether ephemeral users are enabled. Defaults to
342 // |false| if the value has not been read from trusted device policy yet. 274 // |false| if the value has not been read from trusted device policy yet.
343 bool ephemeral_users_enabled_; 275 bool ephemeral_users_enabled_;
344 276
345 // True if user pod row is showed at login screen. 277 // True if user pod row is showed at login screen.
346 bool show_users_; 278 bool show_users_;
347 279
348 // Cached name of device owner. Defaults to empty string if the value has not 280 // Cached name of device owner. Defaults to empty string if the value has not
349 // been read from trusted device policy yet. 281 // been read from trusted device policy yet.
350 std::string owner_email_; 282 std::string owner_email_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 319
388 // Timer triggering DownloadProfileDataScheduled for refreshing profile data. 320 // Timer triggering DownloadProfileDataScheduled for refreshing profile data.
389 base::RepeatingTimer<UserManagerImpl> profile_download_timer_; 321 base::RepeatingTimer<UserManagerImpl> profile_download_timer_;
390 322
391 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); 323 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl);
392 }; 324 };
393 325
394 } // namespace chromeos 326 } // namespace chromeos
395 327
396 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ 328 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698