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

Side by Side Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js

Issue 597503007: Sync current wallpaper (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var WALLPAPER_PICKER_WIDTH = 574; 5 var WALLPAPER_PICKER_WIDTH = 574;
6 var WALLPAPER_PICKER_HEIGHT = 420; 6 var WALLPAPER_PICKER_HEIGHT = 420;
7 7
8 var wallpaperPickerWindow; 8 var wallpaperPickerWindow;
9 9
10 var surpriseWallpaper = null; 10 var surpriseWallpaper = null;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 alphaEnabled: true 228 alphaEnabled: true
229 }, function(w) { 229 }, function(w) {
230 wallpaperPickerWindow = w; 230 wallpaperPickerWindow = w;
231 chrome.wallpaperPrivate.minimizeInactiveWindows(); 231 chrome.wallpaperPrivate.minimizeInactiveWindows();
232 w.onClosed.addListener(function() { 232 w.onClosed.addListener(function() {
233 chrome.wallpaperPrivate.restoreMinimizedWindows(); 233 chrome.wallpaperPrivate.restoreMinimizedWindows();
234 }); 234 });
235 }); 235 });
236 }); 236 });
237 237
238 chrome.syncFileSystem.onFileStatusChanged.addListener(function(detail) {
239 WallpaperUtil.enabledExperimentalFeatureCallback(function() {
240 if (detail.status == 'synced' &&
241 detail.direction == 'remote_to_local') {
242 if (detail.action == 'added') {
243 Constants.WallpaperLocalStorage.get(
244 Constants.AccessLocalWallpaperInfoKey,
245 function(items) {
246 var localData = items[Constants.AccessLocalWallpaperInfoKey];
247 if (localData && localData.url == detail.fileEntry.name &&
248 localData.source == Constants.WallpaperSourceEnum.Custom)
249 WallpaperUtil.setSyncCustomWallpaper(localData.url,
250 localData.layout);
251 });
252 }
253 }
254 });
255 });
256
238 chrome.storage.onChanged.addListener(function(changes, namespace) { 257 chrome.storage.onChanged.addListener(function(changes, namespace) {
258 WallpaperUtil.enabledExperimentalFeatureCallback(function() {
259 WallpaperUtil.requestSyncFs(function() {});
260 });
239 if (changes[Constants.AccessSurpriseMeEnabledKey]) { 261 if (changes[Constants.AccessSurpriseMeEnabledKey]) {
240 if (changes[Constants.AccessSurpriseMeEnabledKey].newValue) { 262 if (changes[Constants.AccessSurpriseMeEnabledKey].newValue) {
241 SurpriseWallpaper.getInstance().next(); 263 SurpriseWallpaper.getInstance().next();
242 } else { 264 } else {
243 SurpriseWallpaper.getInstance().disable(); 265 SurpriseWallpaper.getInstance().disable();
244 } 266 }
245 } 267 }
246 268
247 if (changes[Constants.AccessSyncWallpaperInfoKey]) { 269 if (changes[Constants.AccessSyncWallpaperInfoKey]) {
248 var newValue = changes[Constants.AccessSyncWallpaperInfoKey].newValue; 270 var newValue = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
249 Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey, 271 Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey,
250 function(items) { 272 function(items) {
251 // Normally, the wallpaper info saved in local storage and sync storage 273 // Normally, the wallpaper info saved in local storage and sync storage
252 // are the same. If the synced value changed by sync service, they may 274 // are the same. If the synced value changed by sync service, they may
253 // different. In that case, change wallpaper to the one saved in sync 275 // different. In that case, change wallpaper to the one saved in sync
254 // storage and update the local value. 276 // storage and update the local value.
255 var localValue = items[Constants.AccessLocalWallpaperInfoKey]; 277 var localValue = items[Constants.AccessLocalWallpaperInfoKey];
256 if (localValue == undefined || 278 if (localValue == undefined ||
257 localValue.url != newValue.url || 279 localValue.url != newValue.url ||
258 localValue.layout != newValue.layout || 280 localValue.layout != newValue.layout ||
259 localValue.source != newValue.source) { 281 localValue.source != newValue.source) {
260 if (newValue.source == Constants.WallpaperSourceEnum.Online) { 282 if (newValue.source == Constants.WallpaperSourceEnum.Online) {
261 // TODO(bshe): Consider schedule an alarm to set online wallpaper 283 // TODO(bshe): Consider schedule an alarm to set online wallpaper
262 // later when failed. Note that we need to cancel the retry if user 284 // later when failed. Note that we need to cancel the retry if user
263 // set another wallpaper before retry alarm invoked. 285 // set another wallpaper before retry alarm invoked.
264 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, 286 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout,
265 function() {}, function() {}); 287 function() {}, function() {});
288 } else if (newValue.source == Constants.WallpaperSourceEnum.Custom) {
289 WallpaperUtil.setSyncCustomWallpaper(newValue.url, newValue.layout);
266 } 290 }
267 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, 291 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey,
268 newValue, false); 292 newValue, false);
269 } 293 }
270 }); 294 });
271 } 295 }
272 }); 296 });
273 297
274 chrome.alarms.onAlarm.addListener(function() { 298 chrome.alarms.onAlarm.addListener(function() {
275 SurpriseWallpaper.getInstance().next(); 299 SurpriseWallpaper.getInstance().next();
276 }); 300 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698