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

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

Issue 11092078: Add some error messages for setting wallpaper failures on Chrome(c++) side. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: use SetError Created 8 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 this.wallpaperRequest_.open('GET', wallpaperURL, true); 186 this.wallpaperRequest_.open('GET', wallpaperURL, true);
187 this.wallpaperRequest_.responseType = 'arraybuffer'; 187 this.wallpaperRequest_.responseType = 'arraybuffer';
188 this.wallpaperRequest_.send(null); 188 this.wallpaperRequest_.send(null);
189 this.butterBar_.setRequest(this.wallpaperRequest_); 189 this.butterBar_.setRequest(this.wallpaperRequest_);
190 var self = this; 190 var self = this;
191 this.wallpaperRequest_.addEventListener('load', function(e) { 191 this.wallpaperRequest_.addEventListener('load', function(e) {
192 if (self.wallpaperRequest_.status === 200) { 192 if (self.wallpaperRequest_.status === 200) {
193 var image = self.wallpaperRequest_.response; 193 var image = self.wallpaperRequest_.response;
194 chrome.wallpaperPrivate.setWallpaper(image, 194 chrome.wallpaperPrivate.setWallpaper(image,
195 selectedItem.layout, 195 selectedItem.layout,
196 wallpaperURL); 196 wallpaperURL,
197 self.onFinished_.bind(self));
197 self.currentWallpaper_ = wallpaperURL; 198 self.currentWallpaper_ = wallpaperURL;
198 } else { 199 } else {
199 self.butterBar_.showError_(str('downloadFailed')); 200 self.butterBar_.showError_(str('downloadFailed'));
200 } 201 }
201 self.wallpaperRequest_ = null; 202 self.wallpaperRequest_ = null;
202 }); 203 });
203 } 204 }
204 this.setWallpaperAttribution_(selectedItem); 205 this.setWallpaperAttribution_(selectedItem);
205 }; 206 };
206 207
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 309
309 /** 310 /**
310 * Refreshes the custom wallpaper with the current selected layout. 311 * Refreshes the custom wallpaper with the current selected layout.
311 * @param {ArrayBuffer} customWallpaper The raw wallpaper file data. 312 * @param {ArrayBuffer} customWallpaper The raw wallpaper file data.
312 */ 313 */
313 WallpaperManager.prototype.refreshWallpaper_ = function(customWallpaper) { 314 WallpaperManager.prototype.refreshWallpaper_ = function(customWallpaper) {
314 var setWallpaperLayout = $('set-wallpaper-layout'); 315 var setWallpaperLayout = $('set-wallpaper-layout');
315 var layout = 316 var layout =
316 setWallpaperLayout.options[setWallpaperLayout.selectedIndex].value; 317 setWallpaperLayout.options[setWallpaperLayout.selectedIndex].value;
317 chrome.wallpaperPrivate.setCustomWallpaper(customWallpaper, 318 chrome.wallpaperPrivate.setCustomWallpaper(customWallpaper,
318 layout); 319 layout,
320 this.onFinished_.bind(this));
319 this.currentWallpaper_ = 'CUSTOM'; 321 this.currentWallpaper_ = 'CUSTOM';
320 }; 322 };
321 323
322 /** 324 /**
325 * Sets wallpaper finished. Displays error message in butter bar if any.
326 */
327 WallpaperManager.prototype.onFinished_ = function() {
328 if (chrome.runtime.lastError != undefined)
329 this.butterBar_.showError_(chrome.runtime.lastError.message);
330 else
331 this.butterBar_.hide_();
332 };
333
334 /**
323 * Handles the layout setting change of custom wallpaper. 335 * Handles the layout setting change of custom wallpaper.
324 */ 336 */
325 WallpaperManager.prototype.onWallpaperLayoutChanged_ = function() { 337 WallpaperManager.prototype.onWallpaperLayoutChanged_ = function() {
326 if (this.customWallpaperData_) 338 if (this.customWallpaperData_)
327 this.refreshWallpaper_(this.customWallpaperData_); 339 this.refreshWallpaper_(this.customWallpaperData_);
328 }; 340 };
329 341
330 /** 342 /**
331 * Generates a thumbnail of user selected image file. 343 * Generates a thumbnail of user selected image file.
332 * @param {Object} file The file user selected from file manager. 344 * @param {Object} file The file user selected from file manager.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 selectedItem = wallpaperInfo; 396 selectedItem = wallpaperInfo;
385 } 397 }
386 } 398 }
387 } 399 }
388 this.wallpaperGrid_.dataModel = wallpapersDataModel; 400 this.wallpaperGrid_.dataModel = wallpapersDataModel;
389 this.wallpaperGrid_.selectedItem = selectedItem; 401 this.wallpaperGrid_.selectedItem = selectedItem;
390 } 402 }
391 }; 403 };
392 404
393 })(); 405 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698