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

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

Issue 138913011: Code refactor(rename email to user_id in wallpaper_manager.h/cc) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_WALLPAPER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 private: 91 private:
92 WallpaperManager* wallpaper_manager_; // not owned 92 WallpaperManager* wallpaper_manager_; // not owned
93 93
94 DISALLOW_COPY_AND_ASSIGN(TestApi); 94 DISALLOW_COPY_AND_ASSIGN(TestApi);
95 }; 95 };
96 96
97 class Observer { 97 class Observer {
98 public: 98 public:
99 virtual ~Observer() {} 99 virtual ~Observer() {}
100 virtual void OnWallpaperAnimationFinished(const std::string& email) = 0; 100 virtual void OnWallpaperAnimationFinished(const std::string& user_id) = 0;
101 }; 101 };
102 102
103 // This is "wallpaper either scheduled to load, or loading right now". 103 // This is "wallpaper either scheduled to load, or loading right now".
104 // 104 //
105 // While enqueued, it defines moment in the future, when it will be loaded. 105 // While enqueued, it defines moment in the future, when it will be loaded.
106 // Enqueued but not started request might be updated by subsequent load 106 // Enqueued but not started request might be updated by subsequent load
107 // request. Therefore it's created empty, and updated being enqueued. 107 // request. Therefore it's created empty, and updated being enqueued.
108 // 108 //
109 // PendingWallpaper is owned by WallpaperManager, but reference to this object 109 // PendingWallpaper is owned by WallpaperManager, but reference to this object
110 // is passed to other threads by PoskTask() calls, therefore it is 110 // is passed to other threads by PoskTask() calls, therefore it is
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged 207 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged
208 // in, uses a solid color wallpaper. If logged in as a stub user, uses an 208 // in, uses a solid color wallpaper. If logged in as a stub user, uses an
209 // empty wallpaper. 209 // empty wallpaper.
210 void InitializeWallpaper(); 210 void InitializeWallpaper();
211 211
212 // NotificationObserver overrides: 212 // NotificationObserver overrides:
213 virtual void Observe(int type, 213 virtual void Observe(int type,
214 const content::NotificationSource& source, 214 const content::NotificationSource& source,
215 const content::NotificationDetails& details) OVERRIDE; 215 const content::NotificationDetails& details) OVERRIDE;
216 216
217 // Removes all |email| related wallpaper info and saved wallpapers. 217 // Removes all |user_id| related wallpaper info and saved wallpapers.
218 void RemoveUserWallpaperInfo(const std::string& email); 218 void RemoveUserWallpaperInfo(const std::string& user_id);
219 219
220 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width| 220 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width|
221 // and |preferred_height| while maintaining aspect ratio. 221 // and |preferred_height| while maintaining aspect ratio.
222 bool ResizeWallpaper(const UserImage& wallpaper, 222 bool ResizeWallpaper(const UserImage& wallpaper,
223 ash::WallpaperLayout layout, 223 ash::WallpaperLayout layout,
224 int preferred_width, 224 int preferred_width,
225 int preferred_height, 225 int preferred_height,
226 scoped_refptr<base::RefCountedBytes>* output); 226 scoped_refptr<base::RefCountedBytes>* output);
227 227
228 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width| 228 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width|
(...skipping 27 matching lines...) Expand all
256 256
257 // Sets selected wallpaper information for |user_id| and saves it to Local 257 // Sets selected wallpaper information for |user_id| and saves it to Local
258 // State if |is_persistent| is true. 258 // State if |is_persistent| is true.
259 void SetUserWallpaperInfo(const std::string& user_id, 259 void SetUserWallpaperInfo(const std::string& user_id,
260 const WallpaperInfo& info, 260 const WallpaperInfo& info,
261 bool is_persistent); 261 bool is_persistent);
262 262
263 // Sets last selected user on user pod row. 263 // Sets last selected user on user pod row.
264 void SetLastSelectedUser(const std::string& last_selected_user); 264 void SetLastSelectedUser(const std::string& last_selected_user);
265 265
266 // Sets |email|'s wallpaper (asynchronously with zero delay). 266 // Sets |user_id|'s wallpaper (asynchronously with zero delay).
267 void SetUserWallpaperNow(const std::string& email); 267 void SetUserWallpaperNow(const std::string& user_id);
268 268
269 // Sets |email|'s wallpaper (asynchronously with default delay). 269 // Sets |user_id|'s wallpaper (asynchronously with default delay).
270 void SetUserWallpaperDelayed(const std::string& email); 270 void SetUserWallpaperDelayed(const std::string& user_id);
271 271
272 // Sets wallpaper to |wallpaper| (asynchronously with zero delay). 272 // Sets wallpaper to |wallpaper| (asynchronously with zero delay).
273 void SetWallpaperFromImageSkia(const std::string& email, 273 void SetWallpaperFromImageSkia(const std::string& user_id,
274 const gfx::ImageSkia& wallpaper, 274 const gfx::ImageSkia& wallpaper,
275 ash::WallpaperLayout layout); 275 ash::WallpaperLayout layout);
276 276
277 // Updates current wallpaper. It may switch the size of wallpaper based on the 277 // Updates current wallpaper. It may switch the size of wallpaper based on the
278 // current display's resolution. (asynchronously with zero delay) 278 // current display's resolution. (asynchronously with zero delay)
279 void UpdateWallpaper(); 279 void UpdateWallpaper();
280 280
281 // Adds given observer to the list. 281 // Adds given observer to the list.
282 void AddObserver(Observer* observer); 282 void AddObserver(Observer* observer);
283 283
284 // Removes given observer from the list. 284 // Removes given observer from the list.
285 void RemoveObserver(Observer* observer); 285 void RemoveObserver(Observer* observer);
286 286
287 private: 287 private:
288 friend class TestApi; 288 friend class TestApi;
289 friend class WallpaperManagerBrowserTest; 289 friend class WallpaperManagerBrowserTest;
290 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; 290 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap;
291 291
292 // Gets encoded wallpaper from cache. Returns true if success. 292 // Gets encoded wallpaper from cache. Returns true if success.
293 bool GetWallpaperFromCache(const std::string& email, 293 bool GetWallpaperFromCache(const std::string& user_id,
294 gfx::ImageSkia* wallpaper); 294 gfx::ImageSkia* wallpaper);
295 295
296 296
297 // The number of wallpapers have loaded. For test only. 297 // The number of wallpapers have loaded. For test only.
298 int loaded_wallpapers() const { return loaded_wallpapers_; } 298 int loaded_wallpapers() const { return loaded_wallpapers_; }
299 299
300 // Cache some (or all) logged in users' wallpapers to memory at login 300 // Cache some (or all) logged in users' wallpapers to memory at login
301 // screen. It should not compete with first wallpaper loading when boot 301 // screen. It should not compete with first wallpaper loading when boot
302 // up/initialize login WebUI page. 302 // up/initialize login WebUI page.
303 // There are two ways the first wallpaper might be loaded: 303 // There are two ways the first wallpaper might be loaded:
304 // 1. Loaded on boot. Login WebUI waits for it. 304 // 1. Loaded on boot. Login WebUI waits for it.
305 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded 305 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded
306 // right away and in 500ms after. Wallpaper started to load. 306 // right away and in 500ms after. Wallpaper started to load.
307 // For case 2, should_cache_wallpaper_ is used to indicate if we need to 307 // For case 2, should_cache_wallpaper_ is used to indicate if we need to
308 // cache wallpapers on wallpaper animation finished. The cache operation 308 // cache wallpapers on wallpaper animation finished. The cache operation
309 // should be only executed once. 309 // should be only executed once.
310 void CacheUsersWallpapers(); 310 void CacheUsersWallpapers();
311 311
312 // Caches |email|'s wallpaper to memory. 312 // Caches |user_id|'s wallpaper to memory.
313 void CacheUserWallpaper(const std::string& email); 313 void CacheUserWallpaper(const std::string& user_id);
314 314
315 // Clears all obsolete wallpaper prefs from old version wallpaper pickers. 315 // Clears all obsolete wallpaper prefs from old version wallpaper pickers.
316 void ClearObsoleteWallpaperPrefs(); 316 void ClearObsoleteWallpaperPrefs();
317 317
318 // Deletes everything else except |path| in the same directory. 318 // Deletes everything else except |path| in the same directory.
319 void DeleteAllExcept(const base::FilePath& path); 319 void DeleteAllExcept(const base::FilePath& path);
320 320
321 // Deletes a list of wallpaper files in |file_list|. 321 // Deletes a list of wallpaper files in |file_list|.
322 void DeleteWallpaperInList(const std::vector<base::FilePath>& file_list); 322 void DeleteWallpaperInList(const std::vector<base::FilePath>& file_list);
323 323
324 // Deletes all |email| related custom wallpapers and directories. 324 // Deletes all |user_id| related custom wallpapers and directories.
325 void DeleteUserWallpapers(const std::string& email, 325 void DeleteUserWallpapers(const std::string& user_id,
326 const std::string& path_to_file); 326 const std::string& path_to_file);
327 327
328 // Creates all new custom wallpaper directories for |user_id_hash| if not 328 // Creates all new custom wallpaper directories for |user_id_hash| if not
329 // exist. 329 // exist.
330 void EnsureCustomWallpaperDirectories(const std::string& user_id_hash); 330 void EnsureCustomWallpaperDirectories(const std::string& user_id_hash);
331 331
332 // Gets the CommandLine representing the current process's command line. 332 // Gets the CommandLine representing the current process's command line.
333 CommandLine* GetComandLine(); 333 CommandLine* GetComandLine();
334 334
335 // Initialize wallpaper of registered device after device policy is trusted. 335 // Initialize wallpaper of registered device after device policy is trusted.
336 // Note that before device is enrolled, it proceeds with untrusted setting. 336 // Note that before device is enrolled, it proceeds with untrusted setting.
337 void InitializeRegisteredDeviceWallpaper(); 337 void InitializeRegisteredDeviceWallpaper();
338 338
339 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper 339 // Loads |user_id|'s wallpaper. When |update_wallpaper| is true, sets
340 // to the loaded wallpaper. 340 // wallpaper to the loaded wallpaper.
341 void LoadWallpaper(const std::string& email, 341 void LoadWallpaper(const std::string& user_id,
342 const WallpaperInfo& info, 342 const WallpaperInfo& info,
343 bool update_wallpaper, 343 bool update_wallpaper,
344 MovableOnDestroyCallbackHolder on_finish); 344 MovableOnDestroyCallbackHolder on_finish);
345 345
346 // Moves custom wallpapers from |email| directory to |user_id_hash| 346 // Moves custom wallpapers from |user_id| directory to |user_id_hash|
347 // directory. 347 // directory.
348 void MoveCustomWallpapersOnWorker(const std::string& email, 348 void MoveCustomWallpapersOnWorker(const std::string& user_id,
349 const std::string& user_id_hash); 349 const std::string& user_id_hash);
350 350
351 // Called when the original custom wallpaper is moved to the new place. 351 // Called when the original custom wallpaper is moved to the new place.
352 // Updates the corresponding user wallpaper info. 352 // Updates the corresponding user wallpaper info.
353 void MoveCustomWallpapersSuccess(const std::string& email, 353 void MoveCustomWallpapersSuccess(const std::string& user_id,
354 const std::string& user_id_hash); 354 const std::string& user_id_hash);
355 355
356 // Moves custom wallpaper to a new place. Email address was used as directory 356 // Moves custom wallpaper to a new place. Email address was used as directory
357 // name in the old system, this is not safe. New directory system uses 357 // name in the old system, this is not safe. New directory system uses
358 // user_id_hash instead of email. This must be called after user_id_hash is 358 // user_id_hash instead of user_id. This must be called after user_id_hash is
359 // ready. 359 // ready.
360 void MoveLoggedInUserCustomWallpaper(); 360 void MoveLoggedInUserCustomWallpaper();
361 361
362 // Gets |email|'s custom wallpaper at |wallpaper_path|. Falls back on original 362 // Gets |user_id|'s custom wallpaper at |wallpaper_path|. Falls back on
363 // custom wallpaper. When |update_wallpaper| is true, sets wallpaper to the 363 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper
364 // loaded wallpaper. Must run on wallpaper sequenced worker thread. 364 // to the loaded wallpaper. Must run on wallpaper sequenced worker thread.
365 void GetCustomWallpaperInternal(const std::string& email, 365 void GetCustomWallpaperInternal(const std::string& user_id,
366 const WallpaperInfo& info, 366 const WallpaperInfo& info,
367 const base::FilePath& wallpaper_path, 367 const base::FilePath& wallpaper_path,
368 bool update_wallpaper, 368 bool update_wallpaper,
369 MovableOnDestroyCallbackHolder on_finish); 369 MovableOnDestroyCallbackHolder on_finish);
370 370
371 // Gets wallpaper information of |email| from Local State or memory. Returns 371 // Gets wallpaper information of |user_id| from Local State or memory. Returns
372 // false if wallpaper information is not found. 372 // false if wallpaper information is not found.
373 bool GetUserWallpaperInfo(const std::string& email, WallpaperInfo* info); 373 bool GetUserWallpaperInfo(const std::string& user_id, WallpaperInfo* info);
374 374
375 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. 375 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true.
376 // Otherwise, cache wallpaper to memory if not logged in. 376 // Otherwise, cache wallpaper to memory if not logged in.
377 void OnWallpaperDecoded(const std::string& email, 377 void OnWallpaperDecoded(const std::string& user_id,
378 ash::WallpaperLayout layout, 378 ash::WallpaperLayout layout,
379 bool update_wallpaper, 379 bool update_wallpaper,
380 MovableOnDestroyCallbackHolder on_finish, 380 MovableOnDestroyCallbackHolder on_finish,
381 const UserImage& wallpaper); 381 const UserImage& wallpaper);
382 382
383 // Generates thumbnail of custom wallpaper on wallpaper sequenced worker 383 // Generates thumbnail of custom wallpaper on wallpaper sequenced worker
384 // thread. If |persistent| is true, saves original custom image and resized 384 // thread. If |persistent| is true, saves original custom image and resized
385 // images to disk. 385 // images to disk.
386 void ProcessCustomWallpaper(const std::string& user_id_hash, 386 void ProcessCustomWallpaper(const std::string& user_id_hash,
387 bool persistent, 387 bool persistent,
388 const WallpaperInfo& info, 388 const WallpaperInfo& info,
389 scoped_ptr<gfx::ImageSkia> image, 389 scoped_ptr<gfx::ImageSkia> image,
390 const UserImage::RawImage& raw_image); 390 const UserImage::RawImage& raw_image);
391 391
392 // Record data for User Metrics Analysis. 392 // Record data for User Metrics Analysis.
393 void RecordUma(User::WallpaperType type, int index); 393 void RecordUma(User::WallpaperType type, int index);
394 394
395 // Saves original custom wallpaper to |path| (absolute path) on filesystem 395 // Saves original custom wallpaper to |path| (absolute path) on filesystem
396 // and starts resizing operation of the custom wallpaper if necessary. 396 // and starts resizing operation of the custom wallpaper if necessary.
397 void SaveCustomWallpaper(const std::string& user_id_hash, 397 void SaveCustomWallpaper(const std::string& user_id_hash,
398 const base::FilePath& path, 398 const base::FilePath& path,
399 ash::WallpaperLayout layout, 399 ash::WallpaperLayout layout,
400 const UserImage& wallpaper); 400 const UserImage& wallpaper);
401 401
402 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. 402 // Saves wallpaper image raw |data| to |path| (absolute path) in file system.
403 void SaveWallpaperInternal(const base::FilePath& path, const char* data, 403 void SaveWallpaperInternal(const base::FilePath& path, const char* data,
404 int size); 404 int size);
405 405
406 // Creates new PendingWallpaper request (or updates currently pending). 406 // Creates new PendingWallpaper request (or updates currently pending).
407 void ScheduleSetUserWallpaper(const std::string& email, bool delayed); 407 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed);
408 408
409 // Sets wallpaper to default. 409 // Sets wallpaper to default.
410 void DoSetDefaultWallpaper( 410 void DoSetDefaultWallpaper(
411 const std::string& user_id, 411 const std::string& user_id,
412 MovableOnDestroyCallbackHolder on_finish); 412 MovableOnDestroyCallbackHolder on_finish);
413 413
414 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the 414 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the
415 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. 415 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread.
416 void StartLoad(const std::string& email, 416 void StartLoad(const std::string& user_id,
417 const WallpaperInfo& info, 417 const WallpaperInfo& info,
418 bool update_wallpaper, 418 bool update_wallpaper,
419 const base::FilePath& wallpaper_path, 419 const base::FilePath& wallpaper_path,
420 MovableOnDestroyCallbackHolder on_finish); 420 MovableOnDestroyCallbackHolder on_finish);
421 421
422 // After completed load operation, update average load time. 422 // After completed load operation, update average load time.
423 void SaveLastLoadTime(const base::TimeDelta elapsed); 423 void SaveLastLoadTime(const base::TimeDelta elapsed);
424 424
425 // Notify all registed observers. 425 // Notify all registed observers.
426 void NotifyAnimationFinished(); 426 void NotifyAnimationFinished();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // All pending will be finally deleted on destroy. 492 // All pending will be finally deleted on destroy.
493 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; 493 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList;
494 PendingList loading_; 494 PendingList loading_;
495 495
496 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 496 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
497 }; 497 };
498 498
499 } // namespace chromeos 499 } // namespace chromeos
500 500
501 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 501 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/wallpaper_manager.cc » ('j') | chrome/browser/chromeos/login/wallpaper_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698