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

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

Issue 1631923004: Sync 3rd party wallpaper app name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address tbarzic@'s comments. Created 4 years, 10 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 800b25477dc1836503281fb8c58dd3c963345ed3..084a4bcf85ba6fbdfe870c557eb8753389cfa7e3 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
@@ -279,16 +279,25 @@ chrome.syncFileSystem.onFileStatusChanged.addListener(function(detail) {
Constants.AccessLocalWallpaperInfoKey,
function(items) {
var localData = items[Constants.AccessLocalWallpaperInfoKey];
- if (localData && localData.url == detail.fileEntry.name &&
- localData.source == Constants.WallpaperSourceEnum.Custom) {
- WallpaperUtil.setCustomWallpaperFromSyncFS(localData.url,
- localData.layout);
- } else if (!localData || localData.url !=
- detail.fileEntry.name.replace(
- Constants.CustomWallpaperThumbnailSuffix, '')) {
+ if (!localData) {
// localData might be null on a powerwashed device.
WallpaperUtil.storeWallpaperFromSyncFSToLocalFS(
detail.fileEntry);
+ } else if (localData.url == detail.fileEntry.name &&
+ localData.source == Constants.WallpaperSourceEnum.Custom) {
+ if (localData.hasOwnProperty('appName')) {
+ WallpaperUtil.setCustomWallpaperFromSyncFS(
+ localData.url, localData.layout, localData.appName);
tbarzic 2016/02/04 21:31:24 I'd just use localData.appName || '' (instead of i
+ } else {
+ WallpaperUtil.setCustomWallpaperFromSyncFS(
+ localData.url, localData.layout, '');
+ }
+ } else if (localData.url != detail.fileEntry.name.replace(
+ Constants.CustomWallpaperThumbnailSuffix, '') &&
+ detail.fileEntry.name.indexOf(
+ Constants.ThirdPartyWallpaperPrefix) == -1) {
+ WallpaperUtil.storeWallpaperFromSyncFSToLocalFS(
+ detail.fileEntry);
}
});
} else if (detail.action == 'deleted') {
@@ -319,7 +328,8 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
// 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) {
+ if (oldInfo &&
+ oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) {
WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url);
WallpaperUtil.deleteWallpaperFromSyncFS(oldInfo.url);
}
@@ -354,7 +364,7 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
// storage are the same. If the synced value changed by sync
// service, they may different. In that case, change wallpaper
// to the one saved in sync storage and update the local value.
- if (localInfo == undefined ||
+ if (!localInfo ||
localInfo.url != syncInfo.url ||
localInfo.layout != syncInfo.layout ||
localInfo.source != syncInfo.source) {
@@ -367,8 +377,13 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
syncInfo.layout, function() {}, function() {});
} else if (syncInfo.source ==
Constants.WallpaperSourceEnum.Custom) {
- WallpaperUtil.setCustomWallpaperFromSyncFS(syncInfo.url,
- syncInfo.layout);
+ if (syncInfo.hasOwnProperty('appName')) {
+ WallpaperUtil.setCustomWallpaperFromSyncFS(
+ syncInfo.url, syncInfo.layout, syncInfo.appName);
tbarzic 2016/02/04 21:31:24 How about: WallpaperUtil.setCustomWallpaperFromSyn
xdai1 2016/02/05 01:09:52 As explained in WallpaperUtil.setCustomWallpaperFr
+ } else {
+ WallpaperUtil.setCustomWallpaperFromSyncFS(
+ syncInfo.url, syncInfo.layout, '');
+ }
} else if (syncInfo.source ==
Constants.WallpaperSourceEnum.Default) {
chrome.wallpaperPrivate.resetWallpaper();
@@ -409,7 +424,7 @@ chrome.alarms.onAlarm.addListener(function() {
});
chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function(
- wallpaper, thumbnail, layout) {
+ wallpaper, thumbnail, layout, appName) {
WallpaperUtil.saveToLocalStorage(
Constants.AccessLocalSurpriseMeEnabledKey, false, function() {
WallpaperUtil.saveToSyncStorage(Constants.AccessSyncSurpriseMeEnabledKey,
@@ -418,11 +433,10 @@ chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function(
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);
+ WallpaperUtil.saveWallpaperInfo(
tbarzic 2016/02/04 21:31:24 Not introduced here, but might make for a good fol
xdai1 2016/02/05 01:09:52 Might not true. It's the onChanged() event which i
tbarzic 2016/02/05 22:27:37 Oh, yeah, syncFileSystem,onFileStatusChange only h
+ filename, layout, Constants.WallpaperSourceEnum.Custom, appName);
});

Powered by Google App Engine
This is Rietveld 408576698