| 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 | 13 |
| 13 class SkBitmap; | 14 class SkBitmap; |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 | 17 |
| 17 class UserWallpaperDelegate { | 18 class UserWallpaperDelegate { |
| 18 public: | 19 public: |
| 19 virtual ~UserWallpaperDelegate() {} | 20 virtual ~UserWallpaperDelegate() {} |
| 20 | 21 |
| 21 // Gets the index of user selected wallpaper. | 22 // Gets the index of user selected wallpaper. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 DesktopBackgroundController(); | 42 DesktopBackgroundController(); |
| 42 virtual ~DesktopBackgroundController(); | 43 virtual ~DesktopBackgroundController(); |
| 43 | 44 |
| 44 // Get the desktop background mode. | 45 // Get the desktop background mode. |
| 45 BackgroundMode desktop_background_mode() const { | 46 BackgroundMode desktop_background_mode() const { |
| 46 return desktop_background_mode_; | 47 return desktop_background_mode_; |
| 47 } | 48 } |
| 48 | 49 |
| 49 // Sets the desktop background to image mode and create a new background | 50 // Load default wallpaper at |index| asynchronously and set to current |
| 50 // widget with user selected wallpaper or default wallpaper. Delete the old | 51 // wallpaper after loaded. |
| 51 // widget if any. | 52 void SetDefaultWallpaper(int index); |
| 52 void SetDesktopBackgroundImageMode(); | 53 |
| 54 // Cancel the current wallpaper loading operation. |
| 55 void CancelPendingWallpaperOperation(); |
| 56 |
| 57 // Load logged in user wallpaper asynchronously and set to current wallpaper |
| 58 // after loaded. |
| 59 void SetLoggedInUserWallpaper(); |
| 53 | 60 |
| 54 // Sets the desktop background to solid color mode and create a solid color | 61 // Sets the desktop background to solid color mode and create a solid color |
| 55 // layout. | 62 // layout. |
| 56 void SetDesktopBackgroundSolidColorMode(); | 63 void SetDesktopBackgroundSolidColorMode(); |
| 57 | 64 |
| 58 private: | 65 private: |
| 66 // An operation to asynchronously load wallpaper. |
| 67 class WallpaperOperation; |
| 68 |
| 69 // Sets the desktop background to image mode and create a new background |
| 70 // widget with user selected wallpaper or default wallpaper. Delete the old |
| 71 // widget if any. |
| 72 void SetDesktopBackgroundImageMode(scoped_refptr<WallpaperOperation> wo); |
| 73 |
| 74 // Default wallpapper loaded, set the background mode to image mode. |
| 75 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); |
| 76 |
| 77 // Create an empty wallpaper. Some tests require a wallpaper widget is ready |
| 78 // when running. However, the wallpaper widgets are now created asynchronously |
| 79 // . If loading a real wallpaper, there are cases that these tests crash |
| 80 // because the required widget is not ready. This function synchronously |
| 81 // creates an empty widget for those tests to prevent crashes. An example test |
| 82 // is SystemGestureEventFilterTest.ThreeFingerSwipe. |
| 83 void CreateEmptyWallpaper(); |
| 84 |
| 59 // Can change at runtime. | 85 // Can change at runtime. |
| 60 BackgroundMode desktop_background_mode_; | 86 BackgroundMode desktop_background_mode_; |
| 61 | 87 |
| 88 // The previous successfully loaded wallpaper. |
| 89 int previous_index_; |
| 90 |
| 91 scoped_refptr<WallpaperOperation> wallpaper_op_; |
| 92 |
| 93 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; |
| 94 |
| 62 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 95 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
| 63 }; | 96 }; |
| 64 | 97 |
| 65 } // namespace ash | 98 } // namespace ash |
| 66 | 99 |
| 67 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 100 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| OLD | NEW |