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

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

Issue 11348215: Make wallpaper picker manifest and thumbnails available when offline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment nits Created 8 years, 1 month 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/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_();
+ });
};
/**

Powered by Google App Engine
This is Rietveld 408576698