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

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: Rebased to current ToT (by raymes - fetched from https://codereview.chromium.org/426853002/) 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::getV8ObjectForElement()
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 v8::Isolate* isolate = frame->script().isolate();
458 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.
459 v8::Handle<v8::Context> v8Context = toV8Context(frame, DOMWrapperWorld::main World());
460 if (v8Context.IsEmpty())
461 return v8::Local<v8::Object>();
462 v8::Context::Scope scope(v8Context);
463
464 v8::Handle<v8::Value> v8value = toV8(m_element, v8::Handle<v8::Object>(), is olate);
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.
465 if (!v8value->IsObject())
466 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.
467 v8::Local<v8::Object> v8object(v8::Handle<v8::Object>::Cast(v8value));
468 return handleScope.Escape(v8object);
469 }
470
444 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed) 471 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed)
445 { 472 {
446 LocalFrame* frame = m_element->document().frame(); 473 LocalFrame* frame = m_element->document().frame();
447 if (!frame) 474 if (!frame)
448 return WebString(); 475 return WebString();
449 476
450 const KURL& kurl = url; 477 const KURL& kurl = url;
451 ASSERT(kurl.protocolIs("javascript")); 478 ASSERT(kurl.protocolIs("javascript"));
452 479
453 String script = decodeURLEscapeSequences( 480 String script = decodeURLEscapeSequences(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 void WebPluginContainerImpl::didFailLoading(const ResourceError& error) 602 void WebPluginContainerImpl::didFailLoading(const ResourceError& error)
576 { 603 {
577 m_webPlugin->didFailLoading(error); 604 m_webPlugin->didFailLoading(error);
578 } 605 }
579 606
580 WebLayer* WebPluginContainerImpl::platformLayer() const 607 WebLayer* WebPluginContainerImpl::platformLayer() const
581 { 608 {
582 return m_webLayer; 609 return m_webLayer;
583 } 610 }
584 611
585 NPObject* WebPluginContainerImpl::scriptableObject() 612 void WebPluginContainerImpl::getScriptableObject(v8::Isolate* isolate, v8::Local <v8::Object>* object)
586 { 613 {
587 return m_webPlugin->scriptableObject(); 614 if (m_webPlugin->getScriptableObject(isolate, object)) {
615 // blink::WebPlugin implementation can't provide the obsolete NPObject a t the same time:
616 ASSERT(!m_webPlugin->scriptableObject());
617 return;
618 }
619
620 NPObject* npObject = m_webPlugin->scriptableObject();
621 if (npObject)
622 *object = blink::createV8ObjectForNPObject(npObject, 0, isolate);
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