| OLD | NEW |
| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | |
| 16 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 18 #include "chrome/browser/chromeos/login/user.h" | 17 #include "chrome/browser/chromeos/login/user.h" |
| 19 #include "chrome/browser/chromeos/login/user_image.h" | 18 #include "chrome/browser/chromeos/login/user_image.h" |
| 20 #include "chrome/browser/chromeos/login/user_image_loader.h" | 19 #include "chrome/browser/chromeos/login/user_image_loader.h" |
| 21 #include "chrome/browser/chromeos/settings/cros_settings.h" | 20 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 22 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 24 #include "third_party/icu/source/i18n/unicode/timezone.h" | 23 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 25 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 virtual ~TestApi(); | 73 virtual ~TestApi(); |
| 75 | 74 |
| 76 base::FilePath current_wallpaper_path(); | 75 base::FilePath current_wallpaper_path(); |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 WallpaperManager* wallpaper_manager_; // not owned | 78 WallpaperManager* wallpaper_manager_; // not owned |
| 80 | 79 |
| 81 DISALLOW_COPY_AND_ASSIGN(TestApi); | 80 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 class Observer { | |
| 85 public: | |
| 86 virtual ~Observer() {} | |
| 87 virtual void OnWallpaperAnimationFinished(const std::string& email) = 0; | |
| 88 }; | |
| 89 | |
| 90 static WallpaperManager* Get(); | 83 static WallpaperManager* Get(); |
| 91 | 84 |
| 92 WallpaperManager(); | 85 WallpaperManager(); |
| 93 virtual ~WallpaperManager(); | 86 virtual ~WallpaperManager(); |
| 94 | 87 |
| 95 void set_command_line_for_testing(CommandLine* command_line) { | 88 void set_command_line_for_testing(CommandLine* command_line) { |
| 96 command_line_for_testing_ = command_line; | 89 command_line_for_testing_ = command_line; |
| 97 } | 90 } |
| 98 | 91 |
| 99 // Indicates imminent shutdown, allowing the WallpaperManager to remove any | 92 // Indicates imminent shutdown, allowing the WallpaperManager to remove any |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void SetUserWallpaper(const std::string& email); | 181 void SetUserWallpaper(const std::string& email); |
| 189 | 182 |
| 190 // Sets wallpaper to |wallpaper|. | 183 // Sets wallpaper to |wallpaper|. |
| 191 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper, | 184 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper, |
| 192 ash::WallpaperLayout layout); | 185 ash::WallpaperLayout layout); |
| 193 | 186 |
| 194 // Updates current wallpaper. It may switch the size of wallpaper based on the | 187 // Updates current wallpaper. It may switch the size of wallpaper based on the |
| 195 // current display's resolution. | 188 // current display's resolution. |
| 196 void UpdateWallpaper(); | 189 void UpdateWallpaper(); |
| 197 | 190 |
| 198 // Adds given observer to the list. | |
| 199 void AddObserver(Observer* observer); | |
| 200 | |
| 201 // Removes given observer from the list. | |
| 202 void RemoveObserver(Observer* observer); | |
| 203 | |
| 204 private: | 191 private: |
| 205 friend class TestApi; | 192 friend class TestApi; |
| 206 friend class WallpaperManagerBrowserTest; | 193 friend class WallpaperManagerBrowserTest; |
| 207 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 194 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
| 208 | 195 |
| 209 // The number of wallpapers have loaded. For test only. | 196 // The number of wallpapers have loaded. For test only. |
| 210 int loaded_wallpapers() const { return loaded_wallpapers_; } | 197 int loaded_wallpapers() const { return loaded_wallpapers_; } |
| 211 | 198 |
| 212 // Cache some (or all) logged in users' wallpapers to memory at login | 199 // Cache some (or all) logged in users' wallpapers to memory at login |
| 213 // screen. It should not compete with first wallpaper loading when boot | 200 // screen. It should not compete with first wallpaper loading when boot |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 void SaveWallpaperInternal(const base::FilePath& path, const char* data, | 299 void SaveWallpaperInternal(const base::FilePath& path, const char* data, |
| 313 int size); | 300 int size); |
| 314 | 301 |
| 315 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the | 302 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the |
| 316 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. | 303 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. |
| 317 void StartLoad(const std::string& email, | 304 void StartLoad(const std::string& email, |
| 318 const WallpaperInfo& info, | 305 const WallpaperInfo& info, |
| 319 bool update_wallpaper, | 306 bool update_wallpaper, |
| 320 const base::FilePath& wallpaper_path); | 307 const base::FilePath& wallpaper_path); |
| 321 | 308 |
| 322 // Notify all registed observers. | |
| 323 void NotifyAnimationFinished(); | |
| 324 | |
| 325 // The number of loaded wallpapers. | 309 // The number of loaded wallpapers. |
| 326 int loaded_wallpapers_; | 310 int loaded_wallpapers_; |
| 327 | 311 |
| 328 // Sequence token associated with wallpaper operations. | 312 // Sequence token associated with wallpaper operations. |
| 329 base::SequencedWorkerPool::SequenceToken sequence_token_; | 313 base::SequencedWorkerPool::SequenceToken sequence_token_; |
| 330 | 314 |
| 331 // Wallpaper sequenced task runner. | 315 // Wallpaper sequenced task runner. |
| 332 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 316 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 333 | 317 |
| 334 // The file path of current loaded/loading custom/online wallpaper. | 318 // The file path of current loaded/loading custom/online wallpaper. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 351 | 335 |
| 352 bool should_cache_wallpaper_; | 336 bool should_cache_wallpaper_; |
| 353 | 337 |
| 354 scoped_ptr<CrosSettings::ObserverSubscription> | 338 scoped_ptr<CrosSettings::ObserverSubscription> |
| 355 show_user_name_on_signin_subscription_; | 339 show_user_name_on_signin_subscription_; |
| 356 | 340 |
| 357 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 341 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
| 358 | 342 |
| 359 content::NotificationRegistrar registrar_; | 343 content::NotificationRegistrar registrar_; |
| 360 | 344 |
| 361 ObserverList<Observer> observers_; | |
| 362 | |
| 363 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 345 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
| 364 }; | 346 }; |
| 365 | 347 |
| 366 } // namespace chromeos | 348 } // namespace chromeos |
| 367 | 349 |
| 368 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 350 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
| OLD | NEW |