Index: webkit/glue/plugins/plugin_host.cc |
diff --git a/webkit/plugins/npapi/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc |
similarity index 91% |
rename from webkit/plugins/npapi/plugin_host.cc |
rename to webkit/glue/plugins/plugin_host.cc |
index 1fd542faf68109803bff114e97410ce7700e5739..28aba02a86ba01396fdb1ce717595650665c99dc 100644 |
--- a/webkit/plugins/npapi/plugin_host.cc |
+++ b/webkit/glue/plugins/plugin_host.cc |
@@ -2,47 +2,42 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "webkit/plugins/npapi/plugin_host.h" |
+#include "webkit/glue/plugins/plugin_host.h" |
#include "base/file_util.h" |
#include "base/logging.h" |
#include "base/scoped_ptr.h" |
#include "base/string_piece.h" |
#include "base/string_util.h" |
+#if defined(OS_MACOSX) |
+#include "base/sys_info.h" |
+#endif |
#include "base/sys_string_conversions.h" |
#include "base/utf_string_conversions.h" |
-#include "build/build_config.h" |
#include "net/base/net_util.h" |
#include "third_party/npapi/bindings/npapi_extensions.h" |
#include "third_party/npapi/bindings/npruntime.h" |
#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/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" |
- |
-#if defined(OS_MACOSX) |
-#include "base/sys_info.h" |
-#endif |
+#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" |
using WebKit::WebBindings; |
-namespace webkit { |
-namespace npapi { |
- |
// Finds a PluginInstance from an NPP. |
// The caller must take a reference if needed. |
-static PluginInstance* FindInstance(NPP id) { |
+static NPAPI::PluginInstance* FindInstance(NPP id) { |
if (id == NULL) { |
return NULL; |
} |
- return reinterpret_cast<PluginInstance*>(id->ndata); |
+ return reinterpret_cast<NPAPI::PluginInstance*>(id->ndata); |
} |
#if defined(OS_MACOSX) |
@@ -55,6 +50,8 @@ static bool SupportsSharingAcceleratedSurfaces() { |
} |
#endif |
+namespace NPAPI { |
+ |
scoped_refptr<PluginHost> PluginHost::singleton_; |
PluginHost::PluginHost() { |
@@ -280,19 +277,13 @@ bool PluginHost::SetPostData(const char* buf, |
return !err; |
} |
-} // namespace npapi |
-} // namespace webkit |
+} // namespace NPAPI |
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<PluginHost> host(PluginHost::Singleton()); |
+ scoped_refptr<NPAPI::PluginHost> host(NPAPI::PluginHost::Singleton()); |
if (host != NULL) { |
// Note: We must use the same allocator/deallocator |
// that is used by the javascript library, as some of the |
@@ -305,7 +296,7 @@ void* NPN_MemAlloc(uint32_t size) { |
// Deallocates memory from the host's memory space |
void NPN_MemFree(void* ptr) { |
- scoped_refptr<PluginHost> host(PluginHost::Singleton()); |
+ scoped_refptr<NPAPI::PluginHost> host(NPAPI::PluginHost::Singleton()); |
if (host != NULL) { |
if (ptr != NULL && ptr != reinterpret_cast<void*>(-1)) |
free(ptr); |
@@ -329,8 +320,8 @@ NPError NPN_RequestRead(NPStream* stream, NPByteRange* range_list) { |
if (!stream || !range_list) |
return NPERR_GENERIC_ERROR; |
- scoped_refptr<PluginInstance> plugin( |
- reinterpret_cast<PluginInstance*>(stream->ndata)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin( |
+ reinterpret_cast<NPAPI::PluginInstance*>(stream->ndata)); |
if (!plugin.get()) |
return NPERR_GENERIC_ERROR; |
@@ -347,7 +338,7 @@ static NPError GetURLNotify(NPP id, |
if (!url) |
return NPERR_INVALID_URL; |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (!plugin.get()) { |
return NPERR_GENERIC_ERROR; |
} |
@@ -411,7 +402,7 @@ static NPError PostURLNotify(NPP id, |
if (!url) |
return NPERR_INVALID_URL; |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (!plugin.get()) { |
NOTREACHED(); |
return NPERR_GENERIC_ERROR; |
@@ -558,7 +549,7 @@ NPError NPN_DestroyStream(NPP id, NPStream* stream, NPReason reason) { |
// |
// |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin.get() == NULL) { |
NOTREACHED(); |
return NPERR_GENERIC_ERROR; |
@@ -574,7 +565,7 @@ const char* NPN_UserAgent(NPP id) { |
// else Flash won't request windowless mode. |
bool use_mozilla_user_agent = true; |
if (id) { |
- scoped_refptr<PluginInstance> plugin = FindInstance(id); |
+ scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
if (plugin.get() && !plugin->use_mozilla_user_agent()) |
use_mozilla_user_agent = false; |
} |
@@ -584,12 +575,11 @@ const char* NPN_UserAgent(NPP id) { |
"Gecko/20061103 Firefox/2.0a1"; |
#elif defined(OS_MACOSX) |
// Silverlight 4 doesn't handle events correctly unless we claim to be Safari. |
- scoped_refptr<PluginInstance> plugin; |
+ scoped_refptr<NPAPI::PluginInstance> plugin; |
if (id) |
plugin = FindInstance(id); |
if (plugin.get()) { |
- webkit::npapi::WebPluginInfo plugin_info = |
- plugin->plugin_lib()->plugin_info(); |
+ WebPluginInfo plugin_info = plugin->plugin_lib()->plugin_info(); |
if (plugin_info.name == ASCIIToUTF16("Silverlight Plug-In") && |
StartsWith(plugin_info.version, ASCIIToUTF16("4."), false)) { |
return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) " |
@@ -621,7 +611,7 @@ void NPN_InvalidateRect(NPP id, NPRect *invalidRect) { |
// plug-ins at regularly timed intervals. To force a paint message, the |
// plug-in can call NPN_ForceRedraw after calling this method. |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin.get() && plugin->webplugin()) { |
if (invalidRect) { |
#if defined(OS_WIN) |
@@ -654,7 +644,7 @@ void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { |
// 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<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
DCHECK(plugin.get() != NULL); |
if (plugin.get() && plugin->webplugin()) |
plugin->webplugin()->Invalidate(); |
@@ -683,7 +673,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
switch (static_cast<int>(variable)) { |
case NPNVWindowNPObject: { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
NPObject *np_object = plugin->webplugin()->GetWindowScriptNPObject(); |
// Return value is expected to be retained, as |
// described here: |
@@ -699,7 +689,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
break; |
} |
case NPNVPluginElementNPObject: { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
NPObject *np_object = plugin->webplugin()->GetPluginElement(); |
// Return value is expected to be retained, as |
// described here: |
@@ -716,7 +706,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
} |
#if !defined(OS_MACOSX) // OS X doesn't have windowed plugins. |
case NPNVnetscapeWindow: { |
- scoped_refptr<PluginInstance> plugin = FindInstance(id); |
+ scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
if (!plugin.get()) { |
NOTREACHED(); |
return NPERR_GENERIC_ERROR; |
@@ -753,33 +743,33 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
} |
case NPNVprivateModeBool: { |
NPBool* private_mode = reinterpret_cast<NPBool*>(value); |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
*private_mode = plugin->webplugin()->IsOffTheRecord(); |
rv = NPERR_NO_ERROR; |
break; |
} |
- case webkit::npapi::default_plugin::kMissingPluginStatusStart + |
- webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE: |
+ case default_plugin::kMissingPluginStatusStart + |
+ default_plugin::MISSING_PLUGIN_AVAILABLE: |
// fall through |
- case webkit::npapi::default_plugin::kMissingPluginStatusStart + |
- webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { |
+ case default_plugin::kMissingPluginStatusStart + |
+ 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<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin->plugin_lib()->plugin_info().path.value() == |
- webkit::npapi::kDefaultPluginLibraryName) { |
- plugin->webplugin()->OnMissingPluginStatus(variable - |
- webkit::npapi::default_plugin::kMissingPluginStatusStart); |
+ kDefaultPluginLibraryName) { |
+ plugin->webplugin()->OnMissingPluginStatus( |
+ variable - default_plugin::kMissingPluginStatusStart); |
} |
break; |
} |
#if defined(OS_MACOSX) |
case NPNVpluginDrawingModel: { |
// return the drawing model that was negotiated when we initialized. |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
*reinterpret_cast<int*>(value) = plugin->drawing_model(); |
rv = NPERR_NO_ERROR; |
break; |
@@ -812,8 +802,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
// TODO(stuartmorgan): Once existing CA plugins have implemented the |
// invalidating version, remove support for this one. |
NPBool* supports_model = reinterpret_cast<NPBool*>(value); |
- *supports_model = webkit::npapi::SupportsSharingAcceleratedSurfaces() ? |
- true : false; |
+ *supports_model = SupportsSharingAcceleratedSurfaces() ? true : false; |
rv = NPERR_NO_ERROR; |
break; |
} |
@@ -837,7 +826,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
// 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 = webkit::npapi::GetPepperExtensionsFunctions(value); |
+ rv = NPAPI::GetPepperExtensionsFunctions(value); |
break; |
default: |
DVLOG(1) << "NPN_GetValue(" << variable << ") is not implemented yet."; |
@@ -849,7 +838,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { |
// Allows the plugin to set various modes |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
switch(variable) { |
case NPPVpluginWindowBool: { |
// Sets windowless mode for display of the plugin |
@@ -890,7 +879,7 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { |
if (model == NPDrawingModelCoreGraphics || |
model == NPDrawingModelInvalidatingCoreAnimation || |
(model == NPDrawingModelCoreAnimation && |
- webkit::npapi::SupportsSharingAcceleratedSurfaces())) { |
+ SupportsSharingAcceleratedSurfaces())) { |
plugin->set_drawing_model(static_cast<NPDrawingModel>(model)); |
return NPERR_NO_ERROR; |
} |
@@ -934,13 +923,13 @@ void* NPN_GetJavaPeer(NPP) { |
} |
void NPN_PushPopupsEnabledState(NPP id, NPBool enabled) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->PushPopupsEnabledState(enabled ? true : false); |
} |
void NPN_PopPopupsEnabledState(NPP id) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->PopPopupsEnabledState(); |
} |
@@ -948,7 +937,7 @@ void NPN_PopPopupsEnabledState(NPP id) { |
void NPN_PluginThreadAsyncCall(NPP id, |
void (*func)(void*), |
void* user_data) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->PluginThreadAsyncCall(func, user_data); |
} |
@@ -976,11 +965,11 @@ NPError NPN_GetValueForURL(NPP id, |
break; |
} |
case NPNURLVCookie: { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (!plugin) |
return NPERR_GENERIC_ERROR; |
- WebPlugin* webplugin = plugin->webplugin(); |
+ webkit_glue::WebPlugin* webplugin = plugin->webplugin(); |
if (!webplugin) |
return NPERR_GENERIC_ERROR; |
@@ -1016,11 +1005,11 @@ NPError NPN_SetValueForURL(NPP id, |
switch (variable) { |
case NPNURLVCookie: { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (!plugin) |
return NPERR_GENERIC_ERROR; |
- WebPlugin* webplugin = plugin->webplugin(); |
+ webkit_glue::WebPlugin* webplugin = plugin->webplugin(); |
if (!webplugin) |
return NPERR_GENERIC_ERROR; |
@@ -1062,7 +1051,7 @@ uint32_t NPN_ScheduleTimer(NPP id, |
uint32_t interval, |
NPBool repeat, |
void (*func)(NPP id, uint32_t timer_id)) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (!plugin) |
return 0; |
@@ -1070,7 +1059,7 @@ uint32_t NPN_ScheduleTimer(NPP id, |
} |
void NPN_UnscheduleTimer(NPP id, uint32_t timer_id) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin) |
plugin->UnscheduleTimer(timer_id); |
} |
@@ -1079,7 +1068,7 @@ NPError NPN_PopUpContextMenu(NPP id, NPMenu* menu) { |
if (!menu) |
return NPERR_INVALID_PARAM; |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin.get()) { |
return plugin->PopUpContextMenu(menu); |
} |
@@ -1091,7 +1080,7 @@ NPBool NPN_ConvertPoint(NPP id, double sourceX, double sourceY, |
NPCoordinateSpace sourceSpace, |
double *destX, double *destY, |
NPCoordinateSpace destSpace) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
if (plugin.get()) { |
return plugin->ConvertPoint(sourceX, sourceY, sourceSpace, |
destX, destY, destSpace); |
@@ -1113,7 +1102,7 @@ NPBool NPN_UnfocusInstance(NPP id, NPFocusDirection direction) { |
} |
void NPN_URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) { |
- scoped_refptr<PluginInstance> plugin(FindInstance(instance)); |
+ scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(instance)); |
if (plugin.get()) { |
plugin->URLRedirectResponse(!!allow, notify_data); |
} |