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

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..ea5c3c4d1bae038d8fdcdc2c19a3a32c9421a304 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js
@@ -248,24 +248,38 @@ WallpaperUtil.setCustomWallpaperFromSyncFS = function(
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function() {
- chrome.wallpaperPrivate.setCustomWallpaper(
- reader.result,
- wallpaperLayout,
- true,
- wallpaperFilename,
- function(thumbnailData) {
- // TODO(ranj): Ignore 'canceledWallpaper' error.
- if (chrome.runtime.lastError) {
- console.error(chrome.runtime.lastError.message);
- return;
- }
- WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
- reader.result, Constants.WallpaperDirNameEnum.ORIGINAL);
- WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
- thumbnailData, Constants.WallpaperDirNameEnum.THUMBNAIL);
- if (onSuccess)
- onSuccess();
- });
+ Constants.WallpaperSyncStorage.get(
tbarzic 2016/02/02 20:59:38 pass the app name as a function param (as filename
xdai1 2016/02/04 01:46:33 Done.
+ Constants.AccessSyncThirdPartyAppName, function(items) {
+ var thirdPartyAppName = '';
+ if (items.hasOwnProperty(Constants.AccessSyncThirdPartyAppName))
+ thirdPartyAppName = items[Constants.AccessSyncThirdPartyAppName];
+ chrome.wallpaperPrivate.setCustomWallpaper(
+ reader.result,
+ wallpaperLayout,
+ true,
+ wallpaperFilename,
+ thirdPartyAppName,
+ function(thumbnailData) {
+ // TODO(ranj): Ignore 'canceledWallpaper' error.
+ if (chrome.runtime.lastError) {
+ console.error(chrome.runtime.lastError.message);
+ return;
+ }
+
+ // If it's a custom wallpaper (i.e., not set by a third party
+ // app), it should be stored into the local filesystem.
+ if (!thirdPartyAppName) {
+ WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
+ reader.result, Constants.WallpaperDirNameEnum.ORIGINAL);
+ WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename,
+ thumbnailData,
+ Constants.WallpaperDirNameEnum.THUMBNAIL);
+ WallpaperUtil.clearThirdPartyAppName();
tbarzic 2016/02/02 20:59:38 the correct value should already be set at this po
+ }
+ if (onSuccess)
+ onSuccess();
+ });
+ });
};
reader.readAsArrayBuffer(file);
}, WallpaperUtil.onFileSystemError);
@@ -276,6 +290,25 @@ 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);
+});
+};
+
+/**
+ * Clear the third party wallpaper app name from local & sync filesystem.
+ */
+WallpaperUtil.clearThirdPartyAppName = function() {
+ WallpaperUtil.saveThirdPartyAppName('');
+};
+
+/**
* 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 +414,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