diff options
-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, 49 insertions, 58 deletions
diff --git a/build/all.gyp b/build/all.gyp index 9bdd75f..efd560b 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -35,6 +35,7 @@ '../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:*', @@ -51,9 +52,8 @@ '../chrome_frame/chrome_frame.gyp:*', ], }], - ['enable_pepper==1', { + ['enable_gpu==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 0f42c37..bbce33e 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 pepper APIs are enabled. - 'enable_pepper%': 0, + # Whether GPU plugin build is enabled. + 'enable_gpu%': 0, # Whether usage of OpenMAX is enabled. 'enable_openmax%': 0, @@ -341,9 +341,6 @@ ['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 c7325ad..05a452d 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -517,6 +517,7 @@ 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 f1e7c36c..ebe31de 100755 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -148,7 +148,7 @@ ], }, 'conditions': [ - ['enable_pepper==1', { + ['enable_gpu==1', { 'dependencies': [ '../gpu/gpu.gyp:gpu_plugin', ], diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 3160bd8..f64b451 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -313,6 +313,9 @@ 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 5d97788..9698cdf 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -99,6 +99,7 @@ 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 4718a5c..c9d4f44 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2,10 +2,6 @@ // 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> @@ -2641,24 +2637,36 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( else mime_type_to_use = &mime_type; -#if defined(PEPPER_APIS_ENABLED) + bool use_pepper_host = false; + bool in_process_plugin = RenderProcess::current()->in_process_plugins(); + // Check for trusted Pepper plugins. const char kPepperPrefix[] = "pepper-"; if (StartsWithASCII(*mime_type_to_use, kPepperPrefix, true)) { - return WebPluginDelegatePepper::Create( - path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); + 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; + } } -#endif - - bool in_process_plugin = RenderProcess::current()->in_process_plugins(); + // Check for Native Client modules. 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. - return WebPluginDelegateImpl::Create( - path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); + 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_)); + } #else NOTIMPLEMENTED(); return NULL; diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc index db1ca2e..e07bff2 100644 --- a/webkit/glue/plugins/npapi_extension_thunk.cc +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -9,9 +9,7 @@ #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. @@ -245,18 +243,3 @@ 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 291aa13..e4f4992 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -2,9 +2,6 @@ // 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" @@ -802,9 +799,16 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { break; } #endif // OS_MACOSX - case NPNVPepperExtensions: - rv = NPAPI::GetPepperExtensionsFunctions(value); + 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; + } 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 90ac44a..a549b5f 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 hence only with - // in renderer process plugins. + // This API is only for use with Pepper, and is only overridden + // by in-renderer implementations. virtual WebPluginDelegate* delegate() { return NULL; } }; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index a3148b1..006e544 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -212,6 +212,9 @@ 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. @@ -225,7 +228,6 @@ 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 96c6397..4c8003b 100644 --- a/webkit/tools/pepper_test_plugin/README +++ b/webkit/tools/pepper_test_plugin/README @@ -1,18 +1,12 @@ This is a test plugin for manual testing of the Pepper plugin API. See https://wiki.mozilla.org/Plugins:PlatformIndependentNPAPI -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 +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 75ede4e..7884fac 100644 --- a/webkit/tools/pepper_test_plugin/event_handler.cc +++ b/webkit/tools/pepper_test_plugin/event_handler.cc @@ -28,6 +28,7 @@ #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" @@ -127,11 +128,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 a19574e..5144e76 100644 --- a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp +++ b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp @@ -12,9 +12,6 @@ 'include_dirs': [ '../../..', # Root of Chrome Checkout ], - 'defines': [ - 'PEPPER_APIS_ENABLED', - ], 'conditions': [ ['OS=="win"', { 'product_name': 'pepper_test_plugin', |