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

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

Issue 1004263002: Disable surprise me automatically if the current wallpaper was set by a third party application. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address the code review comments. Created 5 years, 9 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 */ 196 */
197 WallpaperManager.prototype.toggleSurpriseMe_ = function() { 197 WallpaperManager.prototype.toggleSurpriseMe_ = function() {
198 var self = this; 198 var self = this;
199 var checkbox = $('surprise-me').querySelector('#checkbox'); 199 var checkbox = $('surprise-me').querySelector('#checkbox');
200 var shouldEnable = !checkbox.classList.contains('checked'); 200 var shouldEnable = !checkbox.classList.contains('checked');
201 WallpaperUtil.saveToStorage(Constants.AccessSurpriseMeEnabledKey, 201 WallpaperUtil.saveToStorage(Constants.AccessSurpriseMeEnabledKey,
202 shouldEnable, true, function() { 202 shouldEnable, true, function() {
203 if (chrome.runtime.lastError == null) { 203 if (chrome.runtime.lastError == null) {
204 if (shouldEnable) { 204 if (shouldEnable) {
205 checkbox.classList.add('checked'); 205 checkbox.classList.add('checked');
206 // Hides the wallpaper set by message if there is any.
207 $('wallpaper-set-by-message').textContent = '';
206 } else { 208 } else {
207 // Unchecking the "Surprise me" checkbox falls back to the previous 209 // Unchecking the "Surprise me" checkbox falls back to the previous
208 // wallpaper before "Surprise me" was turned on. 210 // wallpaper before "Surprise me" was turned on.
209 self.setSelectedWallpaper_(self.wallpaperGrid_.activeItem_); 211 if (self.wallpaperGrid_.activeItem) {
210 self.onWallpaperChanged_(self.wallpaperGrid_.activeItem_, 212 self.setSelectedWallpaper_(self.wallpaperGrid_.activeItem);
211 self.currentWallpaper_); 213 self.onWallpaperChanged_(self.wallpaperGrid_.activeItem,
214 self.currentWallpaper_);
215 }
212 checkbox.classList.remove('checked'); 216 checkbox.classList.remove('checked');
213 } 217 }
214 $('categories-list').disabled = shouldEnable; 218 $('categories-list').disabled = shouldEnable;
215 $('wallpaper-grid').disabled = shouldEnable; 219 $('wallpaper-grid').disabled = shouldEnable;
216 } else { 220 } else {
217 // TODO(bshe): show error message to user. 221 // TODO(bshe): show error message to user.
218 console.error('Failed to save surprise me option to chrome storage.'); 222 console.error('Failed to save surprise me option to chrome storage.');
219 } 223 }
220 }); 224 });
221 }; 225 };
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 } 1097 }
1094 this.wallpaperGrid_.dataModel = wallpapersDataModel; 1098 this.wallpaperGrid_.dataModel = wallpapersDataModel;
1095 if (selectedItem) { 1099 if (selectedItem) {
1096 this.wallpaperGrid_.selectedItem = selectedItem; 1100 this.wallpaperGrid_.selectedItem = selectedItem;
1097 this.wallpaperGrid_.activeItem = selectedItem; 1101 this.wallpaperGrid_.activeItem = selectedItem;
1098 } 1102 }
1099 } 1103 }
1100 }; 1104 };
1101 1105
1102 })(); 1106 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698