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/dom/shadow/ShadowRoot.h" | 33 #include "core/dom/shadow/ShadowRoot.h" |
33 #include "core/events/Event.h" | 34 #include "core/events/Event.h" |
34 #include "core/frame/ContentSecurityPolicy.h" | 35 #include "core/frame/ContentSecurityPolicy.h" |
35 #include "core/frame/Frame.h" | 36 #include "core/frame/Frame.h" |
36 #include "core/html/HTMLImageLoader.h" | 37 #include "core/html/HTMLImageLoader.h" |
37 #include "core/html/PluginDocument.h" | 38 #include "core/html/PluginDocument.h" |
38 #include "core/html/shadow/HTMLContentElement.h" | 39 #include "core/html/shadow/HTMLContentElement.h" |
39 #include "core/loader/FrameLoaderClient.h" | 40 #include "core/loader/FrameLoaderClient.h" |
40 #include "core/page/EventHandler.h" | 41 #include "core/page/EventHandler.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 if (url.isEmpty() && mimeType.isEmpty()) | 404 if (url.isEmpty() && mimeType.isEmpty()) |
404 return false; | 405 return false; |
405 | 406 |
406 // FIXME: None of this code should use renderers! | 407 // FIXME: None of this code should use renderers! |
407 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 408 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
408 ASSERT(renderer); | 409 ASSERT(renderer); |
409 if (!renderer) | 410 if (!renderer) |
410 return false; | 411 return false; |
411 | 412 |
412 KURL completedURL = document().completeURL(url); | 413 KURL completedURL = document().completeURL(url); |
| 414 if (!pluginIsLoadable(completedURL, mimeType)) |
| 415 return false; |
413 | 416 |
414 bool useFallback; | 417 bool useFallback; |
415 if (shouldUsePlugin(completedURL, mimeType, renderer->hasFallbackContent(),
useFallback)) | 418 if (shouldUsePlugin(completedURL, mimeType, renderer->hasFallbackContent(),
useFallback)) |
416 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa
llback); | 419 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa
llback); |
417 | 420 |
418 // If the plug-in element already contains a subframe, | 421 // If the plug-in element already contains a subframe, |
419 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new | 422 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new |
420 // frame and set it as the RenderPart's widget, causing what was previously | 423 // frame and set it as the RenderPart's widget, causing what was previously |
421 // in the widget to be torn down. | 424 // in the widget to be torn down. |
422 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); | 425 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); |
423 } | 426 } |
424 | 427 |
425 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k) | 428 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k) |
426 { | 429 { |
427 Frame* frame = document().frame(); | 430 Frame* frame = document().frame(); |
428 | 431 |
429 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) | 432 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) |
430 return false; | 433 return false; |
431 | 434 |
432 if (!pluginIsLoadable(url, mimeType)) | |
433 return false; | |
434 | |
435 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 435 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
436 // FIXME: This code should not depend on renderer! | 436 // FIXME: This code should not depend on renderer! |
437 if (!renderer || useFallback) | 437 if (!renderer || useFallback) |
438 return false; | 438 return false; |
439 | 439 |
440 WTF_LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); | 440 WTF_LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); |
441 WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); | 441 WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); |
442 m_loadedUrl = url; | 442 m_loadedUrl = url; |
443 | 443 |
444 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re
nderer->contentHeight())); | 444 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re
nderer->contentHeight())); |
(...skipping 25 matching lines...) Expand all Loading... |
470 } | 470 } |
471 | 471 |
472 ObjectContentType objectType = document().frame()->loader().client()->object
ContentType(url, mimeType, shouldPreferPlugInsForImages()); | 472 ObjectContentType objectType = document().frame()->loader().client()->object
ContentType(url, mimeType, shouldPreferPlugInsForImages()); |
473 // If an object's content can't be handled and it has no fallback, let | 473 // If an object's content can't be handled and it has no fallback, let |
474 // it be handled as a plugin to show the broken plugin icon. | 474 // it be handled as a plugin to show the broken plugin icon. |
475 useFallback = objectType == ObjectContentNone && hasFallback; | 475 useFallback = objectType == ObjectContentNone && hasFallback; |
476 return objectType == ObjectContentNone || objectType == ObjectContentNetscap
ePlugin || objectType == ObjectContentOtherPlugin; | 476 return objectType == ObjectContentNone || objectType == ObjectContentNetscap
ePlugin || objectType == ObjectContentOtherPlugin; |
477 | 477 |
478 } | 478 } |
479 | 479 |
| 480 void HTMLPlugInElement::dispatchErrorEvent() |
| 481 { |
| 482 if (document().isPluginDocument() && document().ownerElement()) |
| 483 document().ownerElement()->dispatchEvent(Event::create(EventTypeNames::e
rror)); |
| 484 else |
| 485 dispatchEvent(Event::create(EventTypeNames::error)); |
| 486 } |
| 487 |
480 bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType
) | 488 bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType
) |
481 { | 489 { |
482 Frame* frame = document().frame(); | 490 Frame* frame = document().frame(); |
483 Settings* settings = frame->settings(); | 491 Settings* settings = frame->settings(); |
484 if (!settings) | 492 if (!settings) |
485 return false; | 493 return false; |
486 | 494 |
487 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType) && !settings->javaEnabl
ed()) | 495 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType) && !settings->javaEnabl
ed()) |
488 return false; | 496 return false; |
489 | 497 |
(...skipping 27 matching lines...) Expand all Loading... |
517 if (root.isOldestAuthorShadowRoot()) | 525 if (root.isOldestAuthorShadowRoot()) |
518 lazyReattachIfAttached(); | 526 lazyReattachIfAttached(); |
519 } | 527 } |
520 | 528 |
521 bool HTMLPlugInElement::useFallbackContent() const | 529 bool HTMLPlugInElement::useFallbackContent() const |
522 { | 530 { |
523 return hasAuthorShadowRoot(); | 531 return hasAuthorShadowRoot(); |
524 } | 532 } |
525 | 533 |
526 } | 534 } |
OLD | NEW |