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

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

Issue 676403002: Sync wallpaper based on sync themes setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/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 f986347a79419de1bb325ff9808e68403a3e3f45..2a6b9a9581a57ba02b93673e5c4b7682039541d2 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js
@@ -237,78 +237,82 @@ chrome.app.runtime.onLaunched.addListener(function() {
});
chrome.syncFileSystem.onFileStatusChanged.addListener(function(detail) {
- WallpaperUtil.enabledExperimentalFeatureCallback(function() {
- if (detail.status == 'synced' &&
- detail.direction == 'remote_to_local') {
- if (detail.action == 'added') {
- Constants.WallpaperLocalStorage.get(
- Constants.AccessLocalWallpaperInfoKey,
- function(items) {
- var localData = items[Constants.AccessLocalWallpaperInfoKey];
- if (localData && localData.url == detail.fileEntry.name &&
- localData.source == Constants.WallpaperSourceEnum.Custom) {
- WallpaperUtil.setCustomWallpaperFromSyncFS(localData.url,
- localData.layout);
- } else if (localData.url !=
- detail.fileEntry.name.replace(
- Constants.CustomWallpaperThumbnailSuffix, '')) {
- WallpaperUtil.storeWallpaperFromSyncFSToLocalFS(
- detail.fileEntry);
- }
- });
- } else if (detail.action == 'deleted') {
- var fileName = detail.fileEntry.name.replace(
- Constants.CustomWallpaperThumbnailSuffix, '');
- WallpaperUtil.deleteWallpaperFromLocalFS(fileName);
+ WallpaperUtil.enabledSyncThemesCallback(function() {
+ WallpaperUtil.enabledExperimentalFeatureCallback(function() {
+ if (detail.status == 'synced' &&
+ detail.direction == 'remote_to_local') {
+ if (detail.action == 'added') {
+ Constants.WallpaperLocalStorage.get(
+ Constants.AccessLocalWallpaperInfoKey,
+ function(items) {
+ var localData = items[Constants.AccessLocalWallpaperInfoKey];
+ if (localData && localData.url == detail.fileEntry.name &&
+ localData.source == Constants.WallpaperSourceEnum.Custom) {
+ WallpaperUtil.setCustomWallpaperFromSyncFS(localData.url,
+ localData.layout);
+ } else if (localData.url !=
+ detail.fileEntry.name.replace(
+ Constants.CustomWallpaperThumbnailSuffix, '')) {
+ WallpaperUtil.storeWallpaperFromSyncFSToLocalFS(
+ detail.fileEntry);
+ }
+ });
+ } else if (detail.action == 'deleted') {
+ var fileName = detail.fileEntry.name.replace(
+ Constants.CustomWallpaperThumbnailSuffix, '');
+ WallpaperUtil.deleteWallpaperFromLocalFS(fileName);
+ }
}
- }
+ });
});
});
chrome.storage.onChanged.addListener(function(changes, namespace) {
- WallpaperUtil.enabledExperimentalFeatureCallback(function() {
- WallpaperUtil.requestSyncFS(function() {});
- });
- if (changes[Constants.AccessSurpriseMeEnabledKey]) {
- if (changes[Constants.AccessSurpriseMeEnabledKey].newValue) {
- SurpriseWallpaper.getInstance().next();
- } else {
- SurpriseWallpaper.getInstance().disable();
+ WallpaperUtil.enabledSyncThemesCallback(function() {
+ WallpaperUtil.enabledExperimentalFeatureCallback(function() {
+ WallpaperUtil.requestSyncFS(function() {});
+ });
+ if (changes[Constants.AccessSurpriseMeEnabledKey]) {
+ if (changes[Constants.AccessSurpriseMeEnabledKey].newValue) {
+ SurpriseWallpaper.getInstance().next();
+ } else {
+ SurpriseWallpaper.getInstance().disable();
+ }
}
- }
- if (changes[Constants.AccessSyncWallpaperInfoKey]) {
- var newValue = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
- Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey,
- function(items) {
- // Normally, the wallpaper info saved in local storage and sync storage
- // are the same. If the synced value changed by sync service, they may
- // different. In that case, change wallpaper to the one saved in sync
- // storage and update the local value.
- var localValue = items[Constants.AccessLocalWallpaperInfoKey];
- if (localValue == undefined ||
- localValue.url != newValue.url ||
- localValue.layout != newValue.layout ||
- localValue.source != newValue.source) {
- if (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() {});
- } else if (newValue.source == Constants.WallpaperSourceEnum.Custom) {
- WallpaperUtil.enabledExperimentalFeatureCallback(function() {
- WallpaperUtil.setCustomWallpaperFromSyncFS(newValue.url,
- newValue.layout);
- });
- } else if (newValue.source == Constants.WallpaperSourceEnum.Default) {
- chrome.wallpaperPrivate.resetWallpaper();
+ if (changes[Constants.AccessSyncWallpaperInfoKey]) {
+ var newValue = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
+ Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey,
+ function(items) {
+ // Normally, the wallpaper info saved in local storage and sync storage
+ // are the same. If the synced value changed by sync service, they may
+ // different. In that case, change wallpaper to the one saved in sync
+ // storage and update the local value.
+ var localValue = items[Constants.AccessLocalWallpaperInfoKey];
+ if (localValue == undefined ||
+ localValue.url != newValue.url ||
+ localValue.layout != newValue.layout ||
+ localValue.source != newValue.source) {
+ if (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() {});
+ } else if (newValue.source == Constants.WallpaperSourceEnum.Custom) {
+ WallpaperUtil.enabledExperimentalFeatureCallback(function() {
+ WallpaperUtil.setCustomWallpaperFromSyncFS(newValue.url,
+ newValue.layout);
+ });
+ } else if (newValue.source == Constants.WallpaperSourceEnum.Default) {
+ chrome.wallpaperPrivate.resetWallpaper();
+ }
+ WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey,
+ newValue, false);
}
- WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey,
- newValue, false);
- }
- });
- }
+ });
+ }
+ });
});
chrome.alarms.onAlarm.addListener(function() {

Powered by Google App Engine
This is Rietveld 408576698