Chromium Code Reviews| 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')) { | 288 // Always prefer the value from local filesystem to avoid the time window |
| 289 $('wallpaper-set-by-message').textContent = loadTimeData.getStringF( | 289 // of setting the third party app name and the third party wallpaper. |
| 290 'currentWallpaperSetByMessage', str('wallpaperAppName')); | 290 var getThirdPartyAppName = function(callback) { |
| 291 $('wallpaper-grid').classList.add('small'); | 291 Constants.WallpaperLocalStorage.get( |
| 292 } else { | 292 Constants.AccessLocalThirdPartyAppName, function(items) { |
| 293 $('wallpaper-grid').classList.remove('small'); | 293 if (items.hasOwnProperty(Constants.AccessLocalThirdPartyAppName)) |
| 294 } | 294 callback(items[Constants.AccessLocalThirdPartyAppName]); |
| 295 else if (loadTimeData.valueExists('wallpaperAppName')) | |
| 296 callback(str('wallpaperAppName')); | |
| 297 else | |
| 298 callback(''); | |
| 299 }); | |
| 300 }; | |
| 301 | |
| 302 getThirdPartyAppName(function(appName) { | |
| 303 if (!!appName) { | |
| 304 $('wallpaper-set-by-message').textContent = loadTimeData.getStringF( | |
| 305 'currentWallpaperSetByMessage', appName); | |
| 306 $('wallpaper-grid').classList.add('small'); | |
| 307 } else { | |
| 308 $('wallpaper-grid').classList.remove('small'); | |
| 309 } | |
| 310 }); | |
| 295 | 311 |
| 296 if (this.enableOnlineWallpaper_) { | 312 if (this.enableOnlineWallpaper_) { |
| 297 var self = this; | 313 var self = this; |
| 298 self.document_.body.setAttribute('surprise-me-disabled', ''); | 314 self.document_.body.setAttribute('surprise-me-disabled', ''); |
| 299 $('surprise-me').hidden = false; | 315 $('surprise-me').hidden = false; |
| 300 $('surprise-me').addEventListener('click', | 316 $('surprise-me').addEventListener('click', |
| 301 this.toggleSurpriseMe_.bind(this)); | 317 this.toggleSurpriseMe_.bind(this)); |
| 302 var onSurpriseMeEnabled = function() { | 318 var onSurpriseMeEnabled = function() { |
| 303 $('surprise-me').querySelector('#checkbox').classList.add('checked'); | 319 $('surprise-me').querySelector('#checkbox').classList.add('checked'); |
| 304 $('categories-list').disabled = true; | 320 $('categories-list').disabled = true; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 * @param {?string} currentWallpaperURL The URL or filename of current | 560 * @param {?string} currentWallpaperURL The URL or filename of current |
| 545 * wallpaper. | 561 * wallpaper. |
| 546 */ | 562 */ |
| 547 WallpaperManager.prototype.onWallpaperChanged_ = function( | 563 WallpaperManager.prototype.onWallpaperChanged_ = function( |
| 548 activeItem, currentWallpaperURL) { | 564 activeItem, currentWallpaperURL) { |
| 549 this.wallpaperGrid_.activeItem = activeItem; | 565 this.wallpaperGrid_.activeItem = activeItem; |
| 550 this.currentWallpaper_ = currentWallpaperURL; | 566 this.currentWallpaper_ = currentWallpaperURL; |
| 551 // Hides the wallpaper set by message. | 567 // Hides the wallpaper set by message. |
| 552 $('wallpaper-set-by-message').textContent = ''; | 568 $('wallpaper-set-by-message').textContent = ''; |
| 553 $('wallpaper-grid').classList.remove('small'); | 569 $('wallpaper-grid').classList.remove('small'); |
| 570 // If the user manually selects a wallpaper from the built-in wallpaper | |
| 571 // picker app, third party app name should be cleared. | |
| 572 WallpaperUtil.clearThirdPartyAppName(); | |
|
tbarzic
2016/02/02 20:59:38
you should do this only when the rest of wallpaper
| |
| 554 }; | 573 }; |
| 555 | 574 |
| 556 /** | 575 /** |
| 557 * Sets wallpaper to the corresponding wallpaper of selected thumbnail. | 576 * Sets wallpaper to the corresponding wallpaper of selected thumbnail. |
| 558 * @param {{baseURL: string, layout: string, source: string, | 577 * @param {{baseURL: string, layout: string, source: string, |
| 559 * availableOffline: boolean, opt_dynamicURL: string, | 578 * availableOffline: boolean, opt_dynamicURL: string, |
| 560 * opt_author: string, opt_authorWebsite: string}} | 579 * opt_author: string, opt_authorWebsite: string}} |
| 561 * selectedItem the selected item in WallpaperThumbnailsGrid's data | 580 * selectedItem the selected item in WallpaperThumbnailsGrid's data |
| 562 * model. | 581 * model. |
| 563 */ | 582 */ |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1125 } | 1144 } |
| 1126 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 1145 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
| 1127 if (selectedItem) { | 1146 if (selectedItem) { |
| 1128 this.wallpaperGrid_.selectedItem = selectedItem; | 1147 this.wallpaperGrid_.selectedItem = selectedItem; |
| 1129 this.wallpaperGrid_.activeItem = selectedItem; | 1148 this.wallpaperGrid_.activeItem = selectedItem; |
| 1130 } | 1149 } |
| 1131 } | 1150 } |
| 1132 }; | 1151 }; |
| 1133 | 1152 |
| 1134 })(); | 1153 })(); |
| OLD | NEW |