diff options
author | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 17:45:03 +0000 |
---|---|---|
committer | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 17:45:03 +0000 |
commit | c2dff4977f8dbd35fd467fb3785587cb634dd190 (patch) | |
tree | 5ee05f387a75d856d29895f06f0c64156754c9ff | |
parent | 5f6397ecb4c7bc92295adc8d21bd87e698ac5622 (diff) | |
download | chromium_src-c2dff4977f8dbd35fd467fb3785587cb634dd190.zip chromium_src-c2dff4977f8dbd35fd467fb3785587cb634dd190.tar.gz chromium_src-c2dff4977f8dbd35fd467fb3785587cb634dd190.tar.bz2 |
Revert 34161 - Enable Pepper support by default, including building the test plugin.
This is needed because the NaCl plugin code that runs in the renderer
needs to use Pepper APIs all the time, and NaCl support has been enabled
by default for several months now. To cause an untrusted Pepper plugin
to run in the renderer one needs to specify the internalpepper flag.
I have also removed the enable_pepper flag from gyp. As the build of the
GPU process was tied to this flag, I have renamed the flag to enable_gpu.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/464074
TBR=sehr@google.com
Review URL: http://codereview.chromium.org/475004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34162 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/all.gyp | 4 | ||||
-rw-r--r-- | build/common.gypi | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rwxr-xr-x | chrome/chrome_renderer.gypi | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 32 | ||||
-rw-r--r-- | webkit/glue/plugins/npapi_extension_thunk.cc | 17 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 14 | ||||
-rw-r--r-- | webkit/glue/webplugin.h | 4 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 4 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/README | 10 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/event_handler.cc | 5 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp | 3 |
14 files changed, 58 insertions, 49 deletions
diff --git a/build/all.gyp b/build/all.gyp index efd560b..9bdd75f 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -35,7 +35,6 @@ '../third_party/sqlite/sqlite.gyp:*', '../third_party/WebKit/WebKit/chromium/WebKit.gyp:*', '../third_party/zlib/zlib.gyp:*', - '../webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp:*', '../webkit/tools/test_shell/test_shell.gyp:*', '../webkit/webkit.gyp:*', 'util/build_util.gyp:*', @@ -52,8 +51,9 @@ '../chrome_frame/chrome_frame.gyp:*', ], }], - ['enable_gpu==1', { + ['enable_pepper==1', { 'dependencies': [ + '../webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp:*', '../gpu/gpu.gyp:*', ], }], diff --git a/build/common.gypi b/build/common.gypi index bbce33e..0f42c37 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -162,8 +162,8 @@ # Whether to add the experimental build define. 'chrome_frame_define%': 0, - # Whether GPU plugin build is enabled. - 'enable_gpu%': 0, + # Whether pepper APIs are enabled. + 'enable_pepper%': 0, # Whether usage of OpenMAX is enabled. 'enable_openmax%': 0, @@ -341,6 +341,9 @@ ['chromeos==1 or toolkit_views==1', { 'defines': ['OS_CHROMEOS=1'], }], + ['enable_pepper==1', { + 'defines': ['ENABLE_PEPPER=1'], + }], ['fastbuild!=0', { 'conditions': [ # Finally, for Windows, we simply turn on profiling. diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 05a452d..c7325ad 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -517,7 +517,6 @@ void BrowserRenderProcessHost::PropogateBrowserCommandLineToRenderer( switches::kSimpleDataSource, switches::kEnableBenchmarking, switches::kInternalNaCl, - switches::kInternalPepper, switches::kDisableByteRangeSupport, switches::kDisableDatabases, switches::kDisableDesktopNotifications, diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index ebe31de..f1e7c36c 100755 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -148,7 +148,7 @@ ], }, 'conditions': [ - ['enable_gpu==1', { + ['enable_pepper==1', { 'dependencies': [ '../gpu/gpu.gyp:gpu_plugin', ], diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index f64b451..3160bd8 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -313,9 +313,6 @@ const char kIncognito[] = "incognito"; // Runs the Native Client inside the renderer process. const char kInternalNaCl[] = "internal-nacl"; -// Runs a trusted Pepper plugin inside the renderer process. -const char kInternalPepper[] = "internal-pepper"; - // Specifies the flags passed to JS engine const char kJavaScriptFlags[] = "js-flags"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 9698cdf..5d97788 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -99,7 +99,6 @@ extern const char kImport[]; extern const char kInProcessPlugins[]; extern const char kIncognito[]; extern const char kInternalNaCl[]; -extern const char kInternalPepper[]; extern const char kJavaScriptFlags[]; extern const char kLoadExtension[]; extern const char kLoadPlugin[]; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index c9d4f44..4718a5c 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#if defined(ENABLE_PEPPER) +#define PEPPER_APIS_ENABLED +#endif + #include "chrome/renderer/render_view.h" #include <algorithm> @@ -2637,36 +2641,24 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( else mime_type_to_use = &mime_type; - bool use_pepper_host = false; - bool in_process_plugin = RenderProcess::current()->in_process_plugins(); - // Check for trusted Pepper plugins. +#if defined(PEPPER_APIS_ENABLED) const char kPepperPrefix[] = "pepper-"; if (StartsWithASCII(*mime_type_to_use, kPepperPrefix, true)) { - if (CommandLine::ForCurrentProcess()-> - HasSwitch(switches::kInternalPepper)) { - in_process_plugin = true; - use_pepper_host = true; - } else { - // In process Pepper plugins must be explicitly enabled. - return NULL; - } + return WebPluginDelegatePepper::Create( + path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); } - // Check for Native Client modules. +#endif + + bool in_process_plugin = RenderProcess::current()->in_process_plugins(); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl)) { if (mime_type == "application/x-nacl-srpc") { in_process_plugin = true; - use_pepper_host = true; } } if (in_process_plugin) { #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. - if (use_pepper_host) { - return WebPluginDelegatePepper::Create( - path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); - } else { - return WebPluginDelegateImpl::Create( - path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); - } + return WebPluginDelegateImpl::Create( + path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); #else NOTIMPLEMENTED(); return NULL; diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc index e07bff2..db1ca2e 100644 --- a/webkit/glue/plugins/npapi_extension_thunk.cc +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -9,7 +9,9 @@ #include "webkit/glue/plugins/plugin_instance.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webplugin_delegate.h" +//#include "third_party/npapi/bindings/npruntime.h" +#if defined(ENABLE_PEPPER) // FindInstance() // Finds a PluginInstance from an NPP. @@ -243,3 +245,18 @@ NPError GetPepperExtensionsFunctions(void* value) { } } // namespace NPAPI + +#else // Not compiling with pepper support + +namespace NPAPI { + +// This NOP function implements the getter for the extensions when the +// extensions aren't available. +NPError GetPepperExtensionsFunctions(void* value) { + return NPERR_GENERIC_ERROR; +} + +} // namespace NPAPI + +#endif // defined(ENABLE_PEPPER) + diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index e4f4992..291aa13 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Pepper API support should be turned on for this module. +#define PEPPER_APIS_ENABLED + #include "webkit/glue/plugins/plugin_host.h" #include "base/file_util.h" @@ -799,16 +802,9 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { break; } #endif // OS_MACOSX - case NPNVPepperExtensions: { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin->webplugin()->delegate() != NULL) { - // Delegate is only set for in-renderer Pepper plugins. - rv = NPAPI::GetPepperExtensionsFunctions(value); - } else { - rv = NPERR_GENERIC_ERROR; - } + case NPNVPepperExtensions: + rv = NPAPI::GetPepperExtensionsFunctions(value); break; - } default: DLOG(INFO) << "NPN_GetValue(" << variable << ") is not implemented yet."; break; diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index a549b5f..90ac44a 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -129,8 +129,8 @@ class WebPlugin { bool defer) = 0; // Gets the WebPluginDelegate that implements the interface. - // This API is only for use with Pepper, and is only overridden - // by in-renderer implementations. + // This API is only for use with Pepper, and hence only with + // in renderer process plugins. virtual WebPluginDelegate* delegate() { return NULL; } }; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index 006e544..a3148b1 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -212,9 +212,6 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) { if (!plugin_delegate) return NULL; - // Set the delegate pointer before Initialize to allow Pepper - // plugins to access to delegate functions during initialization. - delegate_ = plugin_delegate; // Set the container before Initialize because the plugin may // synchronously call NPN_GetValue to get its container during its // initialization. @@ -228,6 +225,7 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) { if (!actual_mime_type.empty()) mime_type_ = actual_mime_type; + delegate_ = plugin_delegate; return true; } diff --git a/webkit/tools/pepper_test_plugin/README b/webkit/tools/pepper_test_plugin/README index 4c8003b..96c6397 100644 --- a/webkit/tools/pepper_test_plugin/README +++ b/webkit/tools/pepper_test_plugin/README @@ -1,12 +1,18 @@ This is a test plugin for manual testing of the Pepper plugin API. See https://wiki.mozilla.org/Plugins:PlatformIndependentNPAPI -Open the Chrome all.sln solution and rebuild the pepper_test_plugin and +To generate a project from the gyp file, set the GYP_DEFINES environment +variable to "enable_pepper=1". From a Windows command prompt: + set GYP_DEFINES=enable_pepper=1 + +Then rebuild the project files: + gclient runhooks --force + +Then open the Chrome all.sln solution and rebuild the pepper_test_plugin and chrome projects. To load this plugin in Chrome, use the command line flags: --no-sandbox - --internal-pepper --load-plugin=<<<YOUR CHECKOUT ROOT>>\src\webkit\tools\pepper_test_plugin\Debug\pepper_test_plugin.dll A simple way to launch Chrome with these command line flags is to run the diff --git a/webkit/tools/pepper_test_plugin/event_handler.cc b/webkit/tools/pepper_test_plugin/event_handler.cc index 7884fac..75ede4e 100644 --- a/webkit/tools/pepper_test_plugin/event_handler.cc +++ b/webkit/tools/pepper_test_plugin/event_handler.cc @@ -28,7 +28,6 @@ #include <stdio.h> #include <string> -#include "base/basictypes.h" #include "base/logging.h" #include "base/string_util.h" #include "webkit/tools/pepper_test_plugin/plugin_object.h" @@ -128,11 +127,11 @@ int EventHandler::handle(void* event) { str += StringPrintf(": mod %x, text: ", npevent->u.character.modifier); size_t i; - for (i = 0; i < arraysize(npevent->u.character.text); ++i) { + for (i = 0; i < ARRAYSIZE(npevent->u.character.text); ++i) { str += StringPrintf("%x ", npevent->u.character.text[i]); } str += ", unmod: "; - for (i = 0; i < arraysize(npevent->u.character.unmodifiedText); ++i) { + for (i = 0; i < ARRAYSIZE(npevent->u.character.unmodifiedText); ++i) { str += StringPrintf("%x ", npevent->u.character.unmodifiedText[i]); } break; diff --git a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp index 5144e76..a19574e 100644 --- a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp +++ b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp @@ -12,6 +12,9 @@ 'include_dirs': [ '../../..', # Root of Chrome Checkout ], + 'defines': [ + 'PEPPER_APIS_ENABLED', + ], 'conditions': [ ['OS=="win"', { 'product_name': 'pepper_test_plugin', |