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

Unified Diff: content/test/plugin/plugin_client.cc

Issue 645203002: Block NPAPI plugins by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move UMA outside ifdef Created 5 years, 11 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 | « content/test/fake_plugin_service.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/plugin/plugin_client.cc
diff --git a/content/test/plugin/plugin_client.cc b/content/test/plugin/plugin_client.cc
index e5d0f8c40b70117c9d3c403b6b4cf1f0e3b6f505..f2f4e68428ffe2b869df459cbd862776f59081d1 100644
--- a/content/test/plugin/plugin_client.cc
+++ b/content/test/plugin/plugin_client.cc
@@ -11,6 +11,52 @@
namespace NPAPIClient {
+class NPWithProperty : public NPObject {
+ public:
+ NPWithProperty() : NPObject() {}
+
+ static NPObject* Allocate(NPP npp, NPClass* npclass) {
+ return new NPWithProperty();
+ }
+
+ static void Deallocate(NPObject* npobject) {
+ delete static_cast<NPWithProperty*>(npobject);
+ }
+
+ static bool HasProperty(NPObject* npobject, NPIdentifier name) {
+ return (name == PluginClient::HostFunctions()->
+ getstringidentifier("loadedProperty"));
+ }
+
+ static bool GetProperty(NPObject* npobject,
+ NPIdentifier name,
+ NPVariant* result) {
+ if (name == PluginClient::HostFunctions()->
+ getstringidentifier("loadedProperty")) {
+ BOOLEAN_TO_NPVARIANT(true, *result);
+ return true;
+ }
+ return false;
+ }
+};
+
+static NPClass* GetNPClass() {
+ static NPClass plugin_class = {
+ NP_CLASS_STRUCT_VERSION,
+ NPWithProperty::Allocate,
+ NPWithProperty::Deallocate,
+ NULL, // Invalidate
+ NULL, // HasMethod
+ NULL, // Invoke
+ NULL, // InvokeDefault
+ NPWithProperty::HasProperty,
+ NPWithProperty::GetProperty,
+ NULL, // SetProperty
+ NULL, // RemoveProperty
+ };
+ return &plugin_class;
+}
+
NPNetscapeFuncs* PluginClient::host_functions_;
NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) {
@@ -230,6 +276,13 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
return NPERR_NO_ERROR;
}
+ if (variable == NPPVpluginScriptableNPObject) {
+ *(NPObject**)value =
+ NPAPIClient::PluginClient::HostFunctions()->createobject(
+ instance, NPAPIClient::GetNPClass());
+ return NPERR_NO_ERROR;
+ }
+
// XXXMB - do work here.
return NPERR_GENERIC_ERROR;
}
« no previous file with comments | « content/test/fake_plugin_service.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698