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

Unified Diff: chrome/browser/extensions/file_manager_util.cc

Issue 8357019: Restricting set of URL requests that get intercepted to gview to GET methods with scheme http (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/file_manager_util.cc
diff --git a/chrome/browser/extensions/file_manager_util.cc b/chrome/browser/extensions/file_manager_util.cc
index 1eb24341eadb841ce7e52aeda7b3e2d7afc1599d..9af2eab922198fae6616a52f2a891b5d03b5b687 100644
--- a/chrome/browser/extensions/file_manager_util.cc
+++ b/chrome/browser/extensions/file_manager_util.cc
@@ -7,15 +7,19 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "base/path_service.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/simple_message_box.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/plugin_service.h"
#include "content/browser/user_metrics.h"
#include "grit/generated_resources.h"
#include "net/base/escape.h"
@@ -41,10 +45,13 @@ const char kMediaPlayerUrl[] = FILEBROWSER_URL("mediaplayer.html");
const char kMediaPlayerPlaylistUrl[] = FILEBROWSER_URL("playlist.html");
#undef FILEBROWSER_URL
+const char kPdfExtension[] = ".pdf";
// List of file extension we can open in tab.
const char* kBrowserSupportedExtensions[] = {
- ".bmp", ".jpg", ".jpeg", ".png", ".webp", ".gif", ".pdf", ".txt", ".html",
- ".htm"
+#if defined(GOOGLE_CHROME_BUILD)
+ ".pdf",
+#endif
+ ".bmp", ".jpg", ".jpeg", ".png", ".webp", ".gif", ".txt", ".html", ".htm"
};
// List of file extension that can be handled with the media player.
const char* kAVExtensions[] = {
@@ -85,6 +92,29 @@ bool IsSupportedAVExtension(const char* ext) {
return false;
}
+// If pdf plugin is enabled, we should open pdf files in a tab.
+bool ShouldBeOpenedWithPdfPlugin(const char* ext) {
+ if (base::strcasecmp(ext, kPdfExtension) != 0)
+ return false;
+
+ Browser* browser = BrowserList::GetLastActive();
+ if (!browser)
+ return false;
+
+ FilePath pdf_path;
+ PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
+
+ webkit::WebPluginInfo plugin;
+ if (!PluginService::GetInstance()->GetPluginInfoByPath(pdf_path, &plugin))
+ return false;
+
+ PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
+ if (!plugin_prefs)
+ return false;
+
+ return plugin_prefs->IsPluginEnabled(plugin);
+}
+
// static
GURL FileManagerUtil::GetFileBrowserExtensionUrl() {
return GURL(kFileBrowserExtensionUrl);
@@ -226,7 +256,8 @@ void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) {
std::string ext = full_path.Extension();
// For things supported natively by the browser, we should open it
// in a tab.
- if (IsSupportedBrowserExtension(ext.data())) {
+ if (IsSupportedBrowserExtension(ext.data()) ||
+ ShouldBeOpenedWithPdfPlugin(ext.data())) {
std::string path;
path = "file://";
path.append(EscapeUrlEncodedData(full_path.value(), false));

Powered by Google App Engine
This is Rietveld 408576698