OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @param {!Element} container Content container. | 6 * @param {!Element} container Content container. |
7 * @param {!ErrorBanner} errorBanner Error banner. | 7 * @param {!ErrorBanner} errorBanner Error banner. |
8 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 8 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
9 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 9 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
10 * @param {!VolumeManager} volumeManager Volume manager. | 10 * @param {!VolumeManager} volumeManager Volume manager. |
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 */ | 1823 */ |
1824 this.container_ = container; | 1824 this.container_ = container; |
1825 | 1825 |
1826 /** | 1826 /** |
1827 * @type {!Gallery.Item} | 1827 * @type {!Gallery.Item} |
1828 * @private | 1828 * @private |
1829 */ | 1829 */ |
1830 this.item_ = item; | 1830 this.item_ = item; |
1831 | 1831 |
1832 /** | 1832 /** |
1833 * @type {boolean} | |
1834 * @private | |
1835 */ | |
1836 this.hidpiEmbedded_ = !!opt_locationInfo && opt_locationInfo.isDriveBased; | |
1837 | |
1838 /** | |
1839 * @type {?number} | 1833 * @type {?number} |
1840 * @private | 1834 * @private |
1841 */ | 1835 */ |
1842 this.left_ = null; // Mark as not laid out. | 1836 this.left_ = null; // Mark as not laid out. |
1843 | 1837 |
1844 /** | 1838 /** |
1845 * @type {number} | 1839 * @type {number} |
1846 * @private | 1840 * @private |
1847 */ | 1841 */ |
1848 this.top_ = 0; | 1842 this.top_ = 0; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 | 2046 |
2053 // Set higher priority for the selected elements to load them first. | 2047 // Set higher priority for the selected elements to load them first. |
2054 var priority = this.getAttribute('selected') ? 2 : 3; | 2048 var priority = this.getAttribute('selected') ? 2 : 3; |
2055 | 2049 |
2056 // Use embedded thumbnails on Drive, since they have higher resolution. | 2050 // Use embedded thumbnails on Drive, since they have higher resolution. |
2057 this.thumbnailLoader_ = new ThumbnailLoader( | 2051 this.thumbnailLoader_ = new ThumbnailLoader( |
2058 this.getItem().getEntry(), | 2052 this.getItem().getEntry(), |
2059 ThumbnailLoader.LoaderType.CANVAS, | 2053 ThumbnailLoader.LoaderType.CANVAS, |
2060 metadata, | 2054 metadata, |
2061 undefined, // Media type. | 2055 undefined, // Media type. |
2062 this.hidpiEmbedded_ ? | 2056 [ |
2063 ThumbnailLoader.UseEmbedded.USE_EMBEDDED : | 2057 ThumbnailLoader.LoadTarget.EXTERNAL_METADATA, |
2064 ThumbnailLoader.UseEmbedded.NO_EMBEDDED, | 2058 ThumbnailLoader.LoadTarget.FILE_ENTRY |
2065 priority); | 2059 ]); |
2066 | 2060 |
2067 // If no hidpi embedded thumbnail available, then use the low resolution | 2061 // If no hidpi embedded thumbnail available, then use the low resolution |
2068 // for preloading. | 2062 // for preloading. |
2069 if (!this.hidpiEmbedded_) { | 2063 if (this.thumbnailLoader_.getLoadTarget() === |
| 2064 ThumbnailLoader.LoadTarget.FILE_ENTRY) { |
2070 this.thumbnailPreloader_ = new ThumbnailLoader( | 2065 this.thumbnailPreloader_ = new ThumbnailLoader( |
2071 this.getItem().getEntry(), | 2066 this.getItem().getEntry(), |
2072 ThumbnailLoader.LoaderType.CANVAS, | 2067 ThumbnailLoader.LoaderType.CANVAS, |
2073 metadata, | 2068 metadata, |
2074 undefined, // Media type. | 2069 undefined, // Media type. |
2075 ThumbnailLoader.UseEmbedded.USE_EMBEDDED, | 2070 [ |
| 2071 ThumbnailLoader.LoadTarget.CONTENT_METADATA |
| 2072 ], |
2076 // Preloaders have always higher priotity, so the preload images | 2073 // Preloaders have always higher priotity, so the preload images |
2077 // are loaded as soon as possible. | 2074 // are loaded as soon as possible. |
2078 2); | 2075 2); |
| 2076 if (!this.thumbnailPreloader_.getLoadTarget()) |
| 2077 this.thumbnailPreloader_ = null; |
2079 } | 2078 } |
2080 | 2079 |
2081 // Dimensions are always acquired from the metadata. For local files, it is | 2080 // Dimensions are always acquired from the metadata. For local files, it is |
2082 // extracted from headers. For Drive files, it is received via the Drive API. | 2081 // extracted from headers. For Drive files, it is received via the Drive API. |
2083 // If the dimensions are not available, then the fallback dimensions will be | 2082 // If the dimensions are not available, then the fallback dimensions will be |
2084 // used (same as for the generic icon). | 2083 // used (same as for the generic icon). |
2085 var width; | 2084 var width; |
2086 var height; | 2085 var height; |
2087 if (metadata.media && metadata.media.width) { | 2086 if (metadata.media && metadata.media.width) { |
2088 width = metadata.media.width; | 2087 width = metadata.media.width; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2283 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, | 2282 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, |
2284 this.width_, this.height_).inflate(-margin, -margin); | 2283 this.width_, this.height_).inflate(-margin, -margin); |
2285 }; | 2284 }; |
2286 | 2285 |
2287 /** | 2286 /** |
2288 * @return {number} X coordinate of the tile center. | 2287 * @return {number} X coordinate of the tile center. |
2289 */ | 2288 */ |
2290 Mosaic.Tile.prototype.getCenterX = function() { | 2289 Mosaic.Tile.prototype.getCenterX = function() { |
2291 return this.left_ + Math.round(this.width_ / 2); | 2290 return this.left_ + Math.round(this.width_ / 2); |
2292 }; | 2291 }; |
OLD | NEW |