| OLD | NEW |
| 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 ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/desktop_background/desktop_background_resources.h" | 10 #include "ash/desktop_background/desktop_background_resources.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 | 13 |
| 14 namespace aura { | 14 namespace aura { |
| 15 class RootWindow; | 15 class RootWindow; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 class ImageSkia; | 19 class ImageSkia; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 | 23 |
| 24 class UserWallpaperDelegate { | 24 class UserWallpaperDelegate { |
| 25 public: | 25 public: |
| 26 virtual ~UserWallpaperDelegate() {} | 26 virtual ~UserWallpaperDelegate() {} |
| 27 | 27 |
| 28 // Gets the index of user selected wallpaper. | 28 // Loads logged in user wallpaper asynchronously and sets to current wallpaper |
| 29 virtual const int GetUserWallpaperIndex() = 0; | 29 // after loaded. |
| 30 virtual void SetLoggedInUserWallpaper() = 0; |
| 30 | 31 |
| 31 // Opens the set wallpaper page in the browser. | 32 // Opens the set wallpaper page in the browser. |
| 32 virtual void OpenSetWallpaperPage() = 0; | 33 virtual void OpenSetWallpaperPage() = 0; |
| 33 | 34 |
| 34 // Returns true if user can open set wallpaper page. Only guest user returns | 35 // Returns true if user can open set wallpaper page. Only guest user returns |
| 35 // false currently. | 36 // false currently. |
| 36 virtual bool CanOpenSetWallpaperPage() = 0; | 37 virtual bool CanOpenSetWallpaperPage() = 0; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 // Loads selected desktop wallpaper from file system asynchronously and updates | 40 // Loads selected desktop wallpaper from file system asynchronously and updates |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 void SetDefaultWallpaper(int index); | 59 void SetDefaultWallpaper(int index); |
| 59 | 60 |
| 60 // Sets the user selected custom wallpaper. Called when user selected a file | 61 // Sets the user selected custom wallpaper. Called when user selected a file |
| 61 // from file system or changed the layout of wallpaper. | 62 // from file system or changed the layout of wallpaper. |
| 62 void SetCustomWallpaper(const gfx::ImageSkia& wallpaper, | 63 void SetCustomWallpaper(const gfx::ImageSkia& wallpaper, |
| 63 WallpaperLayout layout); | 64 WallpaperLayout layout); |
| 64 | 65 |
| 65 // Cancels the current wallpaper loading operation. | 66 // Cancels the current wallpaper loading operation. |
| 66 void CancelPendingWallpaperOperation(); | 67 void CancelPendingWallpaperOperation(); |
| 67 | 68 |
| 68 // Loads logged in user wallpaper asynchronously and sets to current wallpaper | |
| 69 // after loaded. | |
| 70 void SetLoggedInUserWallpaper(); | |
| 71 | |
| 72 // Sets the desktop background to solid color mode and creates a solid color | 69 // Sets the desktop background to solid color mode and creates a solid color |
| 73 // layout. | 70 // layout. |
| 74 void SetDesktopBackgroundSolidColorMode(); | 71 void SetDesktopBackgroundSolidColorMode(); |
| 75 | 72 |
| 73 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready |
| 74 // when running. However, the wallpaper widgets are now created asynchronously |
| 75 // . If loading a real wallpaper, there are cases that these tests crash |
| 76 // because the required widget is not ready. This function synchronously |
| 77 // creates an empty widget for those tests to prevent crashes. An example test |
| 78 // is SystemGestureEventFilterTest.ThreeFingerSwipe. |
| 79 void CreateEmptyWallpaper(); |
| 80 |
| 76 private: | 81 private: |
| 77 // An operation to asynchronously loads wallpaper. | 82 // An operation to asynchronously loads wallpaper. |
| 78 class WallpaperOperation; | 83 class WallpaperOperation; |
| 79 | 84 |
| 80 // Sets the desktop background to image mode and creates a new background | 85 // Sets the desktop background to image mode and creates a new background |
| 81 // widget with user selected wallpaper or default wallpaper. Deletes the old | 86 // widget with user selected wallpaper or default wallpaper. Deletes the old |
| 82 // widget if any. | 87 // widget if any. |
| 83 void SetDesktopBackgroundImageMode(scoped_refptr<WallpaperOperation> wo); | 88 void SetDesktopBackgroundImageMode(scoped_refptr<WallpaperOperation> wo); |
| 84 | 89 |
| 85 // Creates a new background widget and sets the background mode to image mode. | 90 // Creates a new background widget and sets the background mode to image mode. |
| 86 // Called after wallpaper loaded successfully. | 91 // Called after wallpaper loaded successfully. |
| 87 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); | 92 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); |
| 88 | 93 |
| 89 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready | |
| 90 // when running. However, the wallpaper widgets are now created asynchronously | |
| 91 // . If loading a real wallpaper, there are cases that these tests crash | |
| 92 // because the required widget is not ready. This function synchronously | |
| 93 // creates an empty widget for those tests to prevent crashes. An example test | |
| 94 // is SystemGestureEventFilterTest.ThreeFingerSwipe. | |
| 95 void CreateEmptyWallpaper(); | |
| 96 | |
| 97 aura::RootWindow* root_window_; | 94 aura::RootWindow* root_window_; |
| 98 | 95 |
| 99 // Can change at runtime. | 96 // Can change at runtime. |
| 100 BackgroundMode desktop_background_mode_; | 97 BackgroundMode desktop_background_mode_; |
| 101 | 98 |
| 102 // The previous successfully loaded wallpaper. | 99 // The previous successfully loaded wallpaper. |
| 103 int previous_index_; | 100 int previous_index_; |
| 104 | 101 |
| 105 scoped_refptr<WallpaperOperation> wallpaper_op_; | 102 scoped_refptr<WallpaperOperation> wallpaper_op_; |
| 106 | 103 |
| 107 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; | 104 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; |
| 108 | 105 |
| 109 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 106 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
| 110 }; | 107 }; |
| 111 | 108 |
| 112 } // namespace ash | 109 } // namespace ash |
| 113 | 110 |
| 114 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 111 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| OLD | NEW |