| 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 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/html/HTMLPlugInElement.h" | 24 #include "core/html/HTMLPlugInElement.h" |
| 25 | 25 |
| 26 #include "CSSPropertyNames.h" | 26 #include "CSSPropertyNames.h" |
| 27 #include "HTMLNames.h" | 27 #include "HTMLNames.h" |
| 28 #include "bindings/v8/ScriptController.h" | 28 #include "bindings/v8/ScriptController.h" |
| 29 #include "bindings/v8/npruntime_impl.h" | 29 #include "bindings/v8/npruntime_impl.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/Node.h" |
| 31 #include "core/dom/PostAttachCallbacks.h" | 32 #include "core/dom/PostAttachCallbacks.h" |
| 32 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
| 33 #include "core/frame/ContentSecurityPolicy.h" | 34 #include "core/frame/ContentSecurityPolicy.h" |
| 34 #include "core/frame/Frame.h" | 35 #include "core/frame/Frame.h" |
| 35 #include "core/html/HTMLImageLoader.h" | 36 #include "core/html/HTMLImageLoader.h" |
| 36 #include "core/html/PluginDocument.h" | 37 #include "core/html/PluginDocument.h" |
| 37 #include "core/loader/FrameLoaderClient.h" | 38 #include "core/loader/FrameLoaderClient.h" |
| 38 #include "core/page/EventHandler.h" | 39 #include "core/page/EventHandler.h" |
| 39 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
| 40 #include "core/page/Settings.h" | 41 #include "core/page/Settings.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 if (url.isEmpty() && mimeType.isEmpty()) | 401 if (url.isEmpty() && mimeType.isEmpty()) |
| 401 return false; | 402 return false; |
| 402 | 403 |
| 403 // FIXME: None of this code should use renderers! | 404 // FIXME: None of this code should use renderers! |
| 404 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 405 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
| 405 ASSERT(renderer); | 406 ASSERT(renderer); |
| 406 if (!renderer) | 407 if (!renderer) |
| 407 return false; | 408 return false; |
| 408 | 409 |
| 409 KURL completedURL = document().completeURL(url); | 410 KURL completedURL = document().completeURL(url); |
| 411 if (!pluginIsLoadable(completedURL, mimeType)) |
| 412 return false; |
| 410 | 413 |
| 411 bool useFallback; | 414 bool useFallback; |
| 412 if (shouldUsePlugin(completedURL, mimeType, renderer->hasFallbackContent(),
useFallback)) | 415 if (shouldUsePlugin(completedURL, mimeType, renderer->hasFallbackContent(),
useFallback)) |
| 413 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa
llback); | 416 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa
llback); |
| 414 | 417 |
| 415 // If the plug-in element already contains a subframe, | 418 // If the plug-in element already contains a subframe, |
| 416 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new | 419 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new |
| 417 // frame and set it as the RenderPart's widget, causing what was previously | 420 // frame and set it as the RenderPart's widget, causing what was previously |
| 418 // in the widget to be torn down. | 421 // in the widget to be torn down. |
| 419 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); | 422 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); |
| 420 } | 423 } |
| 421 | 424 |
| 422 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k) | 425 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k) |
| 423 { | 426 { |
| 424 Frame* frame = document().frame(); | 427 Frame* frame = document().frame(); |
| 425 | 428 |
| 426 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) | 429 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) |
| 427 return false; | 430 return false; |
| 428 | 431 |
| 429 if (!pluginIsLoadable(url, mimeType)) | |
| 430 return false; | |
| 431 | |
| 432 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 432 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
| 433 // FIXME: This code should not depend on renderer! | 433 // FIXME: This code should not depend on renderer! |
| 434 if (!renderer || useFallback) | 434 if (!renderer || useFallback) |
| 435 return false; | 435 return false; |
| 436 | 436 |
| 437 LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); | 437 LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); |
| 438 LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); | 438 LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); |
| 439 m_loadedUrl = url; | 439 m_loadedUrl = url; |
| 440 | 440 |
| 441 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re
nderer->contentHeight())); | 441 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re
nderer->contentHeight())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 467 } | 467 } |
| 468 | 468 |
| 469 ObjectContentType objectType = document().frame()->loader().client()->object
ContentType(url, mimeType, shouldPreferPlugInsForImages()); | 469 ObjectContentType objectType = document().frame()->loader().client()->object
ContentType(url, mimeType, shouldPreferPlugInsForImages()); |
| 470 // If an object's content can't be handled and it has no fallback, let | 470 // If an object's content can't be handled and it has no fallback, let |
| 471 // it be handled as a plugin to show the broken plugin icon. | 471 // it be handled as a plugin to show the broken plugin icon. |
| 472 useFallback = objectType == ObjectContentNone && hasFallback; | 472 useFallback = objectType == ObjectContentNone && hasFallback; |
| 473 return objectType == ObjectContentNone || objectType == ObjectContentNetscap
ePlugin || objectType == ObjectContentOtherPlugin; | 473 return objectType == ObjectContentNone || objectType == ObjectContentNetscap
ePlugin || objectType == ObjectContentOtherPlugin; |
| 474 | 474 |
| 475 } | 475 } |
| 476 | 476 |
| 477 void HTMLPlugInElement::dispatchErrorEvent() |
| 478 { |
| 479 if (document().isPluginDocument() && document().ownerElement()) |
| 480 document().ownerElement()->dispatchEvent(Event::create(EventTypeNames::e
rror)); |
| 481 else |
| 482 dispatchEvent(Event::create(EventTypeNames::error)); |
| 483 } |
| 484 |
| 477 bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType
) | 485 bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType
) |
| 478 { | 486 { |
| 479 Frame* frame = document().frame(); | 487 Frame* frame = document().frame(); |
| 480 Settings* settings = frame->settings(); | 488 Settings* settings = frame->settings(); |
| 481 if (!settings) | 489 if (!settings) |
| 482 return false; | 490 return false; |
| 483 | 491 |
| 484 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType) && !settings->isJavaEna
bled()) | 492 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType) && !settings->isJavaEna
bled()) |
| 485 return false; | 493 return false; |
| 486 | 494 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 498 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) | 506 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) |
| 499 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar
edMimeType, url)) { | 507 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar
edMimeType, url)) { |
| 500 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); | 508 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); |
| 501 return false; | 509 return false; |
| 502 } | 510 } |
| 503 | 511 |
| 504 return frame->loader().mixedContentChecker()->canRunInsecureContent(document
().securityOrigin(), url); | 512 return frame->loader().mixedContentChecker()->canRunInsecureContent(document
().securityOrigin(), url); |
| 505 } | 513 } |
| 506 | 514 |
| 507 } | 515 } |
| OLD | NEW |