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

Unified Diff: webkit/default_plugin/plugin_main.cc

Issue 2079016: Linux: Initial scaffolding for default plugin. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: comments Created 10 years, 7 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
« no previous file with comments | « webkit/default_plugin/plugin_main.h ('k') | webkit/glue/plugins/plugin_list.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/default_plugin/plugin_main.cc
diff --git a/webkit/default_plugin/plugin_main.cc b/webkit/default_plugin/plugin_main.cc
index a4dacc5f29ec5d76e69737e921c3aa1f1cd2c8ea..50250075712e1584bc0da1a7af91396cbea7920f 100644
--- a/webkit/default_plugin/plugin_main.cc
+++ b/webkit/default_plugin/plugin_main.cc
@@ -28,20 +28,27 @@ inline HMODULE GetCurrentModuleHandle() {
NPNetscapeFuncs* g_browser = NULL;
NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* funcs) {
+ // Be explicit about the namespace, because all internal plugins have
+ // functions with these names and some might accidentally put them into the
+ // global namespace. In that case, the linker might prefer the global one.
funcs->version = 11;
funcs->size = sizeof(*funcs);
- funcs->newp = NPP_New;
- funcs->destroy = NPP_Destroy;
- funcs->setwindow = NPP_SetWindow;
- funcs->newstream = NPP_NewStream;
- funcs->destroystream = NPP_DestroyStream;
- funcs->writeready = NPP_WriteReady;
- funcs->write = NPP_Write;
+ funcs->newp = default_plugin::NPP_New;
+ funcs->destroy = default_plugin::NPP_Destroy;
+ funcs->setwindow = default_plugin::NPP_SetWindow;
+ funcs->newstream = default_plugin::NPP_NewStream;
+ funcs->destroystream = default_plugin::NPP_DestroyStream;
+ funcs->writeready = default_plugin::NPP_WriteReady;
+ funcs->write = default_plugin::NPP_Write;
funcs->asfile = NULL;
funcs->print = NULL;
- funcs->event = NPP_HandleEvent;
- funcs->urlnotify = NPP_URLNotify;
+ funcs->event = default_plugin::NPP_HandleEvent;
+ funcs->urlnotify = default_plugin::NPP_URLNotify;
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ funcs->getvalue = default_plugin::NPP_GetValue;
+#else
funcs->getvalue = NULL;
+#endif
funcs->setvalue = NULL;
return NPERR_NO_ERROR;
}
@@ -51,9 +58,18 @@ NPError API_CALL NP_Initialize(NPNetscapeFuncs* funcs) {
return 0;
}
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+NPError API_CALL NP_Initialize(NPNetscapeFuncs* funcs, NPPluginFuncs* p_funcs) {
+ NPError err = NP_Initialize(funcs);
+ if (err != NPERR_NO_ERROR)
+ return err;
+ return NP_GetEntryPoints(p_funcs);
+}
+#endif
+
NPError API_CALL NP_Shutdown(void) {
g_browser = NULL;
- return 0;
+ return NPERR_NO_ERROR;
}
namespace {
@@ -117,6 +133,27 @@ bool NegotiateModels(NPP instance) {
NOTREACHED();
return false;
}
+#elif defined(OS_POSIX)
+ NPError err;
+ // Check that chrome still supports xembed.
+ NPBool supportsXEmbed = FALSE;
+ err = g_browser->getvalue(instance,
+ NPNVSupportsXEmbedBool,
+ &supportsXEmbed);
+ if (err != NPERR_NO_ERROR || !supportsXEmbed) {
+ NOTREACHED();
+ return false;
+ }
+
+ // Check that the toolkit is still gtk2.
+ NPNToolkitType toolkit;
+ err = g_browser->getvalue(instance,
+ NPNVToolkit,
+ &toolkit);
+ if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) {
+ NOTREACHED();
+ return false;
+ }
#endif
return true;
}
@@ -280,6 +317,18 @@ void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
}
}
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
+ switch (variable) {
+ case NPPVpluginNeedsXEmbed:
+ *static_cast<NPBool*>(value) = TRUE;
+ return NPERR_NO_ERROR;
+ default:
+ return NPERR_INVALID_PARAM;
+ }
+}
+#endif
+
int16 NPP_HandleEvent(NPP instance, void* event) {
if (instance == NULL)
return 0;
« no previous file with comments | « webkit/default_plugin/plugin_main.h ('k') | webkit/glue/plugins/plugin_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698