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

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 enableSync(
239 function() {
240 chrome.syncFileSystem.onFileStatusChanged.addListener(function(detail) {
241 Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey,
242 function(items) {
243 var localData = items[Constants.AccessLocalWallpaperInfoKey];
244 if (localData &&
245 localData.source == Constants.WallpaperSourceEnum.Custom)
246 setWallpaperByName(localData.url, localData.layout);
bshe 2014/09/24 17:07:05 I think we should only set wallpaper if detail.st
Ran 2014/09/26 17:34:53 Done.
247 });
248 });
249 });
250
251 var globalSyncFs;
238 chrome.storage.onChanged.addListener(function(changes, namespace) { 252 chrome.storage.onChanged.addListener(function(changes, namespace) {
253 enableSync(function() {
254 //active syncFileSystem
255 chrome.syncFileSystem.requestFileSystem(function(fs) {globalSyncFs = fs;});
bshe 2014/09/24 17:07:05 We dont want to requestFileSystem each time storag
Ran 2014/09/26 17:34:53 Done.
256 });
239 if (changes[Constants.AccessSurpriseMeEnabledKey]) { 257 if (changes[Constants.AccessSurpriseMeEnabledKey]) {
240 if (changes[Constants.AccessSurpriseMeEnabledKey].newValue) { 258 if (changes[Constants.AccessSurpriseMeEnabledKey].newValue) {
241 SurpriseWallpaper.getInstance().next(); 259 SurpriseWallpaper.getInstance().next();
242 } else { 260 } else {
243 SurpriseWallpaper.getInstance().disable(); 261 SurpriseWallpaper.getInstance().disable();
244 } 262 }
245 } 263 }
246 264
247 if (changes[Constants.AccessSyncWallpaperInfoKey]) { 265 if (changes[Constants.AccessSyncWallpaperInfoKey]) {
248 var newValue = changes[Constants.AccessSyncWallpaperInfoKey].newValue; 266 var newValue = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
249 Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey, 267 Constants.WallpaperLocalStorage.get(Constants.AccessLocalWallpaperInfoKey,
250 function(items) { 268 function(items) {
251 // Normally, the wallpaper info saved in local storage and sync storage 269 // 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 270 // 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 271 // different. In that case, change wallpaper to the one saved in sync
254 // storage and update the local value. 272 // storage and update the local value.
255 var localValue = items[Constants.AccessLocalWallpaperInfoKey]; 273 var localValue = items[Constants.AccessLocalWallpaperInfoKey];
256 if (localValue == undefined || 274 if (localValue == undefined ||
257 localValue.url != newValue.url || 275 localValue.url != newValue.url ||
258 localValue.layout != newValue.layout || 276 localValue.layout != newValue.layout ||
259 localValue.source != newValue.source) { 277 localValue.source != newValue.source) {
260 if (newValue.source == Constants.WallpaperSourceEnum.Online) { 278 if (newValue.source == Constants.WallpaperSourceEnum.Online) {
261 // TODO(bshe): Consider schedule an alarm to set online wallpaper 279 // TODO(bshe): Consider schedule an alarm to set online wallpaper
262 // later when failed. Note that we need to cancel the retry if user 280 // later when failed. Note that we need to cancel the retry if user
263 // set another wallpaper before retry alarm invoked. 281 // set another wallpaper before retry alarm invoked.
264 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, 282 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout,
265 function() {}, function() {}); 283 function() {}, function() {});
266 } 284 }
285 if (newValue.source == Constants.WallpaperSourceEnum.Custom) {
bshe 2014/09/24 17:07:05 nit: use "else if" and move this line to previous
Ran 2014/09/26 17:34:53 Done.
286 setWallpaperByName(newValue.url, newValue.layout);
287 }
267 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, 288 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey,
268 newValue, false); 289 newValue, false);
269 } 290 }
270 }); 291 });
271 } 292 }
272 }); 293 });
273 294
274 chrome.alarms.onAlarm.addListener(function() { 295 chrome.alarms.onAlarm.addListener(function() {
275 SurpriseWallpaper.getInstance().next(); 296 SurpriseWallpaper.getInstance().next();
276 }); 297 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698