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