Index: webkit/plugins/npapi/plugin_host.cc |
=================================================================== |
--- webkit/plugins/npapi/plugin_host.cc (revision 0) |
+++ webkit/plugins/npapi/plugin_host.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "webkit/glue/plugins/plugin_host.h" |
+#include "webkit/plugins/npapi/plugin_host.h" |
#include "base/file_util.h" |
#include "base/logging.h" |
@@ -20,24 +20,27 @@ |
#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
#include "webkit/glue/webkit_glue.h" |
-#include "webkit/glue/plugins/default_plugin_shared.h" |
-#include "webkit/glue/plugins/npapi_extension_thunk.h" |
-#include "webkit/glue/plugins/plugin_instance.h" |
-#include "webkit/glue/plugins/plugin_lib.h" |
-#include "webkit/glue/plugins/plugin_list.h" |
-#include "webkit/glue/plugins/plugin_stream_url.h" |
-#include "webkit/glue/plugins/webplugin_delegate.h" |
-#include "webkit/glue/plugins/webplugininfo.h" |
+#include "webkit/plugins/npapi/default_plugin_shared.h" |
+#include "webkit/plugins/npapi/npapi_extension_thunk.h" |
+#include "webkit/plugins/npapi/plugin_instance.h" |
+#include "webkit/plugins/npapi/plugin_lib.h" |
+#include "webkit/plugins/npapi/plugin_list.h" |
+#include "webkit/plugins/npapi/plugin_stream_url.h" |
+#include "webkit/plugins/npapi/webplugin_delegate.h" |
+#include "webkit/plugins/npapi/webplugininfo.h" |
using WebKit::WebBindings; |
+namespace webkit { |
+namespace npapi { |
+ |
// Finds a PluginInstance from an NPP. |
// The caller must take a reference if needed. |
-static NPAPI::PluginInstance* FindInstance(NPP id) { |
+static PluginInstance* FindInstance(NPP id) { |
if (id == NULL) { |
return NULL; |
} |
- return reinterpret_cast<NPAPI::PluginInstance*>(id->ndata); |
+ return reinterpret_cast<PluginInstance*>(id->ndata); |
} |
#if defined(OS_MACOSX) |
@@ -50,8 +53,6 @@ |
} |
#endif |
-namespace NPAPI { |
- |
scoped_refptr<PluginHost> PluginHost::singleton_; |
PluginHost::PluginHost() { |
@@ -277,13 +278,19 @@ |
return !err; |
} |
-} // namespace NPAPI |
+} // namespace npapi |
+} // namespace webkit |
extern "C" { |
+using webkit::npapi::FindInstance; |
+using webkit::npapi::PluginHost; |
+using webkit::npapi::PluginInstance; |
+using webkit::npapi::WebPlugin; |
+ |
// Allocates memory from the host's memory space. |
void* NPN_MemAlloc(uint32_t size) { |
- scoped_refptr<NPAPI::PluginHost> host(NPAPI::PluginHost::Singleton()); |
+ scoped_refptr<PluginHost> host(PluginHost::Singleton()); |
if (host != NULL) { |
// Note: We must use the same allocator/deallocator |
// that is used by the javascript library, as some of the |
@@ -296,7 +303,7 @@ |
// Deallocates memory from the host's memory space |
void NPN_MemFree(void* ptr) { |
- scoped_refptr<NPAPI::PluginHost> host(NPAPI::PluginHost::Singleton()); |
+ scoped_refptr<PluginHost> host(PluginHost::Singleton()); |
if (host != NULL) { |
if (ptr != NULL && ptr != reinterpret_cast<void*>(-1)) |
free(ptr); |
@@ -320,8 +327,8 @@ |
if (!stream || !range_list) |
return NPERR_GENERIC_ERROR; |
- scoped_refptr<NPAPI::PluginInstance> plugin( |
- reinterpret_cast<NPAPI::PluginInstance*>(stream->ndata)); |
+ scoped_refptr<PluginInstance> plugin( |
+ reinterpret_cast<PluginInstance*>(stream->ndata)); |
if (!plugin.get()) |
return NPERR_GENERIC_ERROR; |
@@ -338,7 +345,7 @@ |
if (!url) |
return NPERR_INVALID_URL; |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (!plugin.get()) { |
return NPERR_GENERIC_ERROR; |
} |
@@ -402,7 +409,7 @@ |
if (!url) |
return NPERR_INVALID_URL; |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (!plugin.get()) { |
NOTREACHED(); |
return NPERR_GENERIC_ERROR; |
@@ -549,7 +556,7 @@ |
// |
// |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin.get() == NULL) { |
NOTREACHED(); |
return NPERR_GENERIC_ERROR; |
@@ -565,7 +572,7 @@ |
// else Flash won't request windowless mode. |
bool use_mozilla_user_agent = true; |
if (id) { |
- scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
+ scoped_refptr<PluginInstance> plugin = FindInstance(id); |
if (plugin.get() && !plugin->use_mozilla_user_agent()) |
use_mozilla_user_agent = false; |
} |
@@ -575,7 +582,7 @@ |
"Gecko/20061103 Firefox/2.0a1"; |
#elif defined(OS_MACOSX) |
// Silverlight 4 doesn't handle events correctly unless we claim to be Safari. |
- scoped_refptr<NPAPI::PluginInstance> plugin; |
+ scoped_refptr<PluginInstance> plugin; |
if (id) |
plugin = FindInstance(id); |
if (plugin.get()) { |
@@ -611,7 +618,7 @@ |
// plug-ins at regularly timed intervals. To force a paint message, the |
// plug-in can call NPN_ForceRedraw after calling this method. |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin.get() && plugin->webplugin()) { |
if (invalidRect) { |
#if defined(OS_WIN) |
@@ -644,7 +651,7 @@ |
// TODO: this is overkill--add platform-specific region handling (at the |
// very least, fetch the region's bounding box and pass it to InvalidateRect). |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
DCHECK(plugin.get() != NULL); |
if (plugin.get() && plugin->webplugin()) |
plugin->webplugin()->Invalidate(); |
@@ -673,7 +680,7 @@ |
switch (static_cast<int>(variable)) { |
case NPNVWindowNPObject: { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
NPObject *np_object = plugin->webplugin()->GetWindowScriptNPObject(); |
// Return value is expected to be retained, as |
// described here: |
@@ -689,7 +696,7 @@ |
break; |
} |
case NPNVPluginElementNPObject: { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
NPObject *np_object = plugin->webplugin()->GetPluginElement(); |
// Return value is expected to be retained, as |
// described here: |
@@ -706,7 +713,7 @@ |
} |
#if !defined(OS_MACOSX) // OS X doesn't have windowed plugins. |
case NPNVnetscapeWindow: { |
- scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
+ scoped_refptr<PluginInstance> plugin = FindInstance(id); |
if (!plugin.get()) { |
NOTREACHED(); |
return NPERR_GENERIC_ERROR; |
@@ -743,33 +750,33 @@ |
} |
case NPNVprivateModeBool: { |
NPBool* private_mode = reinterpret_cast<NPBool*>(value); |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
*private_mode = plugin->webplugin()->IsOffTheRecord(); |
rv = NPERR_NO_ERROR; |
break; |
} |
- case default_plugin::kMissingPluginStatusStart + |
- default_plugin::MISSING_PLUGIN_AVAILABLE: |
+ case webkit::npapi::default_plugin::kMissingPluginStatusStart + |
+ webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE: |
// fall through |
- case default_plugin::kMissingPluginStatusStart + |
- default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { |
+ case webkit::npapi::default_plugin::kMissingPluginStatusStart + |
+ webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { |
// This is a hack for the default plugin to send notification to |
// renderer. Even though we check if the plugin is the default plugin, |
// we still need to worry about future standard change that may conflict |
// with the variable definition, in order to avoid duplicate case clauses |
// in this big switch statement. |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin->plugin_lib()->plugin_info().path.value() == |
- kDefaultPluginLibraryName) { |
- plugin->webplugin()->OnMissingPluginStatus( |
- variable - default_plugin::kMissingPluginStatusStart); |
+ webkit::npapi::kDefaultPluginLibraryName) { |
+ plugin->webplugin()->OnMissingPluginStatus(variable - |
+ webkit::npapi::default_plugin::kMissingPluginStatusStart); |
} |
break; |
} |
#if defined(OS_MACOSX) |
case NPNVpluginDrawingModel: { |
// return the drawing model that was negotiated when we initialized. |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
*reinterpret_cast<int*>(value) = plugin->drawing_model(); |
rv = NPERR_NO_ERROR; |
break; |
@@ -826,7 +833,7 @@ |
// If the plugin is not started in a Pepper implementation, it |
// will likely fail when it tries to use any of the functions |
// attached to the extension vector. |
- rv = NPAPI::GetPepperExtensionsFunctions(value); |
+ rv = webkit::npapi::GetPepperExtensionsFunctions(value); |
break; |
default: |
DVLOG(1) << "NPN_GetValue(" << variable << ") is not implemented yet."; |
@@ -838,7 +845,7 @@ |
NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { |
// Allows the plugin to set various modes |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
switch(variable) { |
case NPPVpluginWindowBool: { |
// Sets windowless mode for display of the plugin |
@@ -923,13 +930,13 @@ |
} |
void NPN_PushPopupsEnabledState(NPP id, NPBool enabled) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->PushPopupsEnabledState(enabled ? true : false); |
} |
void NPN_PopPopupsEnabledState(NPP id) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->PopPopupsEnabledState(); |
} |
@@ -937,7 +944,7 @@ |
void NPN_PluginThreadAsyncCall(NPP id, |
void (*func)(void*), |
void* user_data) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->PluginThreadAsyncCall(func, user_data); |
} |
@@ -965,11 +972,11 @@ |
break; |
} |
case NPNURLVCookie: { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (!plugin) |
return NPERR_GENERIC_ERROR; |
- webkit_glue::WebPlugin* webplugin = plugin->webplugin(); |
+ WebPlugin* webplugin = plugin->webplugin(); |
if (!webplugin) |
return NPERR_GENERIC_ERROR; |
@@ -1005,11 +1012,11 @@ |
switch (variable) { |
case NPNURLVCookie: { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (!plugin) |
return NPERR_GENERIC_ERROR; |
- webkit_glue::WebPlugin* webplugin = plugin->webplugin(); |
+ WebPlugin* webplugin = plugin->webplugin(); |
if (!webplugin) |
return NPERR_GENERIC_ERROR; |
@@ -1051,7 +1058,7 @@ |
uint32_t interval, |
NPBool repeat, |
void (*func)(NPP id, uint32_t timer_id)) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (!plugin) |
return 0; |
@@ -1059,7 +1066,7 @@ |
} |
void NPN_UnscheduleTimer(NPP id, uint32_t timer_id) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->UnscheduleTimer(timer_id); |
} |
@@ -1068,7 +1075,7 @@ |
if (!menu) |
return NPERR_INVALID_PARAM; |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin.get()) { |
return plugin->PopUpContextMenu(menu); |
} |
@@ -1080,7 +1087,7 @@ |
NPCoordinateSpace sourceSpace, |
double *destX, double *destY, |
NPCoordinateSpace destSpace) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
if (plugin.get()) { |
return plugin->ConvertPoint(sourceX, sourceY, sourceSpace, |
destX, destY, destSpace); |
@@ -1102,7 +1109,7 @@ |
} |
void NPN_URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) { |
- scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(instance)); |
+ scoped_refptr<PluginInstance> plugin(FindInstance(instance)); |
if (plugin.get()) { |
plugin->URLRedirectResponse(!!allow, notify_data); |
} |