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 f4f50ec4c60373f328088eb56c19b405714a979a..d083d3f0f9126b7e7c2e7f333ed9b710c365db58 100644 |
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js |
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/util.js |
@@ -54,7 +54,6 @@ WallpaperUtil.storeWallpaperFromSyncFSToLocalFS = function(wallpaperFileEntry) { |
var storeDir = Constants.WallpaperDirNameEnum.ORIGINAL; |
if (filenName.indexOf(Constants.CustomWallpaperThumbnailSuffix) != -1) |
storeDir = Constants.WallpaperDirNameEnum.THUMBNAIL; |
- filenName = filenName.replace(Constants.CustomWallpaperThumbnailSuffix, ''); |
wallpaperFileEntry.file(function(file) { |
var reader = new FileReader(); |
reader.onloadend = function() { |
@@ -89,7 +88,7 @@ WallpaperUtil.deleteWallpaperFromSyncFS = function(wallpaperFilename) { |
}; |
/** |
- * Run experimental features. |
+ * Executes callback if experimental flag is set to true. |
* @param {function} callback The callback will be executed if 'isExperimental' |
* flag is set to true. |
*/ |
@@ -107,19 +106,33 @@ WallpaperUtil.enabledExperimentalFeatureCallback = function(callback) { |
}; |
/** |
+ * Executes callback if sync theme is enabled. |
+ * @param {function} callback The callback will be executed if sync themes is |
+ * enabled. |
+ */ |
+WallpaperUtil.enabledSyncThemesCallback = function(callback) { |
+ chrome.wallpaperPrivate.getSyncSetting(function(setting) { |
+ if (setting.syncThemes) |
+ callback(); |
+ }); |
+}; |
+ |
+/** |
* Request a syncFileSystem handle and run callback on it. |
* @param {function} callback The callback to execute after syncFileSystem |
* handler is available. |
*/ |
WallpaperUtil.requestSyncFS = function(callback) { |
- if (WallpaperUtil.syncFs) { |
- callback(WallpaperUtil.syncFs); |
- } else { |
- chrome.syncFileSystem.requestFileSystem(function(fs) { |
- WallpaperUtil.syncFs = fs; |
+ WallpaperUtil.enabledSyncThemesCallback(function() { |
+ if (WallpaperUtil.syncFs) { |
callback(WallpaperUtil.syncFs); |
- }); |
- } |
+ } else { |
+ chrome.syncFileSystem.requestFileSystem(function(fs) { |
+ WallpaperUtil.syncFs = fs; |
+ callback(WallpaperUtil.syncFs); |
+ }); |
+ } |
+ }); |
}; |
/** |
@@ -156,7 +169,6 @@ WallpaperUtil.onFileSystemError = function(e) { |
* writing data. |
*/ |
WallpaperUtil.writeFile = function(fileEntry, wallpaperData, writeCallback) { |
- var uint8arr = new Uint8Array(wallpaperData); |
fileEntry.createWriter(function(fileWriter) { |
var blob = new Blob([new Int8Array(wallpaperData)]); |
fileWriter.write(blob); |
@@ -276,7 +288,9 @@ WallpaperUtil.saveToStorage = function(key, value, sync, opt_callback) { |
var items = {}; |
items[key] = value; |
if (sync) |
- Constants.WallpaperSyncStorage.set(items, opt_callback); |
+ WallpaperUtil.enabledSyncThemesCallback(function() { |
+ Constants.WallpaperSyncStorage.set(items, opt_callback); |
+ }); |
else |
Constants.WallpaperLocalStorage.set(items, opt_callback); |
}; |