Index: chrome/browser/chromeos/login/wallpaper_manager.h |
diff --git a/chrome/browser/chromeos/login/wallpaper_manager.h b/chrome/browser/chromeos/login/wallpaper_manager.h |
index aed11eb96a21c8c064af59a89bea9d2af593a822..a0e170178f5423640c9b32bc3d3c83334710c16e 100644 |
--- a/chrome/browser/chromeos/login/wallpaper_manager.h |
+++ b/chrome/browser/chromeos/login/wallpaper_manager.h |
@@ -72,6 +72,25 @@ extern const char kThumbnailWallpaperSubDir[]; |
// OS device. |
class WallpaperManager: public content::NotificationObserver { |
public: |
+ struct CustomizedWallpaperRescaledFiles { |
+ CustomizedWallpaperRescaledFiles( |
+ const base::FilePath& path_rescaled_small, |
+ const base::FilePath& path_rescaled_large); |
+ |
+ base::FilePath path_rescaled_small; |
+ base::FilePath path_rescaled_large; |
+ }; |
+ |
+ struct CustomizedWallpaperFilesExist { |
+ CustomizedWallpaperFilesExist(); |
+ |
+ bool AllRescaledExist() const; |
+ |
+ bool downloaded; |
+ bool rescaled_small; |
+ bool rescaled_large; |
+ }; |
+ |
// For testing. |
class TestApi { |
public: |
@@ -171,9 +190,7 @@ class WallpaperManager: public content::NotificationObserver { |
WallpaperManager(); |
virtual ~WallpaperManager(); |
- void set_command_line_for_testing(base::CommandLine* command_line) { |
- command_line_for_testing_ = command_line; |
- } |
+ void set_command_line_for_testing(base::CommandLine* command_line); |
// Indicates imminent shutdown, allowing the WallpaperManager to remove any |
// observers it has registered. |
@@ -224,16 +241,19 @@ class WallpaperManager: public content::NotificationObserver { |
ash::WallpaperLayout layout, |
int preferred_width, |
int preferred_height, |
- scoped_refptr<base::RefCountedBytes>* output) const; |
+ scoped_refptr<base::RefCountedBytes>* output, |
+ gfx::ImageSkia* output_skia) const; |
// Resizes |wallpaper| to a resolution which is nearest to |preferred_width| |
// and |preferred_height| while maintaining aspect ratio. And saves the |
- // resized wallpaper to |path|. |
- void ResizeAndSaveWallpaper(const UserImage& wallpaper, |
+ // resized wallpaper to |path|. |result| is optional (may be NULL). |
+ // Result is true on success. |
+ bool ResizeAndSaveWallpaper(const UserImage& wallpaper, |
const base::FilePath& path, |
ash::WallpaperLayout layout, |
int preferred_width, |
- int preferred_height) const; |
+ int preferred_height, |
+ gfx::ImageSkia* result) const; |
// Saves custom wallpaper to file, post task to generate thumbnail and updates |
// local state preferences. If |update_wallpaper| is false, don't change |
@@ -246,6 +266,14 @@ class WallpaperManager: public content::NotificationObserver { |
const UserImage& wallpaper, |
bool update_wallpaper); |
+ // Use given files as new default wallpaper. |
+ // Reloads current wallpaper, if old default was loaded. |
+ void SetDefaultWallpaperPath( |
+ const base::FilePath& customized_default_wallpaper_file_small, |
+ scoped_ptr<gfx::ImageSkia> small_wallpaper_image, |
+ const base::FilePath& customized_default_wallpaper_file_large, |
+ scoped_ptr<gfx::ImageSkia> large_wallpaper_image); |
+ |
// Sets wallpaper to default wallpaper (asynchronously with zero delay). |
void SetDefaultWallpaperNow(const std::string& user_id); |
@@ -305,9 +333,17 @@ class WallpaperManager: public content::NotificationObserver { |
const std::string& user_id, |
scoped_ptr<std::string> data); |
+ // This is called from CustomizationDocument. |
+ // resized_directory - directory where resized versions are stored |
+ // (must be writable) |
+ void SetCustomizedDefaultWallpaper(const GURL& wallpaper_url, |
+ const base::FilePath& downloaded_file, |
+ const base::FilePath& resized_directory); |
private: |
friend class TestApi; |
friend class WallpaperManagerBrowserTest; |
+ friend class WallpaperManagerTest; |
+ |
typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
// Set |wallpaper| controlled by policy. |
@@ -425,7 +461,9 @@ class WallpaperManager: public content::NotificationObserver { |
const UserImage& wallpaper); |
// Saves wallpaper image raw |data| to |path| (absolute path) in file system. |
- void SaveWallpaperInternal(const base::FilePath& path, const char* data, |
+ // True on success. |
+ bool SaveWallpaperInternal(const base::FilePath& path, |
+ const char* data, |
int size) const; |
// Creates new PendingWallpaper request (or updates currently pending). |
@@ -462,6 +500,61 @@ class WallpaperManager: public content::NotificationObserver { |
// in zero delay. |
base::TimeDelta GetWallpaperLoadDelay() const; |
+ // This is called after we check that supplied default wallpaper files exist. |
+ void SetCustomizedDefaultWallpaperAfterCheck( |
+ const GURL& wallpaper_url, |
+ const base::FilePath& downloaded_file, |
+ scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
+ scoped_ptr<CustomizedWallpaperFilesExist> exist); |
+ |
+ // Starts rescaling of customized wallpaper. |
+ void OnCustomizedDefaultWallpaperDecoded( |
+ const GURL& wallpaper_url, |
+ scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
+ const UserImage& user_image); |
+ |
+ // Resize and save customized default wallpaper. |
+ void ResizeCustomizedDefaultWallpaper( |
+ scoped_ptr<gfx::ImageSkia> image, |
+ const UserImage::RawImage& raw_image, |
+ const CustomizedWallpaperRescaledFiles* rescaled_files, |
+ bool* success, |
+ gfx::ImageSkia* small_wallpaper_image, |
+ gfx::ImageSkia* large_wallpaper_image); |
+ |
+ // Check the result of ResizeCustomizedDefaultWallpaper and finally |
+ // apply Customized Default Wallpaper. |
+ void OnCustomizedDefaultWallpaperResized( |
+ const GURL& wallpaper_url, |
+ scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
+ scoped_ptr<bool> success, |
+ scoped_ptr<gfx::ImageSkia> small_wallpaper_image, |
+ scoped_ptr<gfx::ImageSkia> large_wallpaper_image); |
+ |
+ // These global default values are used to set customized default |
+ // wallpaper path in InitializeWallpaper(). |
+ static base::FilePath GetCustomizedWallpaperDefaultRescaledFileName( |
+ const char* suffix); |
+ |
+ // If DesktopBackgroundController should start with customized default |
+ // wallpaper in InitializeWallpaper(). |
+ static bool ShouldUseCustomizedDefaultWallpaper(); |
+ |
+ // Init "*default_*_wallpaper_file_" from given command line. |
+ void SetDefaultWallpaperPathFromCommandLine(base::CommandLine* command_line); |
+ |
+ // Sets wallpaper to decoded default. |
+ void OnDefaultWallpaperDecoded(const base::FilePath& path, |
+ scoped_ptr<gfx::ImageSkia>* result, |
+ MovableOnDestroyCallbackHolder on_finish, |
+ const UserImage& wallpaper); |
+ |
+ // Start decoding given default wallpaper. |
+ void StartLoadAndSetDefaultWallpaper( |
+ const base::FilePath& path, |
+ scoped_ptr<gfx::ImageSkia>* result, |
+ MovableOnDestroyCallbackHolder on_finish); |
+ |
// The number of loaded wallpapers. |
int loaded_wallpapers_; |
@@ -518,6 +611,18 @@ class WallpaperManager: public content::NotificationObserver { |
typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; |
PendingList loading_; |
+ base::FilePath default_small_wallpaper_file_; |
+ base::FilePath default_large_wallpaper_file_; |
+ |
+ base::FilePath guest_default_small_wallpaper_file_; |
+ base::FilePath guest_default_large_wallpaper_file_; |
+ |
+ // Decoded default images are stored here. |
+ scoped_ptr<gfx::ImageSkia> default_small_wallpaper_image_; |
+ scoped_ptr<gfx::ImageSkia> default_large_wallpaper_image_; |
+ scoped_ptr<gfx::ImageSkia> guest_default_small_wallpaper_image_; |
+ scoped_ptr<gfx::ImageSkia> guest_default_large_wallpaper_image_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
}; |