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

Unified Diff: chrome/browser/chromeos/login/wallpaper_manager.h

Issue 208273005: If customization includes default wallpaper, download and apply it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DBC::IsUsingDefaultWallpaper(); Restart wallpaper fetch on device restart. Created 6 years, 9 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
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..26c8c1c1f8d04f280d63ab4c42347b41cb33200c 100644
--- a/chrome/browser/chromeos/login/wallpaper_manager.h
+++ b/chrome/browser/chromeos/login/wallpaper_manager.h
@@ -72,6 +72,28 @@ extern const char kThumbnailWallpaperSubDir[];
// OS device.
class WallpaperManager: public content::NotificationObserver {
public:
+ struct CustomizedWallpaperRescaledFiles {
+ CustomizedWallpaperRescaledFiles(
+ const base::FilePath& path_rescaled_original,
+ const base::FilePath& path_rescaled_small,
+ const base::FilePath& path_rescaled_large);
+
+ base::FilePath path_rescaled_original;
+ base::FilePath path_rescaled_small;
+ base::FilePath path_rescaled_large;
+ };
+
+ struct CustomizedWallpaperFilesExist {
+ CustomizedWallpaperFilesExist();
+
+ bool AllRescaledExist() const;
+
+ bool dowloaded;
Daniel Erat 2014/03/25 21:58:29 s/dowloaded/downloaded/
Alexander Alekseev 2014/03/27 00:28:37 Done.
+ bool rescaled_original;
+ bool rescaled_small;
+ bool rescaled_large;
+ };
+
// For testing.
class TestApi {
public:
@@ -171,9 +193,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.
@@ -229,7 +249,8 @@ class WallpaperManager: public content::NotificationObserver {
// 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,
+ // Result is true on success.
+ bool ResizeAndSaveWallpaper(const UserImage& wallpaper,
const base::FilePath& path,
ash::WallpaperLayout layout,
int preferred_width,
@@ -246,6 +267,12 @@ 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,
+ const base::FilePath& customized_default_wallpaper_file_large);
+
// Sets wallpaper to default wallpaper (asynchronously with zero delay).
void SetDefaultWallpaperNow(const std::string& user_id);
@@ -305,9 +332,17 @@ class WallpaperManager: public content::NotificationObserver {
const std::string& user_id,
scoped_ptr<std::string> data);
+ // This is called from CustomizationDocument.
+ // scaled_directory - directory where resized versions are stored
Daniel Erat 2014/03/25 21:58:29 this comment seems outdated
Alexander Alekseev 2014/03/27 00:28:37 Done.
+ // (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 +460,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 +499,45 @@ 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);
+
+ // 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);
+
+ // 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);
+
// The number of loaded wallpapers.
int loaded_wallpapers_;
@@ -518,6 +594,12 @@ 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_;
+
DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
};

Powered by Google App Engine
This is Rietveld 408576698