Chromium Code Reviews| Index: Source/web/WebPluginContainerImpl.cpp |
| diff --git a/Source/web/WebPluginContainerImpl.cpp b/Source/web/WebPluginContainerImpl.cpp |
| index 503a263eb08e14ab62c7ce5d5301569bb4772ce0..fcd7b36515a731ff56262f5e136e8605be6de80d 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,29 @@ NPObject* WebPluginContainerImpl::scriptableObjectForElement() |
| return m_element->getNPObject(); |
| } |
| +v8::Local<v8::Object> WebPluginContainerImpl::getV8ObjectForElement() |
| +{ |
| + LocalFrame* frame = m_element->document().frame(); |
| + if (!frame) |
| + return v8::Local<v8::Object>(); |
| + |
| + if (!frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
| + return v8::Local<v8::Object>(); |
| + |
| + v8::Isolate* isolate = frame->script().isolate(); |
| + v8::EscapableHandleScope handleScope(isolate); |
|
abarth-chromium
2014/07/29 17:34:22
Why do we need a handle scope here? The caller mu
Krzysztof Olczyk
2014/07/30 08:40:31
Done.
|
| + v8::Handle<v8::Context> v8Context = toV8Context(frame, DOMWrapperWorld::mainWorld()); |
| + if (v8Context.IsEmpty()) |
| + return v8::Local<v8::Object>(); |
| + v8::Context::Scope scope(v8Context); |
| + |
| + v8::Handle<v8::Value> v8value = toV8(m_element, v8::Handle<v8::Object>(), isolate); |
|
abarth-chromium
2014/07/29 17:34:22
We deleted all callers of toV8 with empty handles
Krzysztof Olczyk
2014/07/30 08:40:31
Done.
|
| + if (!v8value->IsObject()) |
| + return v8::Local<v8::Object>(); |
|
abarth-chromium
2014/07/29 17:34:22
How could the v8value fail to be an object? Shoul
Krzysztof Olczyk
2014/07/30 08:40:31
Done.
|
| + v8::Local<v8::Object> v8object(v8::Handle<v8::Object>::Cast(v8value)); |
| + return handleScope.Escape(v8object); |
| +} |
| + |
| WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed) |
| { |
| LocalFrame* frame = m_element->document().frame(); |
| @@ -582,9 +609,17 @@ WebLayer* WebPluginContainerImpl::platformLayer() const |
| return m_webLayer; |
| } |
| -NPObject* WebPluginContainerImpl::scriptableObject() |
| +void WebPluginContainerImpl::getScriptableObject(v8::Isolate* isolate, v8::Local<v8::Object>* object) |
| { |
| - return m_webPlugin->scriptableObject(); |
| + if (m_webPlugin->getScriptableObject(isolate, object)) { |
| + // blink::WebPlugin implementation can't provide the obsolete NPObject at the same time: |
| + ASSERT(!m_webPlugin->scriptableObject()); |
| + return; |
| + } |
| + |
| + NPObject* npObject = m_webPlugin->scriptableObject(); |
| + if (npObject) |
| + *object = blink::createV8ObjectForNPObject(npObject, 0, isolate); |
| } |
| bool WebPluginContainerImpl::getFormValue(String& value) |