diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 21:06:31 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 21:06:31 +0000 |
commit | 8756e6680ae0d217e99f1f5a92afdd2695d11327 (patch) | |
tree | 570276616722f4fda65f0bc4bfa4be0260591200 | |
parent | c976120a73d5b7e991bc37c705b9a1ee59bf4e4a (diff) | |
download | chromium_src-8756e6680ae0d217e99f1f5a92afdd2695d11327.zip chromium_src-8756e6680ae0d217e99f1f5a92afdd2695d11327.tar.gz chromium_src-8756e6680ae0d217e99f1f5a92afdd2695d11327.tar.bz2 |
Allow open local pdf file from FileBrowse UI.
Allow local pdf file to be opened if a pdf plugin is available.
BUG=chromium-os:5263
TEST=Verify local pdf file could be opened and viewed by pdf plugin.
Review URL: http://codereview.chromium.org/3083015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54964 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/filebrowse.html | 16 | ||||
-rw-r--r-- | chrome/browser/resources/shared/js/media_common.js | 4 |
2 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/resources/filebrowse.html b/chrome/browser/resources/filebrowse.html index 786e513..39aba80 100644 --- a/chrome/browser/resources/filebrowse.html +++ b/chrome/browser/resources/filebrowse.html @@ -577,6 +577,10 @@ function partial(fn, var_args) { }; } +function supportsPdf() { + return 'application/pdf' in navigator.mimeTypes; +} + var currentSavedPath = ''; var currentNode = -1; var menus = []; @@ -1260,7 +1264,7 @@ function showImage(path) { } } -function showText(path) { +function showPath(path) { chrome.send('openNewFullWindow', ['file://' + path]); } @@ -1389,9 +1393,15 @@ function getFunctionForItem(path, id, isDirectory) { } if (pathIsHtmlFile(path)) { return function() { - showText(path); + showPath(path); + } + } + if (pathIsPdfFile(path) && supportsPdf()) { + return function() { + showPath(path); } } + return getUnknownFileTypeHandler(); } @@ -1466,7 +1476,7 @@ function createNewItem(title, path, isDirectory) { menu.appendChild(flickritem); menu.appendChild(emailitem); } - if ((pathIsVideoFile(path) || pathIsAudioFile(path)) && + if ((pathIsVideoFile(path) || pathIsAudioFile(path)) && mediaPlayerEnabled) { var enqueueitem = document.createElement('div'); enqueueitem.textContent = localStrings.getString('enqueue'); diff --git a/chrome/browser/resources/shared/js/media_common.js b/chrome/browser/resources/shared/js/media_common.js index 8528809..86b48c8 100644 --- a/chrome/browser/resources/shared/js/media_common.js +++ b/chrome/browser/resources/shared/js/media_common.js @@ -17,3 +17,7 @@ function pathIsImageFile(path) { function pathIsHtmlFile(path) { return /\.(htm|html|txt)$/i.test(path); } + +function pathIsPdfFile(path) { + return /\.(pdf)$/i.test(path); +} |