summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/cpp_bound_class.cc23
-rw-r--r--webkit/glue/cpp_bound_class.h5
-rw-r--r--webkit/plugins/npapi/webplugin_delegate.h3
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl.cc4
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl.h1
-rw-r--r--webkit/plugins/npapi/webplugin_impl.cc39
-rw-r--r--webkit/plugins/npapi/webplugin_impl.h4
-rw-r--r--webkit/plugins/ppapi/message_channel.cc3
-rw-r--r--webkit/plugins/ppapi/plugin_object.cc3
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc11
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h9
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.h3
13 files changed, 28 insertions, 90 deletions
diff --git a/webkit/glue/cpp_bound_class.cc b/webkit/glue/cpp_bound_class.cc
index e43df18..80d542d 100644
--- a/webkit/glue/cpp_bound_class.cc
+++ b/webkit/glue/cpp_bound_class.cc
@@ -177,13 +177,16 @@ NPClass CppNPObject::np_class_ = {
return obj->bound_class->SetProperty(ident, value);
}
-CppBoundClass::CppBoundClass() : npp_(new NPP_t) {
- WebBindings::registerObjectOwner(npp_.get());
+CppBoundClass::CppBoundClass()
+ : bound_to_frame_(false) {
}
CppBoundClass::~CppBoundClass() {
STLDeleteValues(&properties_);
- WebBindings::unregisterObjectOwner(npp_.get());
+
+ // Unregister ourselves if we were bound to a frame.
+ if (bound_to_frame_)
+ WebBindings::unregisterObject(NPVARIANT_TO_OBJECT(self_variant_));
}
bool CppBoundClass::HasMethod(NPIdentifier ident) const {
@@ -297,10 +300,10 @@ bool CppBoundClass::IsMethodRegistered(const std::string& name) const {
CppVariant* CppBoundClass::GetAsCppVariant() {
if (!self_variant_.isObject()) {
- // Create an NPObject using our static NPClass. The first argument has type
- // NPP, but is only used to track object ownership, so passing this is fine.
- NPObject* np_obj = WebBindings::createObject(
- npp_.get(), &CppNPObject::np_class_);
+ // Create an NPObject using our static NPClass. The first argument (a
+ // plugin's instance handle) is passed through to the allocate function
+ // directly, and we don't use it, so it's ok to be 0.
+ NPObject* np_obj = WebBindings::createObject(0, &CppNPObject::np_class_);
CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
obj->bound_class = this;
self_variant_.Set(np_obj);
@@ -313,11 +316,11 @@ CppVariant* CppBoundClass::GetAsCppVariant() {
void CppBoundClass::BindToJavascript(WebFrame* frame,
const std::string& classname) {
// BindToWindowObject will take its own reference to the NPObject, and clean
- // up after itself. It will also (indirectly) register the object with V8,
- // against an owner pointer we supply, so we must register that as an owner,
- // and unregister when we teardown.
+ // up after itself. It will also (indirectly) register the object with V8,
+ // so we must remember this so we can unregister it when we're destroyed.
frame->bindToWindowObject(ASCIIToUTF16(classname),
NPVARIANT_TO_OBJECT(*GetAsCppVariant()));
+ bound_to_frame_ = true;
}
} // namespace webkit_glue
diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h
index d62e2ef..3d7427d 100644
--- a/webkit/glue/cpp_bound_class.h
+++ b/webkit/glue/cpp_bound_class.h
@@ -133,8 +133,9 @@ class WEBKIT_GLUE_EXPORT CppBoundClass {
// reference to this object, and it is released on deletion.
CppVariant self_variant_;
- // Dummy NPP to use to register as owner for NPObjects.
- scoped_ptr<NPP_t> npp_;
+ // True if our np_object has been bound to a WebFrame, in which case it must
+ // be unregistered with V8 when we delete it.
+ bool bound_to_frame_;
DISALLOW_COPY_AND_ASSIGN(CppBoundClass);
};
diff --git a/webkit/plugins/npapi/webplugin_delegate.h b/webkit/plugins/npapi/webplugin_delegate.h
index 9f7fe0e..43a3955 100644
--- a/webkit/plugins/npapi/webplugin_delegate.h
+++ b/webkit/plugins/npapi/webplugin_delegate.h
@@ -83,9 +83,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginDelegate {
// Gets the NPObject associated with the plugin for scripting.
virtual NPObject* GetPluginScriptableObject() = 0;
- // Gets the NPP instance uniquely identifying the plugin for its lifetime.
- virtual struct _NPP* GetPluginNPP() = 0;
-
// Gets the form value associated with the plugin instance.
// Returns false if the value is not available.
virtual bool GetFormValue(base::string16* value) = 0;
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.cc b/webkit/plugins/npapi/webplugin_delegate_impl.cc
index 831de3d..3c2587e9 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl.cc
+++ b/webkit/plugins/npapi/webplugin_delegate_impl.cc
@@ -186,10 +186,6 @@ NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() {
return instance_->GetPluginScriptableObject();
}
-NPP WebPluginDelegateImpl::GetPluginNPP() {
- return instance_->npp();
-}
-
bool WebPluginDelegateImpl::GetFormValue(base::string16* value) {
return instance_->GetFormValue(value);
}
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.h b/webkit/plugins/npapi/webplugin_delegate_impl.h
index 0101de7..6755891 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl.h
+++ b/webkit/plugins/npapi/webplugin_delegate_impl.h
@@ -112,7 +112,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginDelegateImpl : public WebPluginDelegate {
virtual bool HandleInputEvent(const WebKit::WebInputEvent& event,
WebCursor::CursorInfo* cursor_info) OVERRIDE;
virtual NPObject* GetPluginScriptableObject() OVERRIDE;
- virtual NPP GetPluginNPP() OVERRIDE;
virtual bool GetFormValue(base::string16* value) OVERRIDE;
virtual void DidFinishLoadWithReason(const GURL& url,
NPReason reason,
diff --git a/webkit/plugins/npapi/webplugin_impl.cc b/webkit/plugins/npapi/webplugin_impl.cc
index e86f3d1..801ca91 100644
--- a/webkit/plugins/npapi/webplugin_impl.cc
+++ b/webkit/plugins/npapi/webplugin_impl.cc
@@ -243,15 +243,10 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
if (!plugin_delegate)
return false;
- // Store the plugin's unique identifier, used by the container to track its
- // script objects.
- npp_ = plugin_delegate->GetPluginNPP();
-
// Set the container before Initialize because the plugin may
- // synchronously call NPN_GetValue to get its container, or make calls
- // passing script objects that need to be tracked, during initialization.
+ // synchronously call NPN_GetValue to get its container during its
+ // initialization.
SetContainer(container);
-
bool ok = plugin_delegate->Initialize(
plugin_url_, arg_names_, arg_values_, this, load_manually_);
if (!ok) {
@@ -285,10 +280,6 @@ NPObject* WebPluginImpl::scriptableObject() {
return delegate_->GetPluginScriptableObject();
}
-NPP WebPluginImpl::pluginNPP() {
- return npp_;
-}
-
bool WebPluginImpl::getFormValue(WebKit::WebString& value) {
if (!delegate_)
return false;
@@ -493,7 +484,6 @@ WebPluginImpl::WebPluginImpl(
webframe_(webframe),
delegate_(NULL),
container_(NULL),
- npp_(NULL),
plugin_url_(params.url),
load_manually_(params.loadManually),
first_geometry_update_(true),
@@ -1065,8 +1055,6 @@ void WebPluginImpl::SetContainer(WebPluginContainer* container) {
if (!container)
TearDownPluginInstance(NULL);
container_ = container;
- if (container_)
- container_->allowScriptObjects();
}
void WebPluginImpl::HandleURLRequest(const char* url,
@@ -1345,32 +1333,19 @@ bool WebPluginImpl::ReinitializePluginForResponse(
void WebPluginImpl::TearDownPluginInstance(
WebURLLoader* loader_to_ignore) {
- // JavaScript garbage collection may cause plugin script object references to
- // be retained long after the plugin is destroyed. Some plugins won't cope
- // with their objects being released after they've been destroyed, and once
- // we've actually unloaded the plugin the object's releaseobject() code may
- // no longer be in memory. The container tracks the plugin's objects and lets
- // us invalidate them, releasing the references to them held by the JavaScript
- // runtime.
+ // The container maintains a list of JSObjects which are related to this
+ // plugin. Tell the frame we're gone so that it can invalidate all of
+ // those sub JSObjects.
if (container_) {
container_->clearScriptObjects();
container_->setWebLayer(NULL);
}
- // Call PluginDestroyed() first to prevent the plugin from calling us back
- // in the middle of tearing down the render tree.
if (delegate_) {
- // The plugin may call into the browser and pass script objects even during
- // teardown, so temporarily re-enable plugin script objects.
- DCHECK(container_);
- container_->allowScriptObjects();
-
+ // Call PluginDestroyed() first to prevent the plugin from calling us back
+ // in the middle of tearing down the render tree.
delegate_->PluginDestroyed();
delegate_ = NULL;
-
- // Invalidate any script objects created during teardown here, before the
- // plugin might actually be unloaded.
- container_->clearScriptObjects();
}
// Cancel any pending requests because otherwise this deleted object will
diff --git a/webkit/plugins/npapi/webplugin_impl.h b/webkit/plugins/npapi/webplugin_impl.h
index 7b6594b..20917d0 100644
--- a/webkit/plugins/npapi/webplugin_impl.h
+++ b/webkit/plugins/npapi/webplugin_impl.h
@@ -75,7 +75,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginImpl :
WebKit::WebPluginContainer* container);
virtual void destroy();
virtual NPObject* scriptableObject();
- virtual struct _NPP* pluginNPP();
virtual bool getFormValue(WebKit::WebString& value);
virtual void paint(
WebKit::WebCanvas* canvas, const WebKit::WebRect& paint_rect);
@@ -293,9 +292,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginImpl :
// This is just a weak reference.
WebKit::WebPluginContainer* container_;
- // Unique identifier for this plugin, used to track script objects.
- struct _NPP* npp_;
-
typedef std::map<WebPluginResourceClient*,
webkit_glue::MultipartResponseDelegate*>
MultiPartResponseHandlerMap;
diff --git a/webkit/plugins/ppapi/message_channel.cc b/webkit/plugins/ppapi/message_channel.cc
index bbb3eb2..e0e0a39 100644
--- a/webkit/plugins/ppapi/message_channel.cc
+++ b/webkit/plugins/ppapi/message_channel.cc
@@ -324,8 +324,7 @@ MessageChannel::MessageChannel(PluginInstance* instance)
early_message_queue_state_(QUEUE_MESSAGES) {
// Now create an NPObject for receiving calls to postMessage. This sets the
// reference count to 1. We release it in the destructor.
- NPObject* obj = WebBindings::createObject(instance_->instanceNPP(),
- &message_channel_class);
+ NPObject* obj = WebBindings::createObject(NULL, &message_channel_class);
DCHECK(obj);
np_object_ = static_cast<MessageChannel::MessageChannelNPObject*>(obj);
np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
diff --git a/webkit/plugins/ppapi/plugin_object.cc b/webkit/plugins/ppapi/plugin_object.cc
index 9b6a130..a5ef5fe 100644
--- a/webkit/plugins/ppapi/plugin_object.cc
+++ b/webkit/plugins/ppapi/plugin_object.cc
@@ -298,8 +298,7 @@ PP_Var PluginObject::Create(PluginInstance* instance,
// WrapperClass_Allocated function which will have created an object wrapper
// appropriate for this class (derived from NPObject).
NPObjectWrapper* wrapper = static_cast<NPObjectWrapper*>(
- WebBindings::createObject(instance->instanceNPP(),
- const_cast<NPClass*>(&wrapper_class)));
+ WebBindings::createObject(NULL, const_cast<NPClass*>(&wrapper_class)));
// This object will register itself both with the NPObject and with the
// PluginModule. The NPObject will normally handle its lifetime, and it
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 4f7f050..9368e29 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -437,16 +437,17 @@ PluginInstance::PluginInstance(
selection_anchor_(0),
pending_user_gesture_(0.0),
document_loader_(NULL),
- nacl_document_load_(false),
- npp_(new NPP_t) {
+ nacl_document_load_(false) {
pp_instance_ = HostGlobals::Get()->AddInstance(this);
memset(&current_print_settings_, 0, sizeof(current_print_settings_));
DCHECK(delegate);
module_->InstanceCreated(this);
delegate_->InstanceCreated(this);
+ message_channel_.reset(new MessageChannel(this));
view_data_.is_page_visible = delegate->IsPageVisible();
+
resource_creation_ = delegate_->CreateResourceCreationAPI(this);
// TODO(bbudge) remove this when the trusted NaCl plugin has been removed.
@@ -633,8 +634,6 @@ static void SetGPUHistogram(const ::ppapi::Preferences& prefs,
bool PluginInstance::Initialize(const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
bool full_frame) {
- message_channel_.reset(new MessageChannel(this));
-
full_frame_ = full_frame;
UpdateTouchEventRequest();
@@ -2546,10 +2545,6 @@ bool PluginInstance::IsValidInstanceOf(PluginModule* module) {
module == original_module_.get();
}
-NPP PluginInstance::instanceNPP() {
- return npp_.get();
-}
-
void PluginInstance::DoSetCursor(WebCursorInfo* cursor) {
cursor_.reset(cursor);
if (fullscreen_container_) {
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 3053a8a..07f3657 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -58,7 +58,6 @@
#include "webkit/plugins/webkit_plugins_export.h"
struct PP_Point;
-struct _NPP;
class SkBitmap;
class TransportDIB;
@@ -503,10 +502,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// the given module.
bool IsValidInstanceOf(PluginModule* module);
- // Returns the plugin NPP identifier that this plugin will use to identify
- // itself when making NPObject scripting calls to WebBindings.
- struct _NPP* instanceNPP();
-
private:
friend class PpapiUnittest;
@@ -839,10 +834,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// calls and handles PPB_ContentDecryptor_Private calls.
scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_;
- // Dummy NPP value used when calling in to WebBindings, to allow the bindings
- // to correctly track NPObjects belonging to this plugin instance.
- scoped_ptr<struct _NPP> npp_;
-
friend class PpapiPluginInstanceTest;
DISALLOW_COPY_AND_ASSIGN(PluginInstance);
};
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index 4ce9527..30820fb 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -93,9 +93,6 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
if (!instance_)
return false;
- // Enable script objects for this plugin.
- container->allowScriptObjects();
-
bool success = instance_->Initialize(init_data_->arg_names,
init_data_->arg_values,
full_frame_);
@@ -119,9 +116,6 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
}
void WebPluginImpl::destroy() {
- // Tell |container_| to clear references to this plugin's script objects.
- container_->clearScriptObjects();
-
if (instance_) {
::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_);
instance_object_ = PP_MakeUndefined();
@@ -154,10 +148,6 @@ NPObject* WebPluginImpl::scriptableObject() {
return message_channel_np_object;
}
-NPP WebPluginImpl::pluginNPP() {
- return instance_->instanceNPP();
-}
-
bool WebPluginImpl::getFormValue(WebString& value) {
return false;
}
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.h b/webkit/plugins/ppapi/ppapi_webplugin_impl.h
index b8bbffe..11bcf89 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.h
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.h
@@ -16,8 +16,6 @@
#include "ui/gfx/rect.h"
#include "webkit/plugins/webkit_plugins_export.h"
-struct _NPP;
-
namespace WebKit {
struct WebPluginParams;
struct WebPrintParams;
@@ -45,7 +43,6 @@ class WebPluginImpl : public WebKit::WebPlugin {
virtual bool initialize(WebKit::WebPluginContainer* container);
virtual void destroy();
virtual NPObject* scriptableObject();
- virtual struct _NPP* pluginNPP();
virtual bool getFormValue(WebKit::WebString& value);
virtual void paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect);
virtual void updateGeometry(