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

Unified Diff: ui/file_manager/file_manager/foreground/js/quick_view_controller.js

Issue 2540863004: Quick View: Support pdf and text preview. (Closed)
Patch Set: Fix nits. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_quick_view.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/quick_view_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/quick_view_controller.js b/ui/file_manager/file_manager/foreground/js/quick_view_controller.js
index 2b04daada9f5b5e3c15c499e855c4ef425958f2b..c651a9e0dc9b05b1db065f9eddc97682245bae93 100644
--- a/ui/file_manager/file_manager/foreground/js/quick_view_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/quick_view_controller.js
@@ -203,12 +203,13 @@ QuickViewController.prototype.updateQuickView_ = function() {
*/
QuickViewController.prototype.onMetadataLoaded_ = function(entry, items) {
return this.getQuickViewParameters_(entry, items).then(function(params) {
- this.quickView_.contentUrl = params.contentUrl || '';
this.quickView_.type = params.type || '';
this.quickView_.filePath = params.filePath || '';
+ this.quickView_.contentUrl = params.contentUrl || '';
this.quickView_.videoPoster = params.videoPoster || '';
this.quickView_.audioArtwork = params.audioArtwork || '';
this.quickView_.autoplay = params.autoplay || false;
+ this.quickView_.browsable = params.browsable || false;
}.bind(this));
};
@@ -219,7 +220,8 @@ QuickViewController.prototype.onMetadataLoaded_ = function(entry, items) {
* contentUrl: (string|undefined),
* videoPoster: (string|undefined),
* audioArtwork: (string|undefined),
- * autoplay: (boolean|undefined)
+ * autoplay: (boolean|undefined),
+ * browsable: (boolean|undefined),
* }}
*/
var QuickViewParams;
@@ -311,7 +313,27 @@ QuickViewController.prototype.getQuickViewParameters_ = function(entry, items) {
});
}
}
- return Promise.resolve(params);
+ if (item.externalFileUrl || type === '.folder') {
+ return Promise.resolve(params);
+ }
+ return Promise
+ .all([
+ getFile(entry),
+ new Promise(function(resolve) {
+ chrome.fileManagerPrivate.getFileTasks([entry], resolve);
+ })
+ ])
+ .then(function(values) {
+ var file = values[0];
+ var tasks = values[1];
+ var browsable = tasks.some(function(task) {
+ return ['view-in-browser', 'view-pdf'].includes(
+ task.taskId.split('|')[2]);
+ });
+ params.browsable = browsable;
+ params.contentUrl = browsable && URL.createObjectURL(file);
+ return params;
+ });
};
/**
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_quick_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698