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

Unified Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/util.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, 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/util.js
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js
index b1e402d9aa2b314772fabba9ada6cea8b290e01c..f6811212a19a671a14c25cc69f3aea48ac7ed4cf 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js
@@ -259,10 +259,27 @@ WallpaperUtil.setCustomWallpaperFromSyncFS = function(
console.error(chrome.runtime.lastError.message);
return;
}
- WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
- reader.result, Constants.WallpaperDirNameEnum.ORIGINAL);
- WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
- thumbnailData, Constants.WallpaperDirNameEnum.THUMBNAIL);
+ // If the current synced wallpaper is a third party wallpaper,
+ // we also sync the third party app's name. Otherwise, we save
+ // the custom wallpaper to the local filesystem.
+ if (wallpaperFilename.indexOf(
+ Constants.ThirdPartyWallpaperPrefix) != -1) {
tbarzic 2016/01/28 20:10:48 nit: add 4 indent
+ Constants.WallpaperSyncStorage.get(
+ Constants.AccessSyncThirdPartyAppName, function(items) {
+ if (items.hasOwnProperty(
+ Constants.AccessSyncThirdPartyAppName)) {
+ WallpaperUtil.saveToLocalStorage(
+ Constants.AccessLocalThirdPartyAppName,
+ items[Constants.AccessSyncThirdPartyAppName]);
+ }
+ });
+ } else {
+ WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
+ reader.result, Constants.WallpaperDirNameEnum.ORIGINAL);
+ WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
+ thumbnailData, Constants.WallpaperDirNameEnum.THUMBNAIL);
+ WallpaperUtil.clearThirdPartyAppName();
+ }
if (onSuccess)
onSuccess();
});
@@ -276,6 +293,28 @@ WallpaperUtil.setCustomWallpaperFromSyncFS = function(
};
/**
+ * Save the third party wallpaper app name to local & sync filesystem.
+ * @param {string} appname The third party wallpaper extension or app's name.
+ */
+WallpaperUtil.saveThirdPartyAppName = function(appname) {
+ WallpaperUtil.saveToLocalStorage(Constants.AccessLocalThirdPartyAppName,
+ appname, function() {
+ WallpaperUtil.saveToSyncStorage(Constants.AccessSyncThirdPartyAppName,
+ appname);
+});
tbarzic 2016/01/28 20:10:48 nit: indent
+};
+
+/**
+ * Clear the third party wallpaper app name from local & sync filesystem.
+ */
+WallpaperUtil.clearThirdPartyAppName = function() {
+ WallpaperUtil.saveToLocalStorage(Constants.AccessLocalThirdPartyAppName, '',
+ function() {
+ WallpaperUtil.saveToSyncStorage(Constants.AccessSyncThirdPartyAppName, '');
+ });
+};
+
+/**
* Saves value to local storage that associates with key.
* @param {string} key The key that associates with value.
* @param {string} value The value to save to local storage.
@@ -381,6 +420,7 @@ WallpaperUtil.setOnlineWallpaper = function(url, layout, onSuccess, onFailure) {
onSuccess);
self.saveWallpaperInfo(url, layout,
Constants.WallpaperSourceEnum.Online);
+ WallpaperUtil.clearThirdPartyAppName();
} else {
onFailure();
}

Powered by Google App Engine
This is Rietveld 408576698