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

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

Issue 1631923004: Sync 3rd party wallpaper app name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 /** 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
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 use the value from local filesystem to avoid the time window of
tbarzic 2016/01/28 20:10:48 I don't think you can get rid of this yet. You can
xdai1 2016/02/02 01:19:42 Done.
289 $('wallpaper-set-by-message').textContent = loadTimeData.getStringF( 289 // setting the third party app name and the third party wallpaper.
290 'currentWallpaperSetByMessage', str('wallpaperAppName')); 290 Constants.WallpaperLocalStorage.get(
291 $('wallpaper-grid').classList.add('small'); 291 Constants.AccessLocalThirdPartyAppName, function(items) {
292 } else { 292 if (items.hasOwnProperty(Constants.AccessLocalThirdPartyAppName) &&
293 $('wallpaper-grid').classList.remove('small'); 293 items[Constants.AccessLocalThirdPartyAppName]) {
294 } 294 $('wallpaper-set-by-message').textContent =
295 loadTimeData.getStringF('currentWallpaperSetByMessage',
296 items[Constants.AccessLocalThirdPartyAppName]);
297 $('wallpaper-grid').classList.add('small');
298 } else {
299 $('wallpaper-grid').classList.remove('small');
300 }
301 });
tbarzic 2016/01/28 20:10:48 Maybe add listener to local storage to update the
xdai1 2016/02/02 01:19:42 Will do it in a following CL.
295 302
296 if (this.enableOnlineWallpaper_) { 303 if (this.enableOnlineWallpaper_) {
297 var self = this; 304 var self = this;
298 self.document_.body.setAttribute('surprise-me-disabled', ''); 305 self.document_.body.setAttribute('surprise-me-disabled', '');
299 $('surprise-me').hidden = false; 306 $('surprise-me').hidden = false;
300 $('surprise-me').addEventListener('click', 307 $('surprise-me').addEventListener('click',
301 this.toggleSurpriseMe_.bind(this)); 308 this.toggleSurpriseMe_.bind(this));
302 var onSurpriseMeEnabled = function() { 309 var onSurpriseMeEnabled = function() {
303 $('surprise-me').querySelector('#checkbox').classList.add('checked'); 310 $('surprise-me').querySelector('#checkbox').classList.add('checked');
304 $('categories-list').disabled = true; 311 $('categories-list').disabled = true;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 * @param {?string} currentWallpaperURL The URL or filename of current 551 * @param {?string} currentWallpaperURL The URL or filename of current
545 * wallpaper. 552 * wallpaper.
546 */ 553 */
547 WallpaperManager.prototype.onWallpaperChanged_ = function( 554 WallpaperManager.prototype.onWallpaperChanged_ = function(
548 activeItem, currentWallpaperURL) { 555 activeItem, currentWallpaperURL) {
549 this.wallpaperGrid_.activeItem = activeItem; 556 this.wallpaperGrid_.activeItem = activeItem;
550 this.currentWallpaper_ = currentWallpaperURL; 557 this.currentWallpaper_ = currentWallpaperURL;
551 // Hides the wallpaper set by message. 558 // Hides the wallpaper set by message.
552 $('wallpaper-set-by-message').textContent = ''; 559 $('wallpaper-set-by-message').textContent = '';
553 $('wallpaper-grid').classList.remove('small'); 560 $('wallpaper-grid').classList.remove('small');
561 // If the user manually selects a wallpaper from the built-in wallpaper
562 // picker app, we should clear the third party app name if possible.
tbarzic 2016/01/28 20:10:48 nit: remove "if possible" from the comment. Also,
xdai1 2016/02/02 01:19:42 Done.
563 WallpaperUtil.clearThirdPartyAppName();
554 }; 564 };
555 565
556 /** 566 /**
557 * Sets wallpaper to the corresponding wallpaper of selected thumbnail. 567 * Sets wallpaper to the corresponding wallpaper of selected thumbnail.
558 * @param {{baseURL: string, layout: string, source: string, 568 * @param {{baseURL: string, layout: string, source: string,
559 * availableOffline: boolean, opt_dynamicURL: string, 569 * availableOffline: boolean, opt_dynamicURL: string,
560 * opt_author: string, opt_authorWebsite: string}} 570 * opt_author: string, opt_authorWebsite: string}}
561 * selectedItem the selected item in WallpaperThumbnailsGrid's data 571 * selectedItem the selected item in WallpaperThumbnailsGrid's data
562 * model. 572 * model.
563 */ 573 */
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 } 1135 }
1126 this.wallpaperGrid_.dataModel = wallpapersDataModel; 1136 this.wallpaperGrid_.dataModel = wallpapersDataModel;
1127 if (selectedItem) { 1137 if (selectedItem) {
1128 this.wallpaperGrid_.selectedItem = selectedItem; 1138 this.wallpaperGrid_.selectedItem = selectedItem;
1129 this.wallpaperGrid_.activeItem = selectedItem; 1139 this.wallpaperGrid_.activeItem = selectedItem;
1130 } 1140 }
1131 } 1141 }
1132 }; 1142 };
1133 1143
1134 })(); 1144 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698