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

Side by Side 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: Fixes after code review. 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 unified diff | Download patch
OLDNEW
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
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
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
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 ScriptState::Scope scope(scriptState);
abarth-chromium 2014/07/30 17:52:25 Oh noes! ScriptState::Scope contains a v8::Handle
Krzysztof Olczyk 2014/07/31 06:28:48 oh dear, right. Done.
462
463 v8::Handle<v8::Value> v8value = toV8(m_element, scriptState->context()->Glob al(), scriptState->isolate());
464 ASSERT(v8value->IsObject());
465
466 return v8::Handle<v8::Object>::Cast(v8value);
467 }
468
444 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed) 469 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed)
445 { 470 {
446 LocalFrame* frame = m_element->document().frame(); 471 LocalFrame* frame = m_element->document().frame();
447 if (!frame) 472 if (!frame)
448 return WebString(); 473 return WebString();
449 474
450 const KURL& kurl = url; 475 const KURL& kurl = url;
451 ASSERT(kurl.protocolIs("javascript")); 476 ASSERT(kurl.protocolIs("javascript"));
452 477
453 String script = decodeURLEscapeSequences( 478 String script = decodeURLEscapeSequences(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 void WebPluginContainerImpl::didFailLoading(const ResourceError& error) 600 void WebPluginContainerImpl::didFailLoading(const ResourceError& error)
576 { 601 {
577 m_webPlugin->didFailLoading(error); 602 m_webPlugin->didFailLoading(error);
578 } 603 }
579 604
580 WebLayer* WebPluginContainerImpl::platformLayer() const 605 WebLayer* WebPluginContainerImpl::platformLayer() const
581 { 606 {
582 return m_webLayer; 607 return m_webLayer;
583 } 608 }
584 609
585 NPObject* WebPluginContainerImpl::scriptableObject() 610 v8::Local<v8::Object> WebPluginContainerImpl::scriptableObject(v8::Isolate* isol ate)
586 { 611 {
587 return m_webPlugin->scriptableObject(); 612 v8::Local<v8::Object> object = m_webPlugin->v8ScriptableObject(isolate);
613 if (!object.IsEmpty()) {
614 // blink::WebPlugin implementation can't provide the obsolete NPObject a t the same time:
615 ASSERT(!m_webPlugin->scriptableObject());
616 return object;
617 }
618
619 NPObject* npObject = m_webPlugin->scriptableObject();
620 if (npObject)
621 return blink::createV8ObjectForNPObject(npObject, 0, isolate);
622 return v8::Local<v8::Object>();
588 } 623 }
589 624
590 bool WebPluginContainerImpl::getFormValue(String& value) 625 bool WebPluginContainerImpl::getFormValue(String& value)
591 { 626 {
592 WebString webValue; 627 WebString webValue;
593 if (m_webPlugin->getFormValue(webValue)) { 628 if (m_webPlugin->getFormValue(webValue)) {
594 value = webValue; 629 value = webValue;
595 return true; 630 return true;
596 } 631 }
597 return false; 632 return false;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 976
942 return clipRect; 977 return clipRect;
943 } 978 }
944 979
945 bool WebPluginContainerImpl::pluginShouldPersist() const 980 bool WebPluginContainerImpl::pluginShouldPersist() const
946 { 981 {
947 return m_webPlugin->shouldPersist(); 982 return m_webPlugin->shouldPersist();
948 } 983 }
949 984
950 } // namespace blink 985 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698