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..5a63f0f80898e34bed9b493a2eeef3d44eb195e2 100644 |
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js |
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js |
@@ -296,11 +296,6 @@ chrome.syncFileSystem.onFileStatusChanged.addListener(function(detail) { |
Constants.CustomWallpaperThumbnailSuffix, ''); |
WallpaperUtil.deleteWallpaperFromLocalFS(fileName); |
} |
- } else { // detail.direction == 'local_to_remote' |
bshe
2016/01/13 18:43:17
why do you want to remove this?
xdai1
2016/01/14 23:03:51
It's a different issue and it was introduced by me
bshe
2016/01/15 15:52:00
Acknowledged.
|
- if (detail.action == 'deleted') { |
- WallpaperUtil.deleteWallpaperFromSyncFS(detail.fileEntry.name); |
- WallpaperUtil.deleteWallpaperFromLocalFS(detail.fileEntry.name); |
- } |
} |
} |
}); |
@@ -320,6 +315,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 +373,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 +408,20 @@ 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. |
+ var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime(); |
bshe
2016/01/08 19:56:39
We dont need a history of 3rd party wallpapers. Pe
xdai1
2016/01/08 20:17:48
No, I'm afraid we can't use the same file name for
|
+ var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix; |
+ WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper); |
+ WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail); |
bshe
2016/01/13 18:43:17
why do we want thumbnail for 3rd party wallpaper?
xdai1
2016/01/14 23:03:51
You're right. Ideally we should not show the third
bshe
2016/01/15 15:52:00
I might not understand you correctly, But the 3rd
|
+ WallpaperUtil.saveWallpaperInfo(filename, layout, |
+ Constants.WallpaperSourceEnum.Custom); |
}); |