OLD | NEW |
---|---|
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 cr.define('wallpapers', function() { | 5 cr.define('wallpapers', function() { |
6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
7 /** @const */ var Grid = cr.ui.Grid; | 7 /** @const */ var Grid = cr.ui.Grid; |
8 /** @const */ var GridItem = cr.ui.GridItem; | 8 /** @const */ var GridItem = cr.ui.GridItem; |
9 /** @const */ var GridSelectionController = cr.ui.GridSelectionController; | 9 /** @const */ var GridSelectionController = cr.ui.GridSelectionController; |
10 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 10 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
(...skipping 14 matching lines...) Expand all Loading... | |
25 return el; | 25 return el; |
26 } | 26 } |
27 | 27 |
28 WallpaperThumbnailsGridItem.prototype = { | 28 WallpaperThumbnailsGridItem.prototype = { |
29 __proto__: GridItem.prototype, | 29 __proto__: GridItem.prototype, |
30 | 30 |
31 /** @inheritDoc */ | 31 /** @inheritDoc */ |
32 decorate: function() { | 32 decorate: function() { |
33 GridItem.prototype.decorate.call(this); | 33 GridItem.prototype.decorate.call(this); |
34 var imageEl = cr.doc.createElement('img'); | 34 var imageEl = cr.doc.createElement('img'); |
35 // Thumbnail | 35 var xhr = new XMLHttpRequest(); |
36 imageEl.src = this.dataItem.baseURL + ThumbnailSuffix; | 36 xhr.open('GET', this.dataItem.baseURL + ThumbnailSuffix, true); |
Mihai Parparita -not on Chrome
2012/10/12 00:48:47
What is the base URL in this case? We generally ar
bshe
2012/10/12 16:28:30
The base URL is a online url. https://storage.goog
| |
37 // Remove any garbage added by GridItem and ListItem decorators. | 37 xhr.responseType = 'blob'; |
38 this.textContent = ''; | 38 xhr.send(null); |
39 this.appendChild(imageEl); | 39 var self = this; |
40 xhr.addEventListener('load', function(e) { | |
41 if (xhr.status === 200) { | |
42 self.textContent = ''; | |
43 imageEl.src = window.URL.createObjectURL(xhr.response); | |
Mihai Parparita -not on Chrome
2012/10/12 00:48:47
This will leak the URL, you'll need to call revoke
bshe
2012/10/12 16:28:30
I saw examples of revoke object after load. After
| |
44 self.appendChild(imageEl); | |
45 } | |
46 //TODO(bshe): Add error handleing. | |
47 }); | |
40 }, | 48 }, |
41 }; | 49 }; |
42 | 50 |
43 /** | 51 /** |
44 * Creates a selection controller that wraps selection on grid ends | 52 * Creates a selection controller that wraps selection on grid ends |
45 * and translates Enter presses into 'activate' events. | 53 * and translates Enter presses into 'activate' events. |
46 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to | 54 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to |
47 * interact with. | 55 * interact with. |
48 * @param {cr.ui.Grid} grid The grid to interact with. | 56 * @param {cr.ui.Grid} grid The grid to interact with. |
49 * @constructor | 57 * @constructor |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 this.columns = 0; | 156 this.columns = 0; |
149 this.redraw(); | 157 this.redraw(); |
150 this.focus(); | 158 this.focus(); |
151 } | 159 } |
152 }; | 160 }; |
153 | 161 |
154 return { | 162 return { |
155 WallpaperThumbnailsGrid: WallpaperThumbnailsGrid | 163 WallpaperThumbnailsGrid: WallpaperThumbnailsGrid |
156 }; | 164 }; |
157 }); | 165 }); |
OLD | NEW |