Index: chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
index d91616bf96075d7a458a40ccde14853adcb5381b..161590c710dfb3e069f8197ee15c0b4fbf4710bf 100644 |
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
@@ -15,6 +15,7 @@ |
function WallpaperManager(dialogDom) { |
this.dialogDom_ = dialogDom; |
+ this.storage_ = chrome.storage.local; |
this.document_ = dialogDom.ownerDocument; |
this.selectedCategory = null; |
this.butterBar_ = new ButterBar(this.dialogDom_); |
@@ -40,6 +41,11 @@ function WallpaperManager(dialogDom) { |
/** @const */ var HighResolutionSuffix = '_high_resolution.jpg'; |
/** |
+ * Key to access wallpaper manifest in chrome.local.storage. |
+ */ |
+ /** @const */ var AccessManifestKey = 'wallpaper-picker-manifest-key'; |
+ |
+ /** |
* Returns a translated string. |
* |
* Wrapper function to make dealing with translated strings more concise. |
@@ -131,17 +137,21 @@ function WallpaperManager(dialogDom) { |
*/ |
WallpaperManager.prototype.onLoadManifestSuccess_ = function(manifest) { |
this.manifest_ = manifest; |
+ var items = {}; |
+ items[AccessManifestKey] = manifest; |
+ this.storage_.set(items, function() {}); |
this.initDom_(); |
}; |
- // Sets manifest to an empty object and shows connection error. Called after |
- // manifest failed to load. |
+ // Sets manifest to previously saved object if any and shows connection error. |
+ // Called after manifest failed to load. |
WallpaperManager.prototype.onLoadManifestFailed_ = function() { |
- // TODO(bshe): Fall back to saved manifest if there is a problem fetching |
- // manifest from server. |
- this.manifest_ = {}; |
- this.butterBar_.showError_(str('connectionFailed')); |
- this.initDom_(); |
+ var self = this; |
+ this.storage_.get(AccessManifestKey, function(items) { |
+ self.manifest_ = items[AccessManifestKey] ? items[AccessManifestKey] : {}; |
+ self.butterBar_.showError_(str('connectionFailed')); |
+ self.initDom_(); |
+ }); |
}; |
/** |