diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-27 01:06:01 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-27 01:06:01 +0000 |
commit | d7ce427395f3ea473c9eac56107832fa8093ce09 (patch) | |
tree | c0fde2a3b8ba57a7048e8565e5a3a4eb0aad11e6 | |
parent | 01109dcfb9dc87900f4227efe0dc81d0d382918a (diff) | |
download | chromium_src-d7ce427395f3ea473c9eac56107832fa8093ce09.zip chromium_src-d7ce427395f3ea473c9eac56107832fa8093ce09.tar.gz chromium_src-d7ce427395f3ea473c9eac56107832fa8093ce09.tar.bz2 |
Use internal pdf plugin with --internal-pdf
Review URL: http://codereview.chromium.org/1462001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42886 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/plugin_service.cc | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rw-r--r-- | chrome/common/chrome_paths.cc | 12 | ||||
-rw-r--r-- | chrome/common/chrome_paths.h | 1 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_process_impl.cc | 17 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 5 |
8 files changed, 47 insertions, 0 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index f04d4f3..535ab31 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -111,6 +111,13 @@ PluginService::PluginService() if (!path.empty()) { NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); } + + FilePath pdf; + if (command_line->HasSwitch(switches::kInternalPDF) && + PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf)) { + NPAPI::PluginList::Singleton()->AddExtraPluginPath(pdf); + } + #ifndef DISABLE_NACL if (command_line->HasSwitch(switches::kInternalNaCl)) RegisterInternalNaClPlugin(); diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 1fc8ffa..7f72a79 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -532,6 +532,7 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kSimpleDataSource, switches::kEnableBenchmarking, switches::kInternalNaCl, + switches::kInternalPDF, switches::kInternalPepper, switches::kDisableByteRangeSupport, switches::kDisableDatabases, diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index 8614d1b..8796843 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -221,6 +221,18 @@ bool PathProvider(int key, FilePath* result) { if (!file_util::PathExists(cur)) return false; break; + case chrome::FILE_PDF_PLUGIN: + if (!PathService::Get(base::DIR_MODULE, &cur)) + return false; +#if defined(OS_WIN) + cur = cur.Append(FILE_PATH_LITERAL("pdf.dll")); + if (!file_util::PathExists(cur)) + return false; +#else + // TODO: port + return false; +#endif + break; #if defined(OS_CHROMEOS) case chrome::FILE_CHROMEOS_API: if (!PathService::Get(base::DIR_MODULE, &cur)) diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h index d6aed60..43bf351 100644 --- a/chrome/common/chrome_paths.h +++ b/chrome/common/chrome_paths.h @@ -40,6 +40,7 @@ enum { // playback. FILE_GEARS_PLUGIN, // Full path to the gears.dll plugin file. FILE_FLASH_PLUGIN, // Full path to the internal Flash plugin file. + FILE_PDF_PLUGIN, // Full path to the internal PDF plugin file. FILE_LIBAVCODEC, // Full path to libavcodec media decoding // library. FILE_LIBAVFORMAT, // Full path to libavformat media parsing diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 2b9b02e..fc177fe 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -421,6 +421,9 @@ const char kIncognito[] = "incognito"; // Runs the Native Client inside the renderer process. const char kInternalNaCl[] = "internal-nacl"; +// Uses internal plugin for displaying PDFs. +const char kInternalPDF[] = "internal-pdf"; + // Runs a trusted Pepper plugin inside the renderer process. const char kInternalPepper[] = "internal-pepper"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 84cbdff..3a57ad9 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -127,6 +127,7 @@ extern const char kImportFromFile[]; extern const char kInProcessPlugins[]; extern const char kIncognito[]; extern const char kInternalNaCl[]; +extern const char kInternalPDF[]; extern const char kInternalPepper[]; extern const char kJavaScriptFlags[]; extern const char kLoadExtension[]; diff --git a/chrome/renderer/render_process_impl.cc b/chrome/renderer/render_process_impl.cc index 45fb57a..5b4c383 100644 --- a/chrome/renderer/render_process_impl.cc +++ b/chrome/renderer/render_process_impl.cc @@ -33,6 +33,8 @@ #include "media/base/media.h" #include "media/base/media_switches.h" #include "native_client/src/trusted/plugin/nacl_entry_points.h" +#include "webkit/glue/plugins/plugin_instance.h" +#include "webkit/glue/plugins/plugin_lib.h" #include "webkit/glue/webkit_glue.h" #if defined(OS_MACOSX) @@ -139,6 +141,21 @@ RenderProcessImpl::RenderProcessImpl() media::InitializeOpenMaxLibrary(module_path); } #endif + + // Load the pdf plugin before the sandbox is turned on. + FilePath pdf; + if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf)) { + static scoped_refptr<NPAPI::PluginLib> pdf_lib = + NPAPI::PluginLib::CreatePluginLib(pdf); + // Actually load the plugin. + pdf_lib->NP_Initialize(); + // Keep an instance around to prevent the plugin unloading after a pdf is + // closed. + // Don't use scoped_ptr here because then get asserts on process shut down + // when running in --single-process. + static NPAPI::PluginInstance* instance = pdf_lib->CreateInstance(""); + instance->plugin_lib(); // Quiet unused variable warnings in gcc. + } } RenderProcessImpl::~RenderProcessImpl() { diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 9d232a0..dd0607d 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -3000,6 +3000,11 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( // In process Pepper plugins must be explicitly enabled. return NULL; } + } else if (CommandLine::ForCurrentProcess()-> + HasSwitch(switches::kInternalPDF) && + StartsWithASCII(*mime_type_to_use, "application/pdf", true)) { + in_process_plugin = true; + use_pepper_host = true; } // Check for Native Client modules. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl)) { |