Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / wallpaper_manager.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
7
8 #include <deque>
9 #include <string>
10 #include <vector>
11
12 #include "ash/desktop_background/desktop_background_controller.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h"
18 #include "base/threading/sequenced_worker_pool.h"
19 #include "base/time/time.h"
20 #include "chrome/browser/chromeos/login/user.h"
21 #include "chrome/browser/chromeos/login/user_image.h"
22 #include "chrome/browser/chromeos/login/user_image_loader.h"
23 #include "chrome/browser/chromeos/settings/cros_settings.h"
24 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h"
26 #include "third_party/icu/source/i18n/unicode/timezone.h"
27 #include "ui/gfx/image/image_skia.h"
28
29 class PrefRegistrySimple;
30
31 namespace base {
32 class CommandLine;
33 class SequencedTaskRunner;
34 }
35
36 namespace chromeos {
37
38 struct WallpaperInfo {
39   // Online wallpaper URL or file name of migrated wallpaper.
40   std::string file;
41   ash::WallpaperLayout layout;
42   User::WallpaperType type;
43   base::Time date;
44   bool operator==(const WallpaperInfo& other) {
45     return (file == other.file) && (layout == other.layout) &&
46         (type == other.type);
47   }
48 };
49
50 class MovableOnDestroyCallback;
51 typedef scoped_ptr<MovableOnDestroyCallback> MovableOnDestroyCallbackHolder;
52
53 class WallpaperManagerBrowserTest;
54 class UserImage;
55
56 // Name of wallpaper sequence token.
57 extern const char kWallpaperSequenceTokenName[];
58
59 // File path suffices of resized small or large wallpaper.
60 // TODO(bshe): Use the same sub folder system as custom wallpapers use.
61 // crbug.com/174928
62 extern const char kSmallWallpaperSuffix[];
63 extern const char kLargeWallpaperSuffix[];
64
65 // Directory names of custom wallpapers.
66 extern const char kSmallWallpaperSubDir[];
67 extern const char kLargeWallpaperSubDir[];
68 extern const char kOriginalWallpaperSubDir[];
69 extern const char kThumbnailWallpaperSubDir[];
70
71 // The width and height of small/large resolution wallpaper. When screen size is
72 // smaller than |kSmallWallpaperMaxWidth| and |kSmallWallpaperMaxHeight|, the
73 // small resolution wallpaper should be used. Otherwise, use the large
74 // resolution wallpaper.
75 extern const int kSmallWallpaperMaxWidth;
76 extern const int kSmallWallpaperMaxHeight;
77 extern const int kLargeWallpaperMaxWidth;
78 extern const int kLargeWallpaperMaxHeight;
79
80 // The width and height of wallpaper thumbnails.
81 extern const int kWallpaperThumbnailWidth;
82 extern const int kWallpaperThumbnailHeight;
83
84 // This singleton class maintains wallpapers for users who have logged into this
85 // Chrome OS device.
86 class WallpaperManager: public content::NotificationObserver {
87  public:
88   enum WallpaperResolution {
89     WALLPAPER_RESOLUTION_LARGE,
90     WALLPAPER_RESOLUTION_SMALL
91   };
92
93   // For testing.
94   class TestApi {
95    public:
96     explicit TestApi(WallpaperManager* wallpaper_manager);
97     virtual ~TestApi();
98
99     base::FilePath current_wallpaper_path();
100
101     bool GetWallpaperFromCache(const std::string& user_id,
102                                gfx::ImageSkia* image);
103
104     void SetWallpaperCache(const std::string& user_id,
105                            const gfx::ImageSkia& image);
106
107     void ClearDisposableWallpaperCache();
108
109    private:
110     WallpaperManager* wallpaper_manager_;  // not owned
111
112     DISALLOW_COPY_AND_ASSIGN(TestApi);
113   };
114
115   // This should be public to allow access from functions in anonymous
116   // namespace.
117   class CustomizedWallpaperRescaledFiles;
118
119   class Observer {
120    public:
121     virtual ~Observer() {}
122     virtual void OnWallpaperAnimationFinished(const std::string& user_id) = 0;
123     virtual void OnUpdateWallpaperForTesting() {}
124   };
125
126   // This is "wallpaper either scheduled to load, or loading right now".
127   //
128   // While enqueued, it defines moment in the future, when it will be loaded.
129   // Enqueued but not started request might be updated by subsequent load
130   // request. Therefore it's created empty, and updated being enqueued.
131   //
132   // PendingWallpaper is owned by WallpaperManager, but reference to this object
133   // is passed to other threads by PostTask() calls, therefore it is
134   // RefCountedThreadSafe.
135   class PendingWallpaper : public base::RefCountedThreadSafe<PendingWallpaper> {
136    public:
137     // Do LoadWallpaper() - image not found in cache.
138     PendingWallpaper(const base::TimeDelta delay, const std::string& user_id);
139
140     // There are 4 cases in SetUserWallpaper:
141     // 1) gfx::ImageSkia is found in cache.
142     //    - Schedule task to (probably) resize it and install:
143     //    call ash::Shell::GetInstance()->desktop_background_controller()->
144     //          SetCustomWallpaper(user_wallpaper, layout);
145     // 2) WallpaperInfo is found in cache
146     //    - need to LoadWallpaper(), resize and install.
147     // 3) wallpaper path is not NULL, load image URL, then resize, etc...
148     // 4) SetDefaultWallpaper (either on some error, or when user is new).
149     void ResetSetWallpaperImage(const gfx::ImageSkia& image,
150                                 const WallpaperInfo& info);
151     void ResetLoadWallpaper(const WallpaperInfo& info);
152     void ResetSetCustomWallpaper(const WallpaperInfo& info,
153                                  const base::FilePath& wallpaper_path);
154     void ResetSetDefaultWallpaper();
155
156    private:
157     friend class base::RefCountedThreadSafe<PendingWallpaper>;
158
159     ~PendingWallpaper();
160
161     // All Reset*() methods use SetMode() to set object to new state.
162     void SetMode(const gfx::ImageSkia& image,
163                  const WallpaperInfo& info,
164                  const base::FilePath& wallpaper_path,
165                  const bool is_default);
166
167     // This method is usually triggered by timer to actually load request.
168     void ProcessRequest();
169
170     // This method is called by callback, when load request is finished.
171     void OnWallpaperSet();
172
173     std::string user_id_;
174     WallpaperInfo info_;
175     gfx::ImageSkia user_wallpaper_;
176     base::FilePath wallpaper_path_;
177
178     // Load default wallpaper instead of user image.
179     bool default_;
180
181     // This is "on destroy" callback that will call OnWallpaperSet() when
182     // image will be loaded.
183     MovableOnDestroyCallbackHolder on_finish_;
184     base::OneShotTimer<WallpaperManager::PendingWallpaper> timer;
185
186     // Load start time to calculate duration.
187     base::Time started_load_at_;
188
189     DISALLOW_COPY_AND_ASSIGN(PendingWallpaper);
190   };
191
192   WallpaperManager();
193   virtual ~WallpaperManager();
194
195   // Get pointer to singleton WallpaperManager instance, create it if necessary.
196   static WallpaperManager* Get();
197
198   // Registers wallpaper manager preferences.
199   static void RegisterPrefs(PrefRegistrySimple* registry);
200
201   // Resizes |image| to a resolution which is nearest to |preferred_width| and
202   // |preferred_height| while respecting the |layout| choice. |output_skia| is
203   // optional (may be NULL). Returns true on success.
204   static bool ResizeImage(const gfx::ImageSkia& image,
205                           ash::WallpaperLayout layout,
206                           int preferred_width,
207                           int preferred_height,
208                           scoped_refptr<base::RefCountedBytes>* output,
209                           gfx::ImageSkia* output_skia);
210
211   // Resizes |image| to a resolution which is nearest to |preferred_width| and
212   // |preferred_height| while respecting the |layout| choice and saves the
213   // resized wallpaper to |path|. |output_skia| is optional (may be
214   // NULL). Returns true on success.
215   static bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image,
216                                      const base::FilePath& path,
217                                      ash::WallpaperLayout layout,
218                                      int preferred_width,
219                                      int preferred_height,
220                                      gfx::ImageSkia* output_skia);
221
222   // Returns the appropriate wallpaper resolution for all root windows.
223   static WallpaperResolution GetAppropriateResolution();
224   // This is a temporary variant of the previous method to investigate
225   // a problem with WallpaperManagetBrowserTest.
226   static WallpaperResolution GetAppropriateResolutionForTesting();
227
228   void SetCommandLineForTesting(base::CommandLine* command_line);
229
230   // Indicates imminent shutdown, allowing the WallpaperManager to remove any
231   // observers it has registered.
232   void Shutdown();
233
234   // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers.
235   void AddObservers();
236
237   // Loads wallpaper asynchronously if the current wallpaper is not the
238   // wallpaper of logged in user.
239   void EnsureLoggedInUserWallpaperLoaded();
240
241   // Returns custom wallpaper path. Append |sub_dir|, |user_id_hash| and |file|
242   // to custom wallpaper directory.
243   base::FilePath GetCustomWallpaperPath(const char* sub_dir,
244                                         const std::string& user_id_hash,
245                                         const std::string& file) const;
246
247   // Gets wallpaper information of logged in user.
248   bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info);
249
250   // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged
251   // in, uses a solid color wallpaper. If logged in as a stub user, uses an
252   // empty wallpaper.
253   void InitializeWallpaper();
254
255   // NotificationObserver overrides:
256   virtual void Observe(int type,
257                        const content::NotificationSource& source,
258                        const content::NotificationDetails& details) OVERRIDE;
259
260   // Removes all |user_id| related wallpaper info and saved wallpapers.
261   void RemoveUserWallpaperInfo(const std::string& user_id);
262
263   // Saves custom wallpaper to file, post task to generate thumbnail and updates
264   // local state preferences. If |update_wallpaper| is false, don't change
265   // wallpaper but only update cache.
266   void SetCustomWallpaper(const std::string& user_id,
267                           const std::string& user_id_hash,
268                           const std::string& file,
269                           ash::WallpaperLayout layout,
270                           User::WallpaperType type,
271                           const gfx::ImageSkia& image,
272                           bool update_wallpaper);
273
274   // Use given files as new default wallpaper.
275   // Reloads current wallpaper, if old default was loaded.
276   // Current value of default_wallpaper_image_ is destroyed.
277   // Sets default_wallpaper_image_ either to |small_wallpaper_image| or
278   // |large_wallpaper_image| depending on GetAppropriateResolution().
279   void SetDefaultWallpaperPath(
280       const base::FilePath& customized_default_wallpaper_file_small,
281       scoped_ptr<gfx::ImageSkia> small_wallpaper_image,
282       const base::FilePath& customized_default_wallpaper_file_large,
283       scoped_ptr<gfx::ImageSkia> large_wallpaper_image);
284
285   // Sets wallpaper to default wallpaper (asynchronously with zero delay).
286   void SetDefaultWallpaperNow(const std::string& user_id);
287
288   // Sets wallpaper to default wallpaper (asynchronously with default delay).
289   void SetDefaultWallpaperDelayed(const std::string& user_id);
290
291   // Sets selected wallpaper information for |user_id| and saves it to Local
292   // State if |is_persistent| is true.
293   void SetUserWallpaperInfo(const std::string& user_id,
294                             const WallpaperInfo& info,
295                             bool is_persistent);
296
297   // Sets |user_id|'s wallpaper (asynchronously with zero delay).
298   void SetUserWallpaperNow(const std::string& user_id);
299
300   // Sets |user_id|'s wallpaper (asynchronously with default delay).
301   void SetUserWallpaperDelayed(const std::string& user_id);
302
303   // Sets wallpaper to |image| (asynchronously with zero delay). If
304   // |update_wallpaper| is false, skip change wallpaper but only update cache.
305   void SetWallpaperFromImageSkia(const std::string& user_id,
306                                  const gfx::ImageSkia& image,
307                                  ash::WallpaperLayout layout,
308                                  bool update_wallpaper);
309
310   // Updates current wallpaper. It may switch the size of wallpaper based on the
311   // current display's resolution. (asynchronously with zero delay)
312   void UpdateWallpaper(bool clear_cache);
313
314   // Adds given observer to the list.
315   void AddObserver(Observer* observer);
316
317   // Removes given observer from the list.
318   void RemoveObserver(Observer* observer);
319
320   // Returns whether a wallpaper policy is enforced for |user_id|.
321   bool IsPolicyControlled(const std::string& user_id) const;
322
323   // Called when a wallpaper policy has been set for |user_id|.  Blocks user
324   // from changing the wallpaper.
325   void OnPolicySet(const std::string& policy, const std::string& user_id);
326
327   // Called when the wallpaper policy has been cleared for |user_id|.
328   void OnPolicyCleared(const std::string& policy, const std::string& user_id);
329
330   // Called when the policy-set wallpaper has been fetched.  Initiates decoding
331   // of the JPEG |data| with a callback to SetPolicyControlledWallpaper().
332   void OnPolicyFetched(const std::string& policy,
333                        const std::string& user_id,
334                        scoped_ptr<std::string> data);
335
336   // This is called from CustomizationDocument.
337   // |resized_directory| is the directory where resized versions are stored and
338   // must be writable.
339   void SetCustomizedDefaultWallpaper(const GURL& wallpaper_url,
340                                      const base::FilePath& downloaded_file,
341                                      const base::FilePath& resized_directory);
342
343  private:
344   friend class TestApi;
345   friend class WallpaperManagerBrowserTest;
346   friend class WallpaperManagerBrowserTestDefaultWallpaper;
347   friend class WallpaperManagerPolicyTest;
348
349   typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap;
350
351   // Initialize wallpaper for the specified user to default and saves this
352   // settings in local state.
353   void InitInitialUserWallpaper(const std::string& user_id, bool is_persistent);
354
355   // Set wallpaper to |user_image| controlled by policy.  (Takes a UserImage
356   // because that's the callback interface provided by UserImageLoader.)
357   void SetPolicyControlledWallpaper(const std::string& user_id,
358                                     const UserImage& user_image);
359
360   // Gets encoded wallpaper from cache. Returns true if success.
361   bool GetWallpaperFromCache(const std::string& user_id, gfx::ImageSkia* image);
362
363   // The number of wallpapers have loaded. For test only.
364   int loaded_wallpapers() const { return loaded_wallpapers_; }
365
366   // Cache some (or all) logged in users' wallpapers to memory at login
367   // screen. It should not compete with first wallpaper loading when boot
368   // up/initialize login WebUI page.
369   // There are two ways the first wallpaper might be loaded:
370   // 1. Loaded on boot. Login WebUI waits for it.
371   // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded
372   // right away and in 500ms after. Wallpaper started to load.
373   // For case 2, should_cache_wallpaper_ is used to indicate if we need to
374   // cache wallpapers on wallpaper animation finished. The cache operation
375   // should be only executed once.
376   void CacheUsersWallpapers();
377
378   // Caches |user_id|'s wallpaper to memory.
379   void CacheUserWallpaper(const std::string& user_id);
380
381   // Clears disposable ONLINE and CUSTOM wallpaper cache. At multi profile
382   // world, logged in users' wallpaper cache is not disposable.
383   void ClearDisposableWallpaperCache();
384
385   // Clears all obsolete wallpaper prefs from old version wallpaper pickers.
386   void ClearObsoleteWallpaperPrefs();
387
388   // Deletes all |user_id| related custom wallpapers and directories.
389   void DeleteUserWallpapers(const std::string& user_id,
390                             const std::string& path_to_file);
391
392   // Gets the CommandLine representing the current process's command line.
393   base::CommandLine* GetCommandLine();
394
395   // Initialize wallpaper of registered device after device policy is trusted.
396   // Note that before device is enrolled, it proceeds with untrusted setting.
397   void InitializeRegisteredDeviceWallpaper();
398
399   // Loads |user_id|'s wallpaper. When |update_wallpaper| is true, sets
400   // wallpaper to the loaded wallpaper.
401   void LoadWallpaper(const std::string& user_id,
402                      const WallpaperInfo& info,
403                      bool update_wallpaper,
404                      MovableOnDestroyCallbackHolder on_finish);
405
406   // Moves custom wallpapers from |user_id| directory to |user_id_hash|
407   // directory.
408   void MoveCustomWallpapersOnWorker(const std::string& user_id,
409                                     const std::string& user_id_hash);
410
411   // Called when the original custom wallpaper is moved to the new place.
412   // Updates the corresponding user wallpaper info.
413   void MoveCustomWallpapersSuccess(const std::string& user_id,
414                                    const std::string& user_id_hash);
415
416   // Moves custom wallpaper to a new place. Email address was used as directory
417   // name in the old system, this is not safe. New directory system uses
418   // user_id_hash instead of user_id. This must be called after user_id_hash is
419   // ready.
420   void MoveLoggedInUserCustomWallpaper();
421
422   // Gets |user_id|'s custom wallpaper at |wallpaper_path|. Falls back on
423   // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper
424   // to the loaded wallpaper. Must run on wallpaper sequenced worker thread.
425   void GetCustomWallpaperInternal(const std::string& user_id,
426                                   const WallpaperInfo& info,
427                                   const base::FilePath& wallpaper_path,
428                                   bool update_wallpaper,
429                                   MovableOnDestroyCallbackHolder on_finish);
430
431   // Gets wallpaper information of |user_id| from Local State or memory. Returns
432   // false if wallpaper information is not found.
433   bool GetUserWallpaperInfo(const std::string& user_id,
434                             WallpaperInfo* info) const;
435
436   // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true.
437   // Otherwise, cache wallpaper to memory if not logged in.  (Takes a UserImage
438   // because that's the callback interface provided by UserImageLoader.)
439   void OnWallpaperDecoded(const std::string& user_id,
440                           ash::WallpaperLayout layout,
441                           bool update_wallpaper,
442                           MovableOnDestroyCallbackHolder on_finish,
443                           const UserImage& user_image);
444
445   // Record data for User Metrics Analysis.
446   void RecordUma(User::WallpaperType type, int index) const;
447
448   // Saves original custom wallpaper to |path| (absolute path) on filesystem
449   // and starts resizing operation of the custom wallpaper if necessary.
450   void SaveCustomWallpaper(const std::string& user_id_hash,
451                            const base::FilePath& path,
452                            ash::WallpaperLayout layout,
453                            scoped_ptr<gfx::ImageSkia> image) const;
454
455   // Creates new PendingWallpaper request (or updates currently pending).
456   void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed);
457
458   // Sets wallpaper to default.
459   void DoSetDefaultWallpaper(
460       const std::string& user_id,
461       MovableOnDestroyCallbackHolder on_finish);
462
463   // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the
464   // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread.
465   void StartLoad(const std::string& user_id,
466                  const WallpaperInfo& info,
467                  bool update_wallpaper,
468                  const base::FilePath& wallpaper_path,
469                  MovableOnDestroyCallbackHolder on_finish);
470
471   // After completed load operation, update average load time.
472   void SaveLastLoadTime(const base::TimeDelta elapsed);
473
474   // Notify all registered observers.
475   void NotifyAnimationFinished();
476
477   // Returns modifiable PendingWallpaper.
478   // Returns pending_inactive_ or creates new PendingWallpaper if necessary.
479   PendingWallpaper* GetPendingWallpaper(const std::string& user_id,
480                                         bool delayed);
481
482   // Calculate delay for next wallpaper load.
483   // It is usually average wallpaper load time.
484   // If last wallpaper load happened long ago, timeout should be reduced by
485   // the time passed after last wallpaper load. So usual user experience results
486   // in zero delay.
487   base::TimeDelta GetWallpaperLoadDelay() const;
488
489   // This is called after we check that supplied default wallpaper files exist.
490   void SetCustomizedDefaultWallpaperAfterCheck(
491       const GURL& wallpaper_url,
492       const base::FilePath& downloaded_file,
493       scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files);
494
495   // Starts rescaling of customized wallpaper.
496   void OnCustomizedDefaultWallpaperDecoded(
497       const GURL& wallpaper_url,
498       scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
499       const UserImage& user_image);
500
501   // Resize and save customized default wallpaper.
502   void ResizeCustomizedDefaultWallpaper(
503       scoped_ptr<gfx::ImageSkia> image,
504       const UserImage::RawImage& raw_image,
505       const CustomizedWallpaperRescaledFiles* rescaled_files,
506       bool* success,
507       gfx::ImageSkia* small_wallpaper_image,
508       gfx::ImageSkia* large_wallpaper_image);
509
510   // Check the result of ResizeCustomizedDefaultWallpaper and finally
511   // apply Customized Default Wallpaper.
512   void OnCustomizedDefaultWallpaperResized(
513       const GURL& wallpaper_url,
514       scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
515       scoped_ptr<bool> success,
516       scoped_ptr<gfx::ImageSkia> small_wallpaper_image,
517       scoped_ptr<gfx::ImageSkia> large_wallpaper_image);
518
519   // Init |*default_*_wallpaper_file_| from given command line and
520   // clear |default_wallpaper_image_|.
521   void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line);
522
523   // Sets wallpaper to decoded default.
524   void OnDefaultWallpaperDecoded(const base::FilePath& path,
525                                  const ash::WallpaperLayout layout,
526                                  scoped_ptr<UserImage>* result,
527                                  MovableOnDestroyCallbackHolder on_finish,
528                                  const UserImage& user_image);
529
530   // Start decoding given default wallpaper.
531   void StartLoadAndSetDefaultWallpaper(const base::FilePath& path,
532                                        const ash::WallpaperLayout layout,
533                                        MovableOnDestroyCallbackHolder on_finish,
534                                        scoped_ptr<UserImage>* result_out);
535
536   // Returns wallpaper subdirectory name for current resolution.
537   const char* GetCustomWallpaperSubdirForCurrentResolution();
538
539   // The number of loaded wallpapers.
540   int loaded_wallpapers_;
541
542   // Sequence token associated with wallpaper operations.
543   base::SequencedWorkerPool::SequenceToken sequence_token_;
544
545   // Wallpaper sequenced task runner.
546   scoped_refptr<base::SequencedTaskRunner> task_runner_;
547
548   // The file path of current loaded/loading custom/online wallpaper.
549   base::FilePath current_wallpaper_path_;
550
551   // Loads user wallpaper from its file.
552   scoped_refptr<UserImageLoader> wallpaper_loader_;
553
554   // Logged-in user wallpaper information.
555   WallpaperInfo current_user_wallpaper_info_;
556
557   // If non-NULL, used in place of the real command line.
558   base::CommandLine* command_line_for_testing_;
559
560   // Caches wallpapers of users. Accessed only on UI thread.
561   CustomWallpaperMap wallpaper_cache_;
562
563   // The last selected user on user pod row.
564   std::string last_selected_user_;
565
566   bool should_cache_wallpaper_;
567
568   scoped_ptr<CrosSettings::ObserverSubscription>
569       show_user_name_on_signin_subscription_;
570
571   base::WeakPtrFactory<WallpaperManager> weak_factory_;
572
573   content::NotificationRegistrar registrar_;
574
575   ObserverList<Observer> observers_;
576
577   // These members are for the scheduler:
578
579   // When last load attempt finished.
580   base::Time last_load_finished_at_;
581
582   // last N wallpaper loads times.
583   std::deque<base::TimeDelta> last_load_times_;
584
585   // Pointer to last inactive (waiting) entry of 'loading_' list.
586   // NULL when there is no inactive request.
587   PendingWallpaper* pending_inactive_;
588
589   // Owns PendingWallpaper.
590   // PendingWallpaper deletes itself from here on load complete.
591   // All pending will be finally deleted on destroy.
592   typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList;
593   PendingList loading_;
594
595   base::FilePath default_small_wallpaper_file_;
596   base::FilePath default_large_wallpaper_file_;
597
598   base::FilePath guest_small_wallpaper_file_;
599   base::FilePath guest_large_wallpaper_file_;
600
601   // Current decoded default image is stored in cache.
602   scoped_ptr<UserImage> default_wallpaper_image_;
603
604   DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
605 };
606
607 }  // namespace chromeos
608
609 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_