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

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

Issue 11028121: Convert wallpaper picker to v2 app (Closed) Base URL: http://git.chromium.org/chromium/src.git@AppsV2
Patch Set: Update wallpaper picker to version .2 in manifest Created 8 years 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 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
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 /** @override */ 31 /** @override */
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);
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);
44 imageEl.addEventListener('load', function(e) {
45 window.URL.revokeObjectURL(this.src);
46 });
47 self.appendChild(imageEl);
48 }
49 });
40 }, 50 },
41 }; 51 };
42 52
43 /** 53 /**
44 * Creates a selection controller that wraps selection on grid ends 54 * Creates a selection controller that wraps selection on grid ends
45 * and translates Enter presses into 'activate' events. 55 * and translates Enter presses into 'activate' events.
46 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to 56 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to
47 * interact with. 57 * interact with.
48 * @param {cr.ui.Grid} grid The grid to interact with. 58 * @param {cr.ui.Grid} grid The grid to interact with.
49 * @constructor 59 * @constructor
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 this.columns = 0; 158 this.columns = 0;
149 this.redraw(); 159 this.redraw();
150 this.focus(); 160 this.focus();
151 } 161 }
152 }; 162 };
153 163
154 return { 164 return {
155 WallpaperThumbnailsGrid: WallpaperThumbnailsGrid 165 WallpaperThumbnailsGrid: WallpaperThumbnailsGrid
156 }; 166 };
157 }); 167 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698