Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1956)

Unified Diff: ash/desktop_background/desktop_background_controller.h

Issue 215293003: Move all wallpaper file loading and decoding from DesktopBackgroundController to WallpaperManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clang debug build. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/ash.gyp ('k') | ash/desktop_background/desktop_background_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/desktop_background/desktop_background_controller.h
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
index 505f7441792b86584a009f06becf2453195119f0..219e3c82f360e2cc2fb2be7ed350342b5af7d3d5 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -23,10 +23,6 @@ namespace aura {
class Window;
}
-namespace base {
-class CommandLine;
-}
-
namespace ash {
enum WallpaperLayout {
@@ -43,34 +39,17 @@ enum WallpaperLayout {
WALLPAPER_LAYOUT_TILE,
};
-enum WallpaperResolution {
- WALLPAPER_RESOLUTION_LARGE,
- WALLPAPER_RESOLUTION_SMALL
-};
-
const SkColor kLoginWallpaperColor = 0xFEFEFE;
-// The width and height of small/large resolution wallpaper. When screen size is
-// smaller than |kSmallWallpaperMaxWidth| and |kSmallWallpaperMaxHeight|, the
-// small resolution wallpaper should be used. Otherwise, uses the large
-// resolution wallpaper.
-ASH_EXPORT extern const int kSmallWallpaperMaxWidth;
-ASH_EXPORT extern const int kSmallWallpaperMaxHeight;
-ASH_EXPORT extern const int kLargeWallpaperMaxWidth;
-ASH_EXPORT extern const int kLargeWallpaperMaxHeight;
-
-// The width and heigh of wallpaper thumbnails.
-ASH_EXPORT extern const int kWallpaperThumbnailWidth;
-ASH_EXPORT extern const int kWallpaperThumbnailHeight;
-
class DesktopBackgroundControllerObserver;
class WallpaperResizer;
-// Loads selected desktop wallpaper from file system asynchronously and updates
-// background layer if loaded successfully.
+// Updates background layer if necessary.
class ASH_EXPORT DesktopBackgroundController
: public DisplayController::Observer {
public:
+ class TestAPI;
+
enum BackgroundMode {
BACKGROUND_NONE,
BACKGROUND_IMAGE,
@@ -83,10 +62,6 @@ class ASH_EXPORT DesktopBackgroundController
return desktop_background_mode_;
}
- void set_command_line_for_testing(base::CommandLine* command_line) {
- command_line_for_testing_ = command_line;
- }
-
// Add/Remove observers.
void AddObserver(DesktopBackgroundControllerObserver* observer);
void RemoveObserver(DesktopBackgroundControllerObserver* observer);
@@ -100,18 +75,13 @@ class ASH_EXPORT DesktopBackgroundController
// Initialize root window's background.
void OnRootWindowAdded(aura::Window* root_window);
- // Loads builtin wallpaper asynchronously and sets to current wallpaper
- // after loaded. Returns true if the controller started loading the
- // wallpaper and false otherwise (i.e. the appropriate wallpaper was
- // already loading or loaded).
- bool SetDefaultWallpaper(bool is_guest);
-
- // Sets the user selected custom wallpaper. Called when user selected a file
- // from file system or changed the layout of wallpaper.
- void SetCustomWallpaper(const gfx::ImageSkia& image, WallpaperLayout layout);
-
- // Cancels |default_wallpaper_loader_| if non-NULL.
- void CancelDefaultWallpaperLoader();
+ // Sets wallpaper. This is mostly called by WallpaperManager to set
+ // the default or user selected custom wallpaper.
+ // Returns true if new image was actually set. And false when duplicate set
+ // request detected.
+ bool SetWallpaperImage(const gfx::ImageSkia& image, WallpaperLayout layout);
+ // The same, but image from resources is used.
+ bool SetWallpaperResource(int resource_id, WallpaperLayout layout);
// Creates an empty wallpaper. Some tests require a wallpaper widget is ready
// when running. However, the wallpaper widgets are now created
@@ -121,9 +91,6 @@ class ASH_EXPORT DesktopBackgroundController
// crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe.
void CreateEmptyWallpaper();
- // Returns the appropriate wallpaper resolution for all root windows.
- WallpaperResolution GetAppropriateResolution();
-
// Move all desktop widgets to locked container.
// Returns true if the desktop moved.
bool MoveDesktopToLockedContainer();
@@ -135,30 +102,28 @@ class ASH_EXPORT DesktopBackgroundController
// Overrides DisplayController::Observer:
virtual void OnDisplayConfigurationChanged() OVERRIDE;
+ // Returns the maximum size of all displays combined in native
+ // resolutions. Note that this isn't the bounds of the display who
+ // has maximum resolutions. Instead, this returns the size of the
+ // maximum width of all displays, and the maximum height of all displays.
+ static gfx::Size GetMaxDisplaySizeInNative();
+
private:
friend class DesktopBackgroundControllerTest;
+ // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper;
FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize);
- // An operation to asynchronously loads wallpaper.
- class WallpaperLoader;
-
- // Returns true if the specified default wallpaper is already being
- // loaded by |wallpaper_loader_| or stored in |current_wallpaper_|.
- bool DefaultWallpaperIsAlreadyLoadingOrLoaded(
- const base::FilePath& image_file, int image_resource_id) const;
-
- // Returns true if the specified custom wallpaper is already stored
+ // Returns true if the specified wallpaper is already stored
// in |current_wallpaper_|.
- bool CustomWallpaperIsAlreadyLoaded(const gfx::ImageSkia& image) const;
+ // If |image| is NULL, resource_id is compared.
+ bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia* image,
+ int resource_id,
+ WallpaperLayout layout) const;
// Creates view for all root windows, or notifies them to repaint if they
// already exist.
void SetDesktopBackgroundImageMode();
- // Creates a new background widget and sets the background mode to image mode.
- // Called after a default wallpaper has been loaded successfully.
- void OnDefaultWallpaperLoadCompleted(scoped_refptr<WallpaperLoader> loader);
-
// Creates and adds component for current mode (either Widget or Layer) to
// |root_window|.
void InstallDesktopController(aura::Window* root_window);
@@ -184,15 +149,6 @@ class ASH_EXPORT DesktopBackgroundController
wallpaper_reload_delay_ = value;
}
- // Returns the maximum size of all displays combined in native
- // resolutions. Note that this isn't the bounds of the display who
- // has maximum resolutions. Instead, this returns the size of the
- // maximum width of all displays, and the maximum height of all displays.
- static gfx::Size GetMaxDisplaySizeInNative();
-
- // If non-NULL, used in place of the real command line.
- base::CommandLine* command_line_for_testing_;
-
// Can change at runtime.
bool locked_;
@@ -205,19 +161,8 @@ class ASH_EXPORT DesktopBackgroundController
// The current wallpaper.
scoped_ptr<WallpaperResizer> current_wallpaper_;
- // If a default wallpaper is stored in |current_wallpaper_|, the path and
- // resource ID that were passed to WallpaperLoader when loading it.
- // Otherwise, empty and -1, respectively.
- base::FilePath current_default_wallpaper_path_;
- int current_default_wallpaper_resource_id_;
-
gfx::Size current_max_display_size_;
- // Loads default wallpaper from disk.
- scoped_refptr<WallpaperLoader> default_wallpaper_loader_;
-
- base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_;
-
base::OneShotTimer<DesktopBackgroundController> timer_;
int wallpaper_reload_delay_;
« no previous file with comments | « ash/ash.gyp ('k') | ash/desktop_background/desktop_background_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698