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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 | 500 |
| 501 // Falls back to request wallpaper from server. | 501 // Falls back to request wallpaper from server. |
| 502 if (self.wallpaperRequest_) | 502 if (self.wallpaperRequest_) |
| 503 self.wallpaperRequest_.abort(); | 503 self.wallpaperRequest_.abort(); |
| 504 | 504 |
| 505 self.wallpaperRequest_ = new XMLHttpRequest(); | 505 self.wallpaperRequest_ = new XMLHttpRequest(); |
| 506 self.progressManager_.reset(self.wallpaperRequest_, selectedGridItem); | 506 self.progressManager_.reset(self.wallpaperRequest_, selectedGridItem); |
| 507 | 507 |
| 508 var onSuccess = function(xhr) { | 508 var onSuccess = function(xhr) { |
| 509 var image = xhr.response; | 509 var image = xhr.response; |
| 510 chrome.wallpaperPrivate.setWallpaper(image, selectedItem.layout, | 510 if (image) { |
|
flackr
2013/09/06 15:44:00
onSuccess can actually be called if there's no res
| |
| 511 wallpaperURL, | 511 chrome.wallpaperPrivate.setWallpaper(image, selectedItem.layout, |
| 512 self.onFinished_.bind(self, selectedGridItem, selectedItem)); | 512 wallpaperURL, |
| 513 self.currentWallpaper_ = wallpaperURL; | 513 self.onFinished_.bind(self, selectedGridItem, selectedItem)); |
| 514 WallpaperUtil.saveWallpaperInfo(wallpaperURL, selectedItem.layout, | 514 self.currentWallpaper_ = wallpaperURL; |
| 515 selectedItem.source); | 515 WallpaperUtil.saveWallpaperInfo(wallpaperURL, selectedItem.layout, |
| 516 self.wallpaperRequest_ = null; | 516 selectedItem.source); |
| 517 self.wallpaperRequest_ = null; | |
| 518 } | |
| 517 }; | 519 }; |
| 518 var onFailure = function() { | 520 var onFailure = function() { |
| 519 self.progressManager_.hideProgressBar(selectedGridItem); | 521 self.progressManager_.hideProgressBar(selectedGridItem); |
| 520 self.showError_(str('downloadFailed')); | 522 self.showError_(str('downloadFailed')); |
| 521 self.wallpaperRequest_ = null; | 523 self.wallpaperRequest_ = null; |
| 522 }; | 524 }; |
| 523 WallpaperUtil.fetchURL(wallpaperURL, 'arraybuffer', onSuccess, | 525 WallpaperUtil.fetchURL(wallpaperURL, 'arraybuffer', onSuccess, |
| 524 onFailure, self.wallpaperRequest_); | 526 onFailure, self.wallpaperRequest_); |
| 525 }); | 527 }); |
| 526 break; | 528 break; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 } | 987 } |
| 986 } | 988 } |
| 987 } | 989 } |
| 988 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 990 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
| 989 this.wallpaperGrid_.selectedItem = selectedItem; | 991 this.wallpaperGrid_.selectedItem = selectedItem; |
| 990 this.wallpaperGrid_.activeItem = selectedItem; | 992 this.wallpaperGrid_.activeItem = selectedItem; |
| 991 } | 993 } |
| 992 }; | 994 }; |
| 993 | 995 |
| 994 })(); | 996 })(); |
| OLD | NEW |