r42886 - in trunk/src/chrome: browser browser/renderer_host common renderer

27 views
Skip to first unread message

j...@chromium.org

unread,
Mar 26, 2010, 9:06:01 PM3/26/10
to chromium...@chromium.org
Author: j...@chromium.org
Date: Fri Mar 26 18:06:01 2010
New Revision: 42886

Log:
Use internal pdf plugin with --internal-pdf
Review URL: http://codereview.chromium.org/1462001

Modified:
trunk/src/chrome/browser/plugin_service.cc
trunk/src/chrome/browser/renderer_host/browser_render_process_host.cc
trunk/src/chrome/common/chrome_paths.cc
trunk/src/chrome/common/chrome_paths.h
trunk/src/chrome/common/chrome_switches.cc
trunk/src/chrome/common/chrome_switches.h
trunk/src/chrome/renderer/render_process_impl.cc
trunk/src/chrome/renderer/render_view.cc

Modified: trunk/src/chrome/browser/plugin_service.cc
==============================================================================
--- trunk/src/chrome/browser/plugin_service.cc (original)
+++ trunk/src/chrome/browser/plugin_service.cc Fri Mar 26 18:06:01 2010
@@ -111,6 +111,13 @@
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();

Modified: trunk/src/chrome/browser/renderer_host/browser_render_process_host.cc
==============================================================================
--- trunk/src/chrome/browser/renderer_host/browser_render_process_host.cc (original)
+++ trunk/src/chrome/browser/renderer_host/browser_render_process_host.cc Fri Mar 26 18:06:01 2010
@@ -532,6 +532,7 @@
switches::kSimpleDataSource,
switches::kEnableBenchmarking,
switches::kInternalNaCl,
+ switches::kInternalPDF,
switches::kInternalPepper,
switches::kDisableByteRangeSupport,
switches::kDisableDatabases,

Modified: trunk/src/chrome/common/chrome_paths.cc
==============================================================================
--- trunk/src/chrome/common/chrome_paths.cc (original)
+++ trunk/src/chrome/common/chrome_paths.cc Fri Mar 26 18:06:01 2010
@@ -221,6 +221,18 @@
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))

Modified: trunk/src/chrome/common/chrome_paths.h
==============================================================================
--- trunk/src/chrome/common/chrome_paths.h (original)
+++ trunk/src/chrome/common/chrome_paths.h Fri Mar 26 18:06:01 2010
@@ -40,6 +40,7 @@
// 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

Modified: trunk/src/chrome/common/chrome_switches.cc
==============================================================================
--- trunk/src/chrome/common/chrome_switches.cc (original)
+++ trunk/src/chrome/common/chrome_switches.cc Fri Mar 26 18:06:01 2010
@@ -421,6 +421,9 @@
// 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";

Modified: trunk/src/chrome/common/chrome_switches.h
==============================================================================
--- trunk/src/chrome/common/chrome_switches.h (original)
+++ trunk/src/chrome/common/chrome_switches.h Fri Mar 26 18:06:01 2010
@@ -127,6 +127,7 @@
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[];

Modified: trunk/src/chrome/renderer/render_process_impl.cc
==============================================================================
--- trunk/src/chrome/renderer/render_process_impl.cc (original)
+++ trunk/src/chrome/renderer/render_process_impl.cc Fri Mar 26 18:06:01 2010
@@ -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 @@
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() {

Modified: trunk/src/chrome/renderer/render_view.cc
==============================================================================
--- trunk/src/chrome/renderer/render_view.cc (original)
+++ trunk/src/chrome/renderer/render_view.cc Fri Mar 26 18:06:01 2010
@@ -3000,6 +3000,11 @@
// 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)) {

Reply all
Reply to author
Forward
0 new messages