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 27 matching lines...) Expand all Loading... |
38 #include "core/html/PluginDocument.h" | 38 #include "core/html/PluginDocument.h" |
39 #include "core/input/EventHandler.h" | 39 #include "core/input/EventHandler.h" |
40 #include "core/inspector/ConsoleMessage.h" | 40 #include "core/inspector/ConsoleMessage.h" |
41 #include "core/layout/LayoutImage.h" | 41 #include "core/layout/LayoutImage.h" |
42 #include "core/layout/LayoutPart.h" | 42 #include "core/layout/LayoutPart.h" |
43 #include "core/loader/FrameLoaderClient.h" | 43 #include "core/loader/FrameLoaderClient.h" |
44 #include "core/loader/MixedContentChecker.h" | 44 #include "core/loader/MixedContentChecker.h" |
45 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
46 #include "core/page/scrolling/ScrollingCoordinator.h" | 46 #include "core/page/scrolling/ScrollingCoordinator.h" |
47 #include "core/plugins/PluginView.h" | 47 #include "core/plugins/PluginView.h" |
| 48 #include "platform/Histogram.h" |
48 #include "platform/Logging.h" | 49 #include "platform/Logging.h" |
49 #include "platform/MIMETypeFromURL.h" | 50 #include "platform/MIMETypeFromURL.h" |
50 #include "platform/MIMETypeRegistry.h" | 51 #include "platform/MIMETypeRegistry.h" |
51 #include "platform/Widget.h" | 52 #include "platform/Widget.h" |
52 #include "platform/network/ResourceRequest.h" | 53 #include "platform/network/ResourceRequest.h" |
53 #include "platform/plugins/PluginData.h" | 54 #include "platform/plugins/PluginData.h" |
54 #include "public/platform/WebURLRequest.h" | 55 #include "public/platform/WebURLRequest.h" |
55 | 56 |
56 namespace blink { | 57 namespace blink { |
57 | 58 |
58 using namespace HTMLNames; | 59 using namespace HTMLNames; |
59 | 60 |
| 61 namespace { |
| 62 |
| 63 // Used for histograms, do not change the order. |
| 64 enum PluginRequestObjectResult { |
| 65 PluginRequestObjectResultFailure = 0, |
| 66 PluginRequestObjectResultSuccess = 1, |
| 67 // Keep at the end. |
| 68 PluginRequestObjectResultMax |
| 69 }; |
| 70 |
| 71 } // anonymous namespace |
| 72 |
60 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc
, bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio
n) | 73 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc
, bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio
n) |
61 : HTMLFrameOwnerElement(tagName, doc) | 74 : HTMLFrameOwnerElement(tagName, doc) |
62 , m_isDelayingLoadEvent(false) | 75 , m_isDelayingLoadEvent(false) |
63 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay | 76 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay |
64 // widget updates until after all children are parsed. For HTMLEmbedElement | 77 // widget updates until after all children are parsed. For HTMLEmbedElement |
65 // this delay is unnecessary, but it is simpler to make both classes share | 78 // this delay is unnecessary, but it is simpler to make both classes share |
66 // the same codepath in this class. | 79 // the same codepath in this class. |
67 , m_needsWidgetUpdate(!createdByParser) | 80 , m_needsWidgetUpdate(!createdByParser) |
68 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) | 81 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) |
69 { | 82 { |
(...skipping 20 matching lines...) Expand all Loading... |
90 if (m_persistedPluginWidget->isPluginView()) { | 103 if (m_persistedPluginWidget->isPluginView()) { |
91 m_persistedPluginWidget->hide(); | 104 m_persistedPluginWidget->hide(); |
92 disposeWidgetSoon(m_persistedPluginWidget.release()); | 105 disposeWidgetSoon(m_persistedPluginWidget.release()); |
93 } else { | 106 } else { |
94 ASSERT(m_persistedPluginWidget->isFrameView() || m_persistedPluginWi
dget->isRemoteFrameView()); | 107 ASSERT(m_persistedPluginWidget->isFrameView() || m_persistedPluginWi
dget->isRemoteFrameView()); |
95 } | 108 } |
96 } | 109 } |
97 m_persistedPluginWidget = widget; | 110 m_persistedPluginWidget = widget; |
98 } | 111 } |
99 | 112 |
| 113 bool HTMLPlugInElement::requestObjectInternal(const String& url, const String& m
imeType, const Vector<String>& paramNames, const Vector<String>& paramValues) |
| 114 { |
| 115 if (url.isEmpty() && mimeType.isEmpty()) |
| 116 return false; |
| 117 |
| 118 if (protocolIsJavaScript(url)) |
| 119 return false; |
| 120 |
| 121 KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url); |
| 122 if (!allowedToLoadObject(completedURL, mimeType)) |
| 123 return false; |
| 124 |
| 125 bool useFallback; |
| 126 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallba
ck)) { |
| 127 // If the plugin element already contains a subframe, |
| 128 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a |
| 129 // new frame and set it as the LayoutPart's widget, causing what was |
| 130 // previously in the widget to be torn down. |
| 131 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); |
| 132 } |
| 133 |
| 134 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFallba
ck, true); |
| 135 } |
| 136 |
| 137 |
100 bool HTMLPlugInElement::canProcessDrag() const | 138 bool HTMLPlugInElement::canProcessDrag() const |
101 { | 139 { |
102 return pluginWidget() && pluginWidget()->isPluginView() && toPluginView(plug
inWidget())->canProcessDrag(); | 140 return pluginWidget() && pluginWidget()->isPluginView() && toPluginView(plug
inWidget())->canProcessDrag(); |
103 } | 141 } |
104 | 142 |
105 bool HTMLPlugInElement::canStartSelection() const | 143 bool HTMLPlugInElement::canStartSelection() const |
106 { | 144 { |
107 return useFallbackContent() && Node::canStartSelection(); | 145 return useFallbackContent() && Node::canStartSelection(); |
108 } | 146 } |
109 | 147 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 { | 477 { |
440 ASSERT(document().frame()); | 478 ASSERT(document().frame()); |
441 KURL completedURL; | 479 KURL completedURL; |
442 if (!url.isEmpty()) | 480 if (!url.isEmpty()) |
443 completedURL = document().completeURL(url); | 481 completedURL = document().completeURL(url); |
444 return document().frame()->loader().client()->getObjectContentType(completed
URL, serviceType, shouldPreferPlugInsForImages()) == ObjectContentNetscapePlugin
; | 482 return document().frame()->loader().client()->getObjectContentType(completed
URL, serviceType, shouldPreferPlugInsForImages()) == ObjectContentNetscapePlugin
; |
445 } | 483 } |
446 | 484 |
447 bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues) | 485 bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues) |
448 { | 486 { |
449 if (url.isEmpty() && mimeType.isEmpty()) | 487 bool result = requestObjectInternal(url, mimeType, paramNames, paramValues); |
450 return false; | |
451 | 488 |
452 if (protocolIsJavaScript(url)) | 489 DEFINE_STATIC_LOCAL(EnumerationHistogram, resultHistogram, ("Plugin.RequestO
bjectResult", PluginRequestObjectResultMax)); |
453 return false; | 490 resultHistogram.count(result ? PluginRequestObjectResultSuccess : PluginRequ
estObjectResultFailure); |
454 | 491 |
455 KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url); | 492 return result; |
456 if (!allowedToLoadObject(completedURL, mimeType)) | |
457 return false; | |
458 | |
459 bool useFallback; | |
460 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallba
ck)) { | |
461 // If the plugin element already contains a subframe, | |
462 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a | |
463 // new frame and set it as the LayoutPart's widget, causing what was | |
464 // previously in the widget to be torn down. | |
465 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); | |
466 } | |
467 | |
468 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFallba
ck, true); | |
469 } | 493 } |
470 | 494 |
471 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k, bool requireLayoutObject) | 495 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k, bool requireLayoutObject) |
472 { | 496 { |
473 if (!allowedToLoadPlugin(url, mimeType)) | 497 if (!allowedToLoadPlugin(url, mimeType)) |
474 return false; | 498 return false; |
475 | 499 |
476 LocalFrame* frame = document().frame(); | 500 LocalFrame* frame = document().frame(); |
477 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) | 501 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) |
478 return false; | 502 return false; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 619 |
596 void HTMLPlugInElement::lazyReattachIfNeeded() | 620 void HTMLPlugInElement::lazyReattachIfNeeded() |
597 { | 621 { |
598 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma
geType()) { | 622 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma
geType()) { |
599 lazyReattachIfAttached(); | 623 lazyReattachIfAttached(); |
600 setPersistedPluginWidget(nullptr); | 624 setPersistedPluginWidget(nullptr); |
601 } | 625 } |
602 } | 626 } |
603 | 627 |
604 } // namespace blink | 628 } // namespace blink |
OLD | NEW |