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

Unified Diff: Source/web/WebPluginContainerImpl.cpp

Issue 230813002: Make it possible to have <object>'s scriptableObject as a v8 object instead of NPObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed broken layout tests. Created 6 years, 4 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 | « Source/web/WebPluginContainerImpl.h ('k') | public/web/WebPlugin.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebPluginContainerImpl.cpp
diff --git a/Source/web/WebPluginContainerImpl.cpp b/Source/web/WebPluginContainerImpl.cpp
index 503a263eb08e14ab62c7ce5d5301569bb4772ce0..0cad69edd0f32aa6fa939b3630272c4215ef4805 100644
--- a/Source/web/WebPluginContainerImpl.cpp
+++ b/Source/web/WebPluginContainerImpl.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2014 Opera Software ASA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,6 +33,8 @@
#include "web/WebPluginContainerImpl.h"
#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/V8Element.h"
+#include "bindings/core/v8/V8NPObject.h"
#include "core/HTMLNames.h"
#include "core/clipboard/DataObject.h"
#include "core/clipboard/DataTransfer.h"
@@ -88,6 +91,7 @@
#include "web/WebDataSourceImpl.h"
#include "web/WebInputEventConversion.h"
#include "web/WebViewImpl.h"
+#include "wtf/Assertions.h"
using namespace blink;
@@ -441,6 +445,25 @@ NPObject* WebPluginContainerImpl::scriptableObjectForElement()
return m_element->getNPObject();
}
+v8::Local<v8::Object> WebPluginContainerImpl::v8ObjectForElement()
+{
+ LocalFrame* frame = m_element->document().frame();
+ if (!frame)
+ return v8::Local<v8::Object>();
+
+ if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
+ return v8::Local<v8::Object>();
+
+ ScriptState* scriptState = ScriptState::forMainWorld(frame);
+ if (scriptState->contextIsEmpty())
+ return v8::Local<v8::Object>();
+
+ v8::Handle<v8::Value> v8value = toV8(m_element, scriptState->context()->Global(), scriptState->isolate());
+ ASSERT(v8value->IsObject());
+
+ return v8::Handle<v8::Object>::Cast(v8value);
+}
+
WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed)
{
LocalFrame* frame = m_element->document().frame();
@@ -582,9 +605,19 @@ WebLayer* WebPluginContainerImpl::platformLayer() const
return m_webLayer;
}
-NPObject* WebPluginContainerImpl::scriptableObject()
+v8::Local<v8::Object> WebPluginContainerImpl::scriptableObject(v8::Isolate* isolate)
{
- return m_webPlugin->scriptableObject();
+ v8::Local<v8::Object> object = m_webPlugin->v8ScriptableObject(isolate);
+ if (!object.IsEmpty()) {
+ // blink::WebPlugin implementation can't provide the obsolete NPObject at the same time:
+ ASSERT(!m_webPlugin->scriptableObject());
+ return object;
+ }
+
+ NPObject* npObject = m_webPlugin->scriptableObject();
+ if (npObject)
+ return blink::createV8ObjectForNPObject(npObject, 0, isolate);
+ return v8::Local<v8::Object>();
}
bool WebPluginContainerImpl::getFormValue(String& value)
« no previous file with comments | « Source/web/WebPluginContainerImpl.h ('k') | public/web/WebPlugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698