OLD | NEW |
---|---|
1 /** | 1 /** |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) |
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 document().updateStyleIfNeeded(); | 135 document().updateStyleIfNeeded(); |
136 | 136 |
137 if (!needsWidgetUpdate() || useFallbackContent() || isImageType()) | 137 if (!needsWidgetUpdate() || useFallbackContent() || isImageType()) |
138 return; | 138 return; |
139 if (!renderEmbeddedObject() || renderEmbeddedObject()->showsUnavailablePlugi nIndicator()) | 139 if (!renderEmbeddedObject() || renderEmbeddedObject()->showsUnavailablePlugi nIndicator()) |
140 return; | 140 return; |
141 | 141 |
142 updateWidget(CreateOnlyNonNetscapePlugins); | 142 updateWidget(CreateOnlyNonNetscapePlugins); |
143 } | 143 } |
144 | 144 |
145 void HTMLPlugInElement::createPluginWithoutRenderer(const String& mimeType) | |
146 { | |
147 if (m_plugin && (mimeType == m_pluginMimeType)) | |
eseidel
2013/11/18 22:26:45
I'm confused by this check. It feels like it shou
wjmaclean
2013/11/25 17:51:56
Actually, it might be sensible that, if someone se
| |
148 return; | |
149 | |
150 Frame* frame = document().frame(); | |
151 if (!frame->loader().client()->canCreatePluginWithoutRenderer(mimeType)) | |
152 return; | |
153 | |
154 KURL url; | |
155 Vector<String> paramNames; | |
156 Vector<String> paramValues; | |
157 | |
158 paramNames.append(String("type")); | |
eseidel
2013/11/18 22:26:45
Shouldn't need an explicit String() wrapper here?
wjmaclean
2013/11/25 17:51:56
Done.
| |
159 paramValues.append(mimeType); | |
160 | |
161 m_plugin = frame->loader().client()->createPlugin(IntSize(), this, url, para mNames, paramValues, mimeType, false, true); | |
162 | |
163 // Register the bindings with V8 as a scriptable object; normally this is | |
164 // done in getInstance(), but that is only called after a renderer has been | |
165 // assigned. | |
166 if (m_plugin) { | |
167 m_pluginMimeType = mimeType; | |
168 // We require a V8 context in order to be able to create the script | |
169 // instance, but since this may occur during loading we need to create | |
170 // one here to ensure it exists. | |
171 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | |
172 v8::Local<v8::Context> context = ScriptController::mainWorldContext(fram e); | |
173 v8::Context::Scope contextScope(context); | |
174 m_NPObject = frame->script().createScriptObjectForPluginElement(this); | |
175 m_pluginWrapper = frame->script().createPluginWrapper(m_plugin.get()); | |
176 } else { | |
177 m_pluginMimeType = String(); | |
178 } | |
179 } | |
180 | |
145 void HTMLPlugInElement::detach(const AttachContext& context) | 181 void HTMLPlugInElement::detach(const AttachContext& context) |
146 { | 182 { |
147 // Update the widget the next time we attach (detaching destroys the plugin) . | 183 // Update the widget the next time we attach (detaching destroys the plugin) . |
148 // FIXME: None of this "needsWidgetUpdate" related code looks right. | 184 // FIXME: None of this "needsWidgetUpdate" related code looks right. |
149 if (renderer() && !useFallbackContent()) | 185 if (renderer() && !useFallbackContent()) |
150 setNeedsWidgetUpdate(true); | 186 setNeedsWidgetUpdate(true); |
151 | 187 |
152 resetInstance(); | 188 if (m_plugin) { |
189 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | |
190 if (renderer) | |
191 renderer->configureWidget(RenderWidget::ConfigureOnDetach); | |
192 else | |
193 ASSERT(!m_plugin->parent()); | |
194 | |
195 if (!m_plugin->pluginShouldPersist()) { | |
196 m_plugin.clear(); | |
197 resetInstance(); | |
198 } | |
199 } | |
153 | 200 |
154 if (m_isCapturingMouseEvents) { | 201 if (m_isCapturingMouseEvents) { |
155 if (Frame* frame = document().frame()) | 202 if (Frame* frame = document().frame()) |
156 frame->eventHandler().setCapturingMouseEventsNode(0); | 203 frame->eventHandler().setCapturingMouseEventsNode(0); |
157 m_isCapturingMouseEvents = false; | 204 m_isCapturingMouseEvents = false; |
158 } | 205 } |
159 | 206 |
160 if (m_NPObject) { | 207 if (m_NPObject) { |
161 _NPN_ReleaseObject(m_NPObject); | 208 _NPN_ReleaseObject(m_NPObject); |
162 m_NPObject = 0; | 209 m_NPObject = 0; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 476 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
430 // FIXME: This code should not depend on renderer! | 477 // FIXME: This code should not depend on renderer! |
431 if (!renderer || useFallback) | 478 if (!renderer || useFallback) |
432 return false; | 479 return false; |
433 | 480 |
434 LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); | 481 LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); |
435 LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); | 482 LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); |
436 m_loadedUrl = url; | 483 m_loadedUrl = url; |
437 | 484 |
438 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re nderer->contentHeight())); | 485 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re nderer->contentHeight())); |
439 bool loadManually = document().isPluginDocument() && !document().containsPlu gins() && toPluginDocument(document()).shouldLoadPluginManually(); | 486 RefPtr<Widget> widget = plugin(); |
440 RefPtr<Widget> widget = frame->loader().client()->createPlugin(contentSize, this, url, paramNames, paramValues, mimeType, loadManually); | 487 |
488 if (!widget) { | |
489 bool loadManually = document().isPluginDocument() && !document().contain sPlugins() && toPluginDocument(document()).shouldLoadPluginManually(); | |
eseidel
2013/11/18 22:26:45
There should only be one way to create a plugin.
wjmaclean
2013/11/25 17:51:56
Done.
| |
490 widget = frame->loader().client()->createPlugin(contentSize, this, url, paramNames, paramValues, mimeType, loadManually); | |
491 } | |
441 | 492 |
442 if (!widget) { | 493 if (!widget) { |
443 if (!renderer->showsUnavailablePluginIndicator()) | 494 if (!renderer->showsUnavailablePluginIndicator()) |
444 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::Plugin Missing); | 495 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::Plugin Missing); |
445 return false; | 496 return false; |
446 } | 497 } |
447 | 498 |
448 renderer->setWidget(widget); | 499 // FIXME: What happens here if our widget *isn't* a plugin container? |
eseidel
2013/11/18 22:26:45
That can't happen. We're an HTMLPluginElement, we
wjmaclean
2013/11/25 17:51:56
Done.
| |
500 if (widget->isPluginContainer()) | |
501 setPlugin(widget); | |
502 else | |
503 ASSERT_NOT_REACHED(); | |
504 renderer->configureWidget(RenderWidget::ConfigureOnAttach); | |
449 document().setContainsPlugins(); | 505 document().setContainsPlugins(); |
450 setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); | 506 setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
451 return true; | 507 return true; |
452 } | 508 } |
453 | 509 |
454 bool HTMLPlugInElement::shouldUsePlugin(const KURL& url, const String& mimeType, bool hasFallback, bool& useFallback) | 510 bool HTMLPlugInElement::shouldUsePlugin(const KURL& url, const String& mimeType, bool hasFallback, bool& useFallback) |
455 { | 511 { |
456 // Allow other plug-ins to win over QuickTime because if the user has | 512 // Allow other plug-ins to win over QuickTime because if the user has |
457 // installed a plug-in that can handle TIFF (which QuickTime can also | 513 // installed a plug-in that can handle TIFF (which QuickTime can also |
458 // handle) they probably intended to override QT. | 514 // handle) they probably intended to override QT. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 fastGetAttribute(HTMLNames::typeAttr); | 550 fastGetAttribute(HTMLNames::typeAttr); |
495 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) | 551 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) |
496 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar edMimeType, url)) { | 552 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar edMimeType, url)) { |
497 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje ct::PluginBlockedByContentSecurityPolicy); | 553 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje ct::PluginBlockedByContentSecurityPolicy); |
498 return false; | 554 return false; |
499 } | 555 } |
500 | 556 |
501 return frame->loader().mixedContentChecker()->canRunInsecureContent(document ().securityOrigin(), url); | 557 return frame->loader().mixedContentChecker()->canRunInsecureContent(document ().securityOrigin(), url); |
502 } | 558 } |
503 | 559 |
560 void HTMLPlugInElement::setPlugin(PassRefPtr<Widget> plugin) | |
561 { | |
562 m_plugin = plugin; | |
504 } | 563 } |
564 | |
565 PassRefPtr<Widget> HTMLPlugInElement::plugin() | |
566 { | |
567 return m_plugin; | |
568 } | |
569 | |
570 } | |
OLD | NEW |