| OLD | NEW |
| 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 = null; | 8 var wallpaperPickerWindow = null; |
| 9 | 9 |
| 10 var surpriseWallpaper = null; | 10 var surpriseWallpaper = null; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 var wpDocument = wallpaperPickerWindow.contentWindow.document; | 327 var wpDocument = wallpaperPickerWindow.contentWindow.document; |
| 328 if (!!appName) { | 328 if (!!appName) { |
| 329 chrome.wallpaperPrivate.getStrings(function(strings) { | 329 chrome.wallpaperPrivate.getStrings(function(strings) { |
| 330 var message = | 330 var message = |
| 331 strings.currentWallpaperSetByMessage.replace(/\$1/g, appName); | 331 strings.currentWallpaperSetByMessage.replace(/\$1/g, appName); |
| 332 wpDocument.querySelector('#wallpaper-set-by-message').textContent = | 332 wpDocument.querySelector('#wallpaper-set-by-message').textContent = |
| 333 message; | 333 message; |
| 334 wpDocument.querySelector('#wallpaper-grid').classList.add('small'); | 334 wpDocument.querySelector('#wallpaper-grid').classList.add('small'); |
| 335 if (wpDocument.querySelector('.check')) | 335 if (wpDocument.querySelector('.check')) |
| 336 wpDocument.querySelector('.check').style.visibility = 'hidden'; | 336 wpDocument.querySelector('.check').style.visibility = 'hidden'; |
| 337 wpDocument.querySelector('#checkbox').classList.remove('checked'); |
| 338 wpDocument.querySelector('#categories-list').disabled = false; |
| 339 wpDocument.querySelector('#wallpaper-grid').disabled = false; |
| 337 }); | 340 }); |
| 338 } else { | 341 } else { |
| 339 wpDocument.querySelector('#wallpaper-set-by-message').textContent = | 342 wpDocument.querySelector('#wallpaper-set-by-message').textContent = |
| 340 ''; | 343 ''; |
| 341 wpDocument.querySelector('#wallpaper-grid').classList.remove('small'); | 344 wpDocument.querySelector('#wallpaper-grid').classList.remove('small'); |
| 342 wpDocument.querySelector('.check').style.visibility = 'visible'; | 345 Constants.WallpaperSyncStorage.get( |
| 346 Constants.AccessSyncSurpriseMeEnabledKey, function(item) { |
| 347 var enable = item[Constants.AccessSyncSurpriseMeEnabledKey]; |
| 348 if (enable) { |
| 349 wpDocument.querySelector('#checkbox').classList.add('checked'); |
| 350 if (wpDocument.querySelector('.check')) |
| 351 wpDocument.querySelector('.check').style.visibility = 'hidden'; |
| 352 } else { |
| 353 wpDocument.querySelector('#checkbox').classList.remove('checked'); |
| 354 if (wpDocument.querySelector('.check')) |
| 355 wpDocument.querySelector('.check').style.visibility = 'visible'; |
| 356 } |
| 357 wpDocument.querySelector('#categories-list').disabled = enable; |
| 358 wpDocument.querySelector('#wallpaper-grid').disabled = enable; |
| 359 }); |
| 343 } | 360 } |
| 344 }; | 361 }; |
| 345 | 362 |
| 346 if (changes[Constants.AccessLocalWallpaperInfoKey]) { | 363 if (changes[Constants.AccessLocalWallpaperInfoKey]) { |
| 347 // If the old wallpaper is a third party wallpaper we should remove it | 364 // If the old wallpaper is a third party wallpaper we should remove it |
| 348 // from the local & sync file system to free space. | 365 // from the local & sync file system to free space. |
| 349 var oldInfo = changes[Constants.AccessLocalWallpaperInfoKey].oldValue; | 366 var oldInfo = changes[Constants.AccessLocalWallpaperInfoKey].oldValue; |
| 350 if (oldInfo && | 367 if (oldInfo && |
| 351 oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) { | 368 oldInfo.url.indexOf(Constants.ThirdPartyWallpaperPrefix) != -1) { |
| 352 WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url); | 369 WallpaperUtil.deleteWallpaperFromLocalFS(oldInfo.url); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 SurpriseWallpaper.getInstance().disable(); | 471 SurpriseWallpaper.getInstance().disable(); |
| 455 | 472 |
| 456 // Make third party wallpaper syncable through different devices. | 473 // Make third party wallpaper syncable through different devices. |
| 457 var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime(); | 474 var filename = Constants.ThirdPartyWallpaperPrefix + new Date().getTime(); |
| 458 var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix; | 475 var thumbnailFilename = filename + Constants.CustomWallpaperThumbnailSuffix; |
| 459 WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper); | 476 WallpaperUtil.storeWallpaperToSyncFS(filename, wallpaper); |
| 460 WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail); | 477 WallpaperUtil.storeWallpaperToSyncFS(thumbnailFilename, thumbnail); |
| 461 WallpaperUtil.saveWallpaperInfo( | 478 WallpaperUtil.saveWallpaperInfo( |
| 462 filename, layout, Constants.WallpaperSourceEnum.Custom, appName); | 479 filename, layout, Constants.WallpaperSourceEnum.Custom, appName); |
| 463 }); | 480 }); |
| OLD | NEW |