OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
3 * | 4 * |
4 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
6 * met: | 7 * met: |
7 * | 8 * |
8 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 11 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 12 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 13 * in the documentation and/or other materials provided with the |
(...skipping 12 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 30 */ |
30 | 31 |
31 #include "config.h" | 32 #include "config.h" |
32 #include "web/WebPluginContainerImpl.h" | 33 #include "web/WebPluginContainerImpl.h" |
33 | 34 |
34 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 36 #include "bindings/core/v8/V8Element.h" |
| 37 #include "bindings/core/v8/V8NPObject.h" |
35 #include "core/HTMLNames.h" | 38 #include "core/HTMLNames.h" |
36 #include "core/clipboard/DataObject.h" | 39 #include "core/clipboard/DataObject.h" |
37 #include "core/clipboard/DataTransfer.h" | 40 #include "core/clipboard/DataTransfer.h" |
38 #include "core/events/GestureEvent.h" | 41 #include "core/events/GestureEvent.h" |
39 #include "core/events/KeyboardEvent.h" | 42 #include "core/events/KeyboardEvent.h" |
40 #include "core/events/MouseEvent.h" | 43 #include "core/events/MouseEvent.h" |
41 #include "core/events/TouchEvent.h" | 44 #include "core/events/TouchEvent.h" |
42 #include "core/events/WheelEvent.h" | 45 #include "core/events/WheelEvent.h" |
43 #include "core/frame/FrameView.h" | 46 #include "core/frame/FrameView.h" |
44 #include "core/frame/LocalFrame.h" | 47 #include "core/frame/LocalFrame.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 #include "public/web/WebElement.h" | 84 #include "public/web/WebElement.h" |
82 #include "public/web/WebInputEvent.h" | 85 #include "public/web/WebInputEvent.h" |
83 #include "public/web/WebPlugin.h" | 86 #include "public/web/WebPlugin.h" |
84 #include "public/web/WebPrintParams.h" | 87 #include "public/web/WebPrintParams.h" |
85 #include "public/web/WebViewClient.h" | 88 #include "public/web/WebViewClient.h" |
86 #include "web/ChromeClientImpl.h" | 89 #include "web/ChromeClientImpl.h" |
87 #include "web/ScrollbarGroup.h" | 90 #include "web/ScrollbarGroup.h" |
88 #include "web/WebDataSourceImpl.h" | 91 #include "web/WebDataSourceImpl.h" |
89 #include "web/WebInputEventConversion.h" | 92 #include "web/WebInputEventConversion.h" |
90 #include "web/WebViewImpl.h" | 93 #include "web/WebViewImpl.h" |
| 94 #include "wtf/Assertions.h" |
91 | 95 |
92 | 96 |
93 using namespace blink; | 97 using namespace blink; |
94 | 98 |
95 namespace blink { | 99 namespace blink { |
96 | 100 |
97 // Public methods -------------------------------------------------------------- | 101 // Public methods -------------------------------------------------------------- |
98 | 102 |
99 void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect) | 103 void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect) |
100 { | 104 { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return; | 438 return; |
435 | 439 |
436 frame()->script().cleanupScriptObjectsForPlugin(this); | 440 frame()->script().cleanupScriptObjectsForPlugin(this); |
437 } | 441 } |
438 | 442 |
439 NPObject* WebPluginContainerImpl::scriptableObjectForElement() | 443 NPObject* WebPluginContainerImpl::scriptableObjectForElement() |
440 { | 444 { |
441 return m_element->getNPObject(); | 445 return m_element->getNPObject(); |
442 } | 446 } |
443 | 447 |
| 448 v8::Local<v8::Object> WebPluginContainerImpl::v8ObjectForElement() |
| 449 { |
| 450 LocalFrame* frame = m_element->document().frame(); |
| 451 if (!frame) |
| 452 return v8::Local<v8::Object>(); |
| 453 |
| 454 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
| 455 return v8::Local<v8::Object>(); |
| 456 |
| 457 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 458 if (scriptState->contextIsEmpty()) |
| 459 return v8::Local<v8::Object>(); |
| 460 |
| 461 v8::Handle<v8::Value> v8value = toV8(m_element, scriptState->context()->Glob
al(), scriptState->isolate()); |
| 462 ASSERT(v8value->IsObject()); |
| 463 |
| 464 return v8::Handle<v8::Object>::Cast(v8value); |
| 465 } |
| 466 |
444 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup
sAllowed) | 467 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup
sAllowed) |
445 { | 468 { |
446 LocalFrame* frame = m_element->document().frame(); | 469 LocalFrame* frame = m_element->document().frame(); |
447 if (!frame) | 470 if (!frame) |
448 return WebString(); | 471 return WebString(); |
449 | 472 |
450 const KURL& kurl = url; | 473 const KURL& kurl = url; |
451 ASSERT(kurl.protocolIs("javascript")); | 474 ASSERT(kurl.protocolIs("javascript")); |
452 | 475 |
453 String script = decodeURLEscapeSequences( | 476 String script = decodeURLEscapeSequences( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 void WebPluginContainerImpl::didFailLoading(const ResourceError& error) | 598 void WebPluginContainerImpl::didFailLoading(const ResourceError& error) |
576 { | 599 { |
577 m_webPlugin->didFailLoading(error); | 600 m_webPlugin->didFailLoading(error); |
578 } | 601 } |
579 | 602 |
580 WebLayer* WebPluginContainerImpl::platformLayer() const | 603 WebLayer* WebPluginContainerImpl::platformLayer() const |
581 { | 604 { |
582 return m_webLayer; | 605 return m_webLayer; |
583 } | 606 } |
584 | 607 |
585 NPObject* WebPluginContainerImpl::scriptableObject() | 608 v8::Local<v8::Object> WebPluginContainerImpl::scriptableObject(v8::Isolate* isol
ate) |
586 { | 609 { |
587 return m_webPlugin->scriptableObject(); | 610 v8::Local<v8::Object> object = m_webPlugin->v8ScriptableObject(isolate); |
| 611 if (!object.IsEmpty()) { |
| 612 // blink::WebPlugin implementation can't provide the obsolete NPObject a
t the same time: |
| 613 ASSERT(!m_webPlugin->scriptableObject()); |
| 614 return object; |
| 615 } |
| 616 |
| 617 NPObject* npObject = m_webPlugin->scriptableObject(); |
| 618 if (npObject) |
| 619 return blink::createV8ObjectForNPObject(npObject, 0, isolate); |
| 620 return v8::Local<v8::Object>(); |
588 } | 621 } |
589 | 622 |
590 bool WebPluginContainerImpl::getFormValue(String& value) | 623 bool WebPluginContainerImpl::getFormValue(String& value) |
591 { | 624 { |
592 WebString webValue; | 625 WebString webValue; |
593 if (m_webPlugin->getFormValue(webValue)) { | 626 if (m_webPlugin->getFormValue(webValue)) { |
594 value = webValue; | 627 value = webValue; |
595 return true; | 628 return true; |
596 } | 629 } |
597 return false; | 630 return false; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 | 974 |
942 return clipRect; | 975 return clipRect; |
943 } | 976 } |
944 | 977 |
945 bool WebPluginContainerImpl::pluginShouldPersist() const | 978 bool WebPluginContainerImpl::pluginShouldPersist() const |
946 { | 979 { |
947 return m_webPlugin->shouldPersist(); | 980 return m_webPlugin->shouldPersist(); |
948 } | 981 } |
949 | 982 |
950 } // namespace blink | 983 } // namespace blink |
OLD | NEW |