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

Unified Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js

Issue 1566713005: Make the third party wallpaper syncable through different devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO Created 4 years, 11 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/resources/chromeos/wallpaper_manager/js/event_page.js
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
index eba94a343e034ee748bf9ae6095796fde5995a08..4a5a310c02d1b80959bf0d64a6f6e39026d7d934 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
@@ -320,6 +320,16 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
}
}
+ if (changes[Constants.AccessLocalWallpaperInfoKey]) {
+ // If the old wallpaper is a third party wallpaper we should remove it
+ // from the local & sync file system to free space.
+ var oldInfo = changes[Constants.AccessLocalWallpaperInfoKey].oldValue;
+ if (oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) {
+ WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url);
+ WallpaperUtil.deleteWallpaperFromSyncFS(oldInfo.url);
+ }
+ }
+
if (changes[Constants.AccessSyncWallpaperInfoKey]) {
var syncInfo = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
@@ -368,6 +378,15 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
Constants.WallpaperSourceEnum.Default) {
chrome.wallpaperPrivate.resetWallpaper();
}
+
+ // If the old wallpaper is a third party wallpaper we should
+ // remove it from the local & sync file system to free space.
+ if (localInfo && localInfo.url.indexOf(
+ Constants.ThirdPartyWallpaperPrefix) != -1) {
+ WallpaperUtil.deleteWallpaperFromLocalFS(localInfo.url);
+ WallpaperUtil.deleteWallpaperFromSyncFS(localInfo.url);
+ }
+
WallpaperUtil.saveToLocalStorage(
Constants.AccessLocalWallpaperInfoKey, syncInfo);
}
@@ -394,11 +413,21 @@ chrome.alarms.onAlarm.addListener(function() {
SurpriseWallpaper.getInstance().next();
});
-chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function() {
+chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function(
+ wallpaper, thumbnail, layout) {
WallpaperUtil.saveToLocalStorage(
Constants.AccessLocalSurpriseMeEnabledKey, false, function() {
WallpaperUtil.saveToSyncStorage(Constants.AccessSyncSurpriseMeEnabledKey,
false);
});
SurpriseWallpaper.getInstance().disable();
+
+ // Make third party wallpaper syncable through different devices.
+ // TODO(xdai): also sync the third party app name.
+ var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime();
+ var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix;
+ WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper);
+ WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail);
+ WallpaperUtil.saveWallpaperInfo(filename, layout,
+ Constants.WallpaperSourceEnum.Custom);
});

Powered by Google App Engine
This is Rietveld 408576698