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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/quick_view_controller.js

Issue 2181953003: Improved security of Quick View by rendering videos and audios inside webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 4 months 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) 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 QuickViewController.prototype.getQuickViewParameters_ = function(entry, items) { 217 QuickViewController.prototype.getQuickViewParameters_ = function(entry, items) {
218 var item = items[0]; 218 var item = items[0];
219 var type = FileType.getType(entry).type; 219 var type = FileType.getType(entry).type;
220 220
221 /** @type {!QuickViewParams} */ 221 /** @type {!QuickViewParams} */
222 var params = { 222 var params = {
223 type: type, 223 type: type,
224 filePath: entry.name, 224 filePath: entry.name,
225 }; 225 };
226 226
227 /**
228 * @type function(!FileEntry): !Promise<!File>
229 */
230 var getFile = function(entry) {
231 return new Promise(function(resolve, reject) {
232 entry.file(resolve, reject);
233 });
234 };
235
227 if (type === 'image') { 236 if (type === 'image') {
228 if (item.externalFileUrl) { 237 if (item.externalFileUrl) {
229 if (item.thumbnailUrl) { 238 if (item.thumbnailUrl) {
230 return this.loadThumbnailFromDrive_(item.thumbnailUrl) 239 return this.loadThumbnailFromDrive_(item.thumbnailUrl)
231 .then(function(result) { 240 .then(function(result) {
232 if (result.status === 'success') 241 if (result.status === 'success')
233 params.contentUrl = result.data; 242 params.contentUrl = result.data;
234 return params; 243 return params;
235 }.bind(this)); 244 }.bind(this));
236 } 245 }
237 } else { 246 } else {
238 return new Promise(function(resolve, reject) { 247 return getFile(entry).then(function(file) {
239 entry.file(function(file) {
240 params.contentUrl = URL.createObjectURL(file); 248 params.contentUrl = URL.createObjectURL(file);
fukino 2016/07/28 12:31:38 nit: Should be 2 tab.
oka 2016/08/02 00:24:00 Done.
241 resolve(params); 249 return params;
242 });
243 }); 250 });
244 } 251 }
245 } else if (type === 'video') { 252 } else if (type === 'video') {
246 if (item.externalFileUrl) { 253 if (item.externalFileUrl) {
247 if (item.thumbnailUrl) { 254 if (item.thumbnailUrl) {
248 return this.loadThumbnailFromDrive_(item.thumbnailUrl) 255 return this.loadThumbnailFromDrive_(item.thumbnailUrl)
249 .then(function(result) { 256 .then(function(result) {
250 if (result.status === 'success') { 257 if (result.status === 'success') {
251 params.videoPoster = result.data; 258 params.videoPoster = result.data;
252 } 259 }
253 return params; 260 return params;
254 }); 261 });
255 } 262 }
256 } else { 263 } else {
257 params.contentUrl = entry.toURL();
258 params.autoplay = true; 264 params.autoplay = true;
259 if (item.thumbnailUrl) { 265 if (item.thumbnailUrl) {
260 params.videoPoster = item.thumbnailUrl; 266 params.videoPoster = item.thumbnailUrl;
261 } 267 }
268 return getFile(entry).then(function(file) {
269 params.contentUrl = URL.createObjectURL(file);
270 return params;
fukino 2016/07/28 12:31:38 ditto
oka 2016/08/02 00:24:00 Done.
271 });
262 } 272 }
263 } else if (type === 'audio') { 273 } else if (type === 'audio') {
264 if (item.externalFileUrl) { 274 if (item.externalFileUrl) {
265 // If the file is in Drive, we ask user to open it with external app. 275 // If the file is in Drive, we ask user to open it with external app.
266 } else { 276 } else {
267 params.contentUrl = entry.toURL();
268 params.autoplay = true; 277 params.autoplay = true;
269 return this.metadataModel_.get([entry], ['contentThumbnailUrl']) 278 return Promise.all([
270 .then(function(entry, items) { 279 this.metadataModel_.get([entry], ['contentThumbnailUrl']),
280 getFile(entry)
281 ]).then(function(values) {
282 /** @type {!Array<!MetadataItem>} */
fukino 2016/07/28 12:31:38 ditto
oka 2016/08/02 00:24:00 Done.
283 var items = values[0];
284 /** @type {!File} */
285 var file = values[1];
271 var item = items[0]; 286 var item = items[0];
272 if (item.contentThumbnailUrl) { 287 if (item.contentThumbnailUrl) {
273 params.audioArtwork = item.contentThumbnailUrl; 288 params.audioArtwork = item.contentThumbnailUrl;
274 } 289 }
290 params.contentUrl = URL.createObjectURL(file);
275 return params; 291 return params;
276 }.bind(this, entry)); 292 });
277 } 293 }
278 } 294 }
279 return Promise.resolve(params); 295 return Promise.resolve(params);
280 }; 296 };
281 297
282 /** 298 /**
283 * Loads a thumbnail from Drive. 299 * Loads a thumbnail from Drive.
284 * 300 *
285 * @param {string} url Thumbnail url 301 * @param {string} url Thumbnail url
286 * @return Promise<{{status: string, data:string, width:number, height:number}}> 302 * @return Promise<{{status: string, data:string, width:number, height:number}}>
287 * @private 303 * @private
288 */ 304 */
289 QuickViewController.prototype.loadThumbnailFromDrive_ = function(url) { 305 QuickViewController.prototype.loadThumbnailFromDrive_ = function(url) {
290 return new Promise(function(resolve) { 306 return new Promise(function(resolve) {
291 ImageLoaderClient.getInstance().load(url, resolve) 307 ImageLoaderClient.getInstance().load(url, resolve)
292 }); 308 });
293 }; 309 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698