Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 * Controller for QuickView. | 6 * Controller for QuickView. |
| 7 * | 7 * |
| 8 * @param {!FilesQuickView} quickView | 8 * @param {!FilesQuickView} quickView |
| 9 * @param {!MetadataModel} metadataModel File system metadata. | 9 * @param {!MetadataModel} metadataModel File system metadata. |
| 10 * @param {!FileSelectionHandler} selectionHandler | 10 * @param {!FileSelectionHandler} selectionHandler |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 * @private | 161 * @private |
| 162 */ | 162 */ |
| 163 QuickViewController.prototype.updateQuickView_ = function() { | 163 QuickViewController.prototype.updateQuickView_ = function() { |
| 164 assert(this.entries_.length > 0); | 164 assert(this.entries_.length > 0); |
| 165 // TODO(oka): Support multi-selection. | 165 // TODO(oka): Support multi-selection. |
| 166 this.quickViewModel_.setSelectedEntry(this.entries_[0]); | 166 this.quickViewModel_.setSelectedEntry(this.entries_[0]); |
| 167 | 167 |
| 168 var entry = | 168 var entry = |
| 169 (/** @type {!FileEntry} */ (this.quickViewModel_.getSelectedEntry())); | 169 (/** @type {!FileEntry} */ (this.quickViewModel_.getSelectedEntry())); |
| 170 assert(entry); | 170 assert(entry); |
| 171 this.quickView_.filePath = entry.name; | 171 return this.metadataModel_ |
| 172 return this.metadataModel_.get([entry], ['contentThumbnailUrl']) | 172 .get( |
| 173 [entry], | |
| 174 ['thumbnailUrl', 'contentThumbnailUrl', 'croppedThumbnailUrl']) | |
|
fukino
2016/06/17 02:35:13
question: When do we need croppedThumbnailUrl?
fukino
2016/06/17 02:35:13
I don't remember the exact implementation, but if
oka
2016/06/17 23:13:54
Avoided to use contentThumbnailUrl for Drive files
oka
2016/06/17 23:13:54
It worked without croppedThumbnailUrl.
| |
| 173 .then(this.onMetadataLoaded_.bind(this, entry)); | 175 .then(this.onMetadataLoaded_.bind(this, entry)); |
| 174 }; | 176 }; |
| 175 | 177 |
| 176 /** | 178 /** |
| 177 * Update quick view using file entry and loaded metadata. | 179 * Update quick view using file entry and loaded metadata. |
| 178 * | 180 * |
| 179 * @param {!FileEntry} entry | 181 * @param {!FileEntry} entry |
| 180 * @param {Array<MetadataItem>} items | 182 * @param {Array<MetadataItem>} items |
| 181 * @private | 183 * @private |
| 182 */ | 184 */ |
| 183 QuickViewController.prototype.onMetadataLoaded_ = function(entry, items) { | 185 QuickViewController.prototype.onMetadataLoaded_ = function(entry, items) { |
| 186 this.quickView_.clear(); | |
| 187 this.quickView_.filePath = entry.name; | |
| 184 var item = items[0]; | 188 var item = items[0]; |
| 185 var type = FileType.getType(entry); | 189 var type = FileType.getType(entry); |
| 186 var thumbnailUrl = item.thumbnailUrl || item.croppedThumbnailUrl; | 190 var thumbnailUrl = item.thumbnailUrl || item.croppedThumbnailUrl; |
| 187 if (type.type === 'image') { | 191 if (type.type === 'image') { |
| 188 if (item.externalFileUrl) { | 192 if (item.externalFileUrl) { |
| 189 // TODO(oka): Support Drive. | 193 // TODO(oka): Support Drive. |
| 190 } else { | 194 } else { |
| 191 var url = thumbnailUrl || entry.toURL(); | 195 var url = thumbnailUrl || entry.toURL(); |
| 192 this.quickView_.setImageURL(url); | 196 this.quickView_.image = url; |
| 193 } | 197 } |
| 194 } else if (type.type === 'video') { | 198 } else if (type.type === 'video') { |
| 195 // TODO(oka): Set thumbnail. | 199 // TODO(oka): Set thumbnail. |
| 196 if (item.externalFileUrl) { | 200 if (item.externalFileUrl) { |
| 197 // TODO(oka): Support Drive. | 201 // TODO(oka): Support Drive. |
| 198 } else { | 202 } else { |
| 199 var url = entry.toURL(); | 203 var url = entry.toURL(); |
| 200 this.quickView_.setVideoURL(url); | 204 this.quickView_.video = url; |
| 201 } | 205 } |
| 202 this.quickView_.setVideoURL(entry.toURL()); | |
| 203 } else if (type.type === 'audio') { | 206 } else if (type.type === 'audio') { |
| 204 this.quickView_.setAudioURL(entry.toURL()); | |
| 205 // TODO(oka): Set thumbnail. | |
| 206 if (item.externalFileUrl) { | 207 if (item.externalFileUrl) { |
| 207 // TODO(oka): Support Drive. | 208 // TODO(oka): Support Drive. |
| 208 } else { | 209 } else { |
| 209 this.quickView_.setAudioURL(url); | 210 var url = entry.toURL(); |
| 211 this.quickView_.audio = url; | |
| 210 } | 212 } |
| 211 this.quickView_.setAudioURL(entry.toURL()); | 213 if (item.contentThumbnailUrl) |
| 214 this.quickView_.contentThumbnailUrl = item.contentThumbnailUrl; | |
| 215 } else { | |
| 216 this.quickView_.unsupported = true; | |
| 212 } | 217 } |
| 213 }; | 218 }; |
| OLD | NEW |