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

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

Issue 1631923004: Sync 3rd party wallpaper app name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address tbarzic@'s comments. 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 SurpriseWallpaper.getInstance().next(); 312 SurpriseWallpaper.getInstance().next();
313 } else { 313 } else {
314 SurpriseWallpaper.getInstance().disable(); 314 SurpriseWallpaper.getInstance().disable();
315 } 315 }
316 } 316 }
317 317
318 if (changes[Constants.AccessLocalWallpaperInfoKey]) { 318 if (changes[Constants.AccessLocalWallpaperInfoKey]) {
319 // If the old wallpaper is a third party wallpaper we should remove it 319 // If the old wallpaper is a third party wallpaper we should remove it
320 // from the local & sync file system to free space. 320 // from the local & sync file system to free space.
321 var oldInfo = changes[Constants.AccessLocalWallpaperInfoKey].oldValue; 321 var oldInfo = changes[Constants.AccessLocalWallpaperInfoKey].oldValue;
322 if (oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) { 322 if (oldInfo &&
323 oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) {
323 WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url); 324 WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url);
324 WallpaperUtil.deleteWallpaperFromSyncFS(oldInfo.url); 325 WallpaperUtil.deleteWallpaperFromSyncFS(oldInfo.url);
325 } 326 }
326 } 327 }
327 328
328 if (changes[Constants.AccessSyncWallpaperInfoKey]) { 329 if (changes[Constants.AccessSyncWallpaperInfoKey]) {
329 var syncInfo = changes[Constants.AccessSyncWallpaperInfoKey].newValue; 330 var syncInfo = changes[Constants.AccessSyncWallpaperInfoKey].newValue;
330 331
331 Constants.WallpaperSyncStorage.get( 332 Constants.WallpaperSyncStorage.get(
332 Constants.AccessSyncSurpriseMeEnabledKey, function(enabledItems) { 333 Constants.AccessSyncSurpriseMeEnabledKey, function(enabledItems) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // alarm invoked. 366 // alarm invoked.
366 WallpaperUtil.setOnlineWallpaper(syncInfo.url, 367 WallpaperUtil.setOnlineWallpaper(syncInfo.url,
367 syncInfo.layout, function() {}, function() {}); 368 syncInfo.layout, function() {}, function() {});
368 } else if (syncInfo.source == 369 } else if (syncInfo.source ==
369 Constants.WallpaperSourceEnum.Custom) { 370 Constants.WallpaperSourceEnum.Custom) {
370 WallpaperUtil.setCustomWallpaperFromSyncFS(syncInfo.url, 371 WallpaperUtil.setCustomWallpaperFromSyncFS(syncInfo.url,
371 syncInfo.layout); 372 syncInfo.layout);
372 } else if (syncInfo.source == 373 } else if (syncInfo.source ==
373 Constants.WallpaperSourceEnum.Default) { 374 Constants.WallpaperSourceEnum.Default) {
374 chrome.wallpaperPrivate.resetWallpaper(); 375 chrome.wallpaperPrivate.resetWallpaper();
376 WallpaperUtil.clearThirdPartyAppName();
375 } 377 }
376 378
377 // If the old wallpaper is a third party wallpaper we should 379 // If the old wallpaper is a third party wallpaper we should
378 // remove it from the local & sync file system to free space. 380 // remove it from the local & sync file system to free space.
379 if (localInfo && localInfo.url.indexOf( 381 if (localInfo && localInfo.url.indexOf(
380 Constants.ThirdPartyWallpaperPrefix) != -1) { 382 Constants.ThirdPartyWallpaperPrefix) != -1) {
381 WallpaperUtil.deleteWallpaperFromLocalFS(localInfo.url); 383 WallpaperUtil.deleteWallpaperFromLocalFS(localInfo.url);
382 WallpaperUtil.deleteWallpaperFromSyncFS(localInfo.url); 384 WallpaperUtil.deleteWallpaperFromSyncFS(localInfo.url);
383 } 385 }
384 386
(...skipping 17 matching lines...) Expand all
402 } 404 }
403 } 405 }
404 }); 406 });
405 }); 407 });
406 408
407 chrome.alarms.onAlarm.addListener(function() { 409 chrome.alarms.onAlarm.addListener(function() {
408 SurpriseWallpaper.getInstance().next(); 410 SurpriseWallpaper.getInstance().next();
409 }); 411 });
410 412
411 chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function( 413 chrome.wallpaperPrivate.onWallpaperChangedBy3rdParty.addListener(function(
412 wallpaper, thumbnail, layout) { 414 wallpaper, thumbnail, layout, appname) {
413 WallpaperUtil.saveToLocalStorage( 415 WallpaperUtil.saveToLocalStorage(
414 Constants.AccessLocalSurpriseMeEnabledKey, false, function() { 416 Constants.AccessLocalSurpriseMeEnabledKey, false, function() {
415 WallpaperUtil.saveToSyncStorage(Constants.AccessSyncSurpriseMeEnabledKey, 417 WallpaperUtil.saveToSyncStorage(Constants.AccessSyncSurpriseMeEnabledKey,
416 false); 418 false);
417 }); 419 });
418 SurpriseWallpaper.getInstance().disable(); 420 SurpriseWallpaper.getInstance().disable();
419 421
420 // Make third party wallpaper syncable through different devices. 422 // Make third party wallpaper syncable through different devices.
421 // TODO(xdai): also sync the third party app name.
422 var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime(); 423 var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime();
423 var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix; 424 var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix;
424 WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper); 425 WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper);
425 WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail); 426 WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail);
426 WallpaperUtil.saveWallpaperInfo(filename, layout, 427 WallpaperUtil.saveWallpaperInfo(filename, layout,
427 Constants.WallpaperSourceEnum.Custom); 428 Constants.WallpaperSourceEnum.Custom);
429 WallpaperUtil.saveThirdPartyAppName(appname);
428 }); 430 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698