| 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 /** | 5 /** |
| 6 * WallpaperManager constructor. | 6 * WallpaperManager constructor. |
| 7 * | 7 * |
| 8 * WallpaperManager objects encapsulate the functionality of the wallpaper | 8 * WallpaperManager objects encapsulate the functionality of the wallpaper |
| 9 * manager extension. | 9 * manager extension. |
| 10 * | 10 * |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 i18nTemplate.process(this.document_, loadTimeData); | 278 i18nTemplate.process(this.document_, loadTimeData); |
| 279 this.initCategoriesList_(); | 279 this.initCategoriesList_(); |
| 280 this.initThumbnailsGrid_(); | 280 this.initThumbnailsGrid_(); |
| 281 this.presetCategory_(); | 281 this.presetCategory_(); |
| 282 | 282 |
| 283 $('file-selector').addEventListener( | 283 $('file-selector').addEventListener( |
| 284 'change', this.onFileSelectorChanged_.bind(this)); | 284 'change', this.onFileSelectorChanged_.bind(this)); |
| 285 $('set-wallpaper-layout').addEventListener( | 285 $('set-wallpaper-layout').addEventListener( |
| 286 'change', this.onWallpaperLayoutChanged_.bind(this)); | 286 'change', this.onWallpaperLayoutChanged_.bind(this)); |
| 287 | 287 |
| 288 if (loadTimeData.valueExists('wallpaperAppName')) { | |
| 289 $('wallpaper-set-by-message').textContent = loadTimeData.getStringF( | |
| 290 'currentWallpaperSetByMessage', str('wallpaperAppName')); | |
| 291 $('wallpaper-grid').classList.add('small'); | |
| 292 } else { | |
| 293 $('wallpaper-grid').classList.remove('small'); | |
| 294 } | |
| 295 | |
| 296 if (this.enableOnlineWallpaper_) { | 288 if (this.enableOnlineWallpaper_) { |
| 297 var self = this; | 289 var self = this; |
| 298 self.document_.body.setAttribute('surprise-me-disabled', ''); | 290 self.document_.body.setAttribute('surprise-me-disabled', ''); |
| 299 $('surprise-me').hidden = false; | 291 $('surprise-me').hidden = false; |
| 300 $('surprise-me').addEventListener('click', | 292 $('surprise-me').addEventListener('click', |
| 301 this.toggleSurpriseMe_.bind(this)); | 293 this.toggleSurpriseMe_.bind(this)); |
| 302 var onSurpriseMeEnabled = function() { | 294 var onSurpriseMeEnabled = function() { |
| 303 $('surprise-me').querySelector('#checkbox').classList.add('checked'); | 295 $('surprise-me').querySelector('#checkbox').classList.add('checked'); |
| 304 $('categories-list').disabled = true; | 296 $('categories-list').disabled = true; |
| 305 $('wallpaper-grid').disabled = true; | 297 $('wallpaper-grid').disabled = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 326 WallpaperUtil.saveToSyncStorage( | 318 WallpaperUtil.saveToSyncStorage( |
| 327 Constants.AccessSyncSurpriseMeEnabledKey, | 319 Constants.AccessSyncSurpriseMeEnabledKey, |
| 328 items[Constants.AccessLocalSurpriseMeEnabledKey]); | 320 items[Constants.AccessLocalSurpriseMeEnabledKey]); |
| 329 if (items[Constants.AccessLocalSurpriseMeEnabledKey]) { | 321 if (items[Constants.AccessLocalSurpriseMeEnabledKey]) { |
| 330 onSurpriseMeEnabled(); | 322 onSurpriseMeEnabled(); |
| 331 } | 323 } |
| 332 } | 324 } |
| 333 }); | 325 }); |
| 334 } | 326 } |
| 335 }); | 327 }); |
| 328 |
| 329 // Prefer Third party app name from sync filesystem, but if sync theme |
| 330 // is disabled, use the value from local filesystem. |
| 331 Constants.WallpaperSyncStorage.get( |
| 332 Constants.AccessSyncThirdPartyAppName, function(items) { |
| 333 if (items.hasOwnProperty(Constants.AccessSyncThirdPartyAppName) && |
| 334 items[Constants.AccessSyncThirdPartyAppName]) { |
| 335 $('wallpaper-set-by-message').textContent = |
| 336 loadTimeData.getStringF('currentWallpaperSetByMessage', |
| 337 items[Constants.AccessSyncThirdPartyAppName]); |
| 338 $('wallpaper-grid').classList.add('small'); |
| 339 } else { |
| 340 $('wallpaper-grid').classList.remove('small'); |
| 341 } |
| 342 }); |
| 343 |
| 336 } else { | 344 } else { |
| 337 Constants.WallpaperLocalStorage.get( | 345 Constants.WallpaperLocalStorage.get( |
| 338 Constants.AccessLocalSurpriseMeEnabledKey, function(items) { | 346 Constants.AccessLocalSurpriseMeEnabledKey, function(items) { |
| 339 if (items.hasOwnProperty( | 347 if (items.hasOwnProperty( |
| 340 Constants.AccessLocalSurpriseMeEnabledKey)) { | 348 Constants.AccessLocalSurpriseMeEnabledKey)) { |
| 341 if (items[Constants.AccessLocalSurpriseMeEnabledKey]) { | 349 if (items[Constants.AccessLocalSurpriseMeEnabledKey]) { |
| 342 onSurpriseMeEnabled(); | 350 onSurpriseMeEnabled(); |
| 343 } | 351 } |
| 344 } | 352 } |
| 345 }); | 353 }); |
| 354 |
| 355 Constants.WallpaperLocalStorage.get( |
| 356 Constants.AccessLocalThirdPartyAppName, function(items) { |
| 357 if (items.hasOwnProperty(Constants.AccessLocalThirdPartyAppName) && |
| 358 items[Constants.AccessLocalThirdPartyAppName]) { |
| 359 $('wallpaper-set-by-message').textContent = |
| 360 loadTimeData.getStringF('currentWallpaperSetByMessage', |
| 361 items[Constants.AccessLocalThirdPartyAppName]); |
| 362 $('wallpaper-grid').classList.add('small'); |
| 363 } else { |
| 364 $('wallpaper-grid').classList.remove('small'); |
| 365 } |
| 366 }); |
| 346 } | 367 } |
| 347 }); | 368 }); |
| 348 | 369 |
| 349 window.addEventListener('offline', function() { | 370 window.addEventListener('offline', function() { |
| 350 chrome.wallpaperPrivate.getOfflineWallpaperList(function(lists) { | 371 chrome.wallpaperPrivate.getOfflineWallpaperList(function(lists) { |
| 351 if (!self.downloadedListMap_) | 372 if (!self.downloadedListMap_) |
| 352 self.downloadedListMap_ = {}; | 373 self.downloadedListMap_ = {}; |
| 353 for (var i = 0; i < lists.length; i++) { | 374 for (var i = 0; i < lists.length; i++) { |
| 354 self.downloadedListMap_[lists[i]] = true; | 375 self.downloadedListMap_[lists[i]] = true; |
| 355 } | 376 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 * @param {?string} currentWallpaperURL The URL or filename of current | 565 * @param {?string} currentWallpaperURL The URL or filename of current |
| 545 * wallpaper. | 566 * wallpaper. |
| 546 */ | 567 */ |
| 547 WallpaperManager.prototype.onWallpaperChanged_ = function( | 568 WallpaperManager.prototype.onWallpaperChanged_ = function( |
| 548 activeItem, currentWallpaperURL) { | 569 activeItem, currentWallpaperURL) { |
| 549 this.wallpaperGrid_.activeItem = activeItem; | 570 this.wallpaperGrid_.activeItem = activeItem; |
| 550 this.currentWallpaper_ = currentWallpaperURL; | 571 this.currentWallpaper_ = currentWallpaperURL; |
| 551 // Hides the wallpaper set by message. | 572 // Hides the wallpaper set by message. |
| 552 $('wallpaper-set-by-message').textContent = ''; | 573 $('wallpaper-set-by-message').textContent = ''; |
| 553 $('wallpaper-grid').classList.remove('small'); | 574 $('wallpaper-grid').classList.remove('small'); |
| 575 // If the user manually selects a wallpaper from the built-in wallpaper |
| 576 // picker app, we should clear the third party app name if possible. |
| 577 WallpaperUtil.clearThirdPartyAppName(); |
| 554 }; | 578 }; |
| 555 | 579 |
| 556 /** | 580 /** |
| 557 * Sets wallpaper to the corresponding wallpaper of selected thumbnail. | 581 * Sets wallpaper to the corresponding wallpaper of selected thumbnail. |
| 558 * @param {{baseURL: string, layout: string, source: string, | 582 * @param {{baseURL: string, layout: string, source: string, |
| 559 * availableOffline: boolean, opt_dynamicURL: string, | 583 * availableOffline: boolean, opt_dynamicURL: string, |
| 560 * opt_author: string, opt_authorWebsite: string}} | 584 * opt_author: string, opt_authorWebsite: string}} |
| 561 * selectedItem the selected item in WallpaperThumbnailsGrid's data | 585 * selectedItem the selected item in WallpaperThumbnailsGrid's data |
| 562 * model. | 586 * model. |
| 563 */ | 587 */ |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 } | 1149 } |
| 1126 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 1150 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
| 1127 if (selectedItem) { | 1151 if (selectedItem) { |
| 1128 this.wallpaperGrid_.selectedItem = selectedItem; | 1152 this.wallpaperGrid_.selectedItem = selectedItem; |
| 1129 this.wallpaperGrid_.activeItem = selectedItem; | 1153 this.wallpaperGrid_.activeItem = selectedItem; |
| 1130 } | 1154 } |
| 1131 } | 1155 } |
| 1132 }; | 1156 }; |
| 1133 | 1157 |
| 1134 })(); | 1158 })(); |
| OLD | NEW |