Index: chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js |
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js |
index b069aa472cba0b266a53e357d22b9b39ba7bfa3f..0271fb0f9dd99e91ae9be085bbd1815570618fb8 100644 |
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js |
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js |
@@ -36,8 +36,8 @@ SurpriseWallpaper.prototype.tryChangeWallpaper = function() { |
// Try to fetch newest rss as document from server first. If any error occurs, |
// proceed with local copy of rss. |
WallpaperUtil.fetchURL(Constants.WallpaperRssURL, 'document', function(xhr) { |
- WallpaperUtil.saveToLocalStorage(Constants.AccessRssKey, |
- new XMLSerializer().serializeToString(xhr.responseXML)); |
+ WallpaperUtil.saveToStorage(Constants.AccessRssKey, |
+ new XMLSerializer().serializeToString(xhr.responseXML), false); |
self.updateSurpriseWallpaper(xhr.responseXML); |
}, onFailure); |
}; |
@@ -139,8 +139,10 @@ SurpriseWallpaper.prototype.setRandomWallpaper_ = function(dateString) { |
var wallpaper = manifest.wallpaper_list[index]; |
var wallpaperURL = wallpaper.base_url + Constants.HighResolutionSuffix; |
var onSuccess = function() { |
- WallpaperUtil.saveToLocalStorage( |
- Constants.AccessLastSurpriseWallpaperChangedDate, dateString); |
+ WallpaperUtil.saveToStorage( |
+ Constants.AccessLastSurpriseWallpaperChangedDate, |
+ dateString, |
+ false); |
} |
WallpaperUtil.setOnlineWallpaper(wallpaperURL, wallpaper.default_layout, |
onSuccess, self.retryLater_.bind(self)); |
@@ -180,8 +182,8 @@ SurpriseWallpaper.prototype.setWallpaperFromRssItem_ = function(item, |
SurpriseWallpaper.prototype.disable = function() { |
chrome.alarms.clearAll(); |
// Makes last changed date invalid. |
- WallpaperUtil.saveToLocalStorage( |
- Constants.AccessLastSurpriseWallpaperChangedDate, ''); |
+ WallpaperUtil.saveToStorage(Constants.AccessLastSurpriseWallpaperChangedDate, |
+ '', false); |
}; |
/** |
@@ -236,6 +238,18 @@ chrome.storage.onChanged.addListener(function(changes, namespace) { |
} else { |
SurpriseWallpaper.getInstance().disable(); |
} |
+ } else if (changes[Constants.AccessWallpaperInfoKey]) { |
flackr
2013/04/26 03:51:16
This shouldn't be else if, just if. Both keys may
bshe
2013/04/26 16:56:51
Done.
|
+ var newValue = changes[Constants.AccessWallpaperInfoKey].newValue; |
+ var oldValue = changes[Constants.AccessWallpaperInfoKey].oldValue; |
+ // oldValue equals undefined indicate that sync just happened. |
+ if (oldValue == undefined && |
flackr
2013/04/26 03:51:16
Why only if oldValue is undefined? I think it woul
bshe
2013/04/26 16:56:51
You are right. It doesn't handle the case you ment
|
+ newValue.source == Constants.WallpaperSourceEnum.Online) { |
+ // TODO(bshe): Consider schedule an alarm to set online wallpaper later |
+ // when failed. Note that we need to cancel the retry if user set another |
+ // wallpaper before retry alarm invoked. |
+ WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, |
+ function() {}, function() {}); |
+ } |
} |
}); |