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

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

Issue 1566713005: Make the third party wallpaper syncable through different devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // localData might be null on a powerwashed device. 289 // localData might be null on a powerwashed device.
290 WallpaperUtil.storeWallpaperFromSyncFSToLocalFS( 290 WallpaperUtil.storeWallpaperFromSyncFSToLocalFS(
291 detail.fileEntry); 291 detail.fileEntry);
292 } 292 }
293 }); 293 });
294 } else if (detail.action == 'deleted') { 294 } else if (detail.action == 'deleted') {
295 var fileName = detail.fileEntry.name.replace( 295 var fileName = detail.fileEntry.name.replace(
296 Constants.CustomWallpaperThumbnailSuffix, ''); 296 Constants.CustomWallpaperThumbnailSuffix, '');
297 WallpaperUtil.deleteWallpaperFromLocalFS(fileName); 297 WallpaperUtil.deleteWallpaperFromLocalFS(fileName);
298 } 298 }
299 } else { // detail.direction == 'local_to_remote'
bshe 2016/01/13 18:43:17 why do you want to remove this?
xdai1 2016/01/14 23:03:51 It's a different issue and it was introduced by me
bshe 2016/01/15 15:52:00 Acknowledged.
300 if (detail.action == 'deleted') {
301 WallpaperUtil.deleteWallpaperFromSyncFS(detail.fileEntry.name);
302 WallpaperUtil.deleteWallpaperFromLocalFS(detail.fileEntry.name);
303 }
304 } 299 }
305 } 300 }
306 }); 301 });
307 }); 302 });
308 303
309 chrome.storage.onChanged.addListener(function(changes, namespace) { 304 chrome.storage.onChanged.addListener(function(changes, namespace) {
310 WallpaperUtil.enabledSyncThemesCallback(function(syncEnabled) { 305 WallpaperUtil.enabledSyncThemesCallback(function(syncEnabled) {
311 if (syncEnabled) { 306 if (syncEnabled) {
312 // If sync theme is enabled, use values from chrome.storage.sync to sync 307 // If sync theme is enabled, use values from chrome.storage.sync to sync
313 // wallpaper changes. 308 // wallpaper changes.
314 WallpaperUtil.requestSyncFS(function() {}); 309 WallpaperUtil.requestSyncFS(function() {});
315 if (changes[Constants.AccessSyncSurpriseMeEnabledKey]) { 310 if (changes[Constants.AccessSyncSurpriseMeEnabledKey]) {
316 if (changes[Constants.AccessSyncSurpriseMeEnabledKey].newValue) { 311 if (changes[Constants.AccessSyncSurpriseMeEnabledKey].newValue) {
317 SurpriseWallpaper.getInstance().next(); 312 SurpriseWallpaper.getInstance().next();
318 } else { 313 } else {
319 SurpriseWallpaper.getInstance().disable(); 314 SurpriseWallpaper.getInstance().disable();
320 } 315 }
321 } 316 }
322 317
318 if (changes[Constants.AccessLocalWallpaperInfoKey]) {
319 // If the old wallpaper is a third party wallpaper we should remove it
320 // from the local & sync file system to free space.
321 var oldInfo = changes[Constants.AccessLocalWallpaperInfoKey].oldValue;
322 if (oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) {
323 WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url);
324 WallpaperUtil.deleteWallpaperFromSyncFS(oldInfo.url);
325 }
326 }
327
323 if (changes[Constants.AccessSyncWallpaperInfoKey]) { 328 if (changes[Constants.AccessSyncWallpaperInfoKey]) {
324 var syncInfo = changes[Constants.AccessSyncWallpaperInfoKey].newValue; 329 var syncInfo = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
325 330
326 Constants.WallpaperSyncStorage.get( 331 Constants.WallpaperSyncStorage.get(
327 Constants.AccessSyncSurpriseMeEnabledKey, function(enabledItems) { 332 Constants.AccessSyncSurpriseMeEnabledKey, function(enabledItems) {
328 var syncSurpriseMeEnabled = 333 var syncSurpriseMeEnabled =
329 enabledItems[Constants.AccessSyncSurpriseMeEnabledKey]; 334 enabledItems[Constants.AccessSyncSurpriseMeEnabledKey];
330 335
331 Constants.WallpaperSyncStorage.get( 336 Constants.WallpaperSyncStorage.get(
332 Constants.AccessLastSurpriseWallpaperChangedDate, 337 Constants.AccessLastSurpriseWallpaperChangedDate,
(...skipping 28 matching lines...) Expand all
361 WallpaperUtil.setOnlineWallpaper(syncInfo.url, 366 WallpaperUtil.setOnlineWallpaper(syncInfo.url,
362 syncInfo.layout, function() {}, function() {}); 367 syncInfo.layout, function() {}, function() {});
363 } else if (syncInfo.source == 368 } else if (syncInfo.source ==
364 Constants.WallpaperSourceEnum.Custom) { 369 Constants.WallpaperSourceEnum.Custom) {
365 WallpaperUtil.setCustomWallpaperFromSyncFS(syncInfo.url, 370 WallpaperUtil.setCustomWallpaperFromSyncFS(syncInfo.url,
366 syncInfo.layout); 371 syncInfo.layout);
367 } else if (syncInfo.source == 372 } else if (syncInfo.source ==
368 Constants.WallpaperSourceEnum.Default) { 373 Constants.WallpaperSourceEnum.Default) {
369 chrome.wallpaperPrivate.resetWallpaper(); 374 chrome.wallpaperPrivate.resetWallpaper();
370 } 375 }
376
377 // If the old wallpaper is a third party wallpaper we should
378 // remove it from the local & sync file system to free space.
379 if (localInfo && localInfo.url.indexOf(
380 Constants.ThirdPartyWallpaperPrefix) != -1) {
381 WallpaperUtil.deleteWallpaperFromLocalFS(localInfo.url);
382 WallpaperUtil.deleteWallpaperFromSyncFS(localInfo.url);
383 }
384
371 WallpaperUtil.saveToLocalStorage( 385 WallpaperUtil.saveToLocalStorage(
372 Constants.AccessLocalWallpaperInfoKey, syncInfo); 386 Constants.AccessLocalWallpaperInfoKey, syncInfo);
373 } 387 }
374 }); 388 });
375 } 389 }
376 }); 390 });
377 }); 391 });
378 } 392 }
379 } else { 393 } else {
380 // If sync theme is disabled, use values from chrome.storage.local to 394 // If sync theme is disabled, use values from chrome.storage.local to
381 // track wallpaper changes. 395 // track wallpaper changes.
382 if (changes[Constants.AccessLocalSurpriseMeEnabledKey]) { 396 if (changes[Constants.AccessLocalSurpriseMeEnabledKey]) {
383 if (changes[Constants.AccessLocalSurpriseMeEnabledKey].newValue) { 397 if (changes[Constants.AccessLocalSurpriseMeEnabledKey].newValue) {
384 SurpriseWallpaper.getInstance().next(); 398 SurpriseWallpaper.getInstance().next();
385 } else { 399 } else {
386 SurpriseWallpaper.getInstance().disable(); 400 SurpriseWallpaper.getInstance().disable();
387 } 401 }
388 } 402 }
389 } 403 }
390 }); 404 });
391 }); 405 });
392 406
393 chrome.alarms.onAlarm.addListener(function() { 407 chrome.alarms.onAlarm.addListener(function() {
394 SurpriseWallpaper.getInstance().next(); 408 SurpriseWallpaper.getInstance().next();
395 }); 409 });
396 410
397 chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function() { 411 chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function(
412 wallpaper, thumbnail, layout) {
398 WallpaperUtil.saveToLocalStorage( 413 WallpaperUtil.saveToLocalStorage(
399 Constants.AccessLocalSurpriseMeEnabledKey, false, function() { 414 Constants.AccessLocalSurpriseMeEnabledKey, false, function() {
400 WallpaperUtil.saveToSyncStorage(Constants.AccessSyncSurpriseMeEnabledKey, 415 WallpaperUtil.saveToSyncStorage(Constants.AccessSyncSurpriseMeEnabledKey,
401 false); 416 false);
402 }); 417 });
403 SurpriseWallpaper.getInstance().disable(); 418 SurpriseWallpaper.getInstance().disable();
419
420 // Make third party wallpaper syncable through different devices.
421 var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime();
bshe 2016/01/08 19:56:39 We dont need a history of 3rd party wallpapers. Pe
xdai1 2016/01/08 20:17:48 No, I'm afraid we can't use the same file name for
422 var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix;
423 WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper);
424 WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail);
bshe 2016/01/13 18:43:17 why do we want thumbnail for 3rd party wallpaper?
xdai1 2016/01/14 23:03:51 You're right. Ideally we should not show the third
bshe 2016/01/15 15:52:00 I might not understand you correctly, But the 3rd
425 WallpaperUtil.saveWallpaperInfo(filename, layout,
426 Constants.WallpaperSourceEnum.Custom);
404 }); 427 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698