| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #include "core/html/PluginDocument.h" | 24 #include "core/html/PluginDocument.h" |
| 25 #include "core/loader/FrameLoader.h" | 25 #include "core/loader/FrameLoader.h" |
| 26 #include "core/loader/FrameLoaderClient.h" | 26 #include "core/loader/FrameLoaderClient.h" |
| 27 #include "core/frame/ContentSecurityPolicy.h" | 27 #include "core/frame/ContentSecurityPolicy.h" |
| 28 #include "core/frame/Frame.h" | 28 #include "core/frame/Frame.h" |
| 29 #include "core/page/Page.h" | 29 #include "core/page/Page.h" |
| 30 #include "core/page/Settings.h" | 30 #include "core/page/Settings.h" |
| 31 #include "platform/Logging.h" | 31 #include "platform/Logging.h" |
| 32 #include "core/platform/MIMETypeRegistry.h" | 32 #include "core/platform/MIMETypeRegistry.h" |
| 33 #include "core/platform/graphics/Image.h" | |
| 34 #include "core/plugins/PluginData.h" | 33 #include "core/plugins/PluginData.h" |
| 35 #include "core/rendering/RenderEmbeddedObject.h" | 34 #include "core/rendering/RenderEmbeddedObject.h" |
| 36 #include "core/rendering/RenderImage.h" | |
| 37 #include "platform/UserGestureIndicator.h" | 35 #include "platform/UserGestureIndicator.h" |
| 38 #include "weborigin/SecurityOrigin.h" | 36 #include "weborigin/SecurityOrigin.h" |
| 39 | 37 |
| 40 namespace WebCore { | 38 namespace WebCore { |
| 41 | 39 |
| 42 using namespace HTMLNames; | 40 using namespace HTMLNames; |
| 43 | 41 |
| 44 typedef Vector<RefPtr<HTMLPlugInImageElement> > HTMLPlugInImageElementList; | 42 typedef Vector<RefPtr<HTMLPlugInImageElement> > HTMLPlugInImageElementList; |
| 45 | 43 |
| 46 static const int sizingTinyDimensionThreshold = 40; | 44 static const int sizingTinyDimensionThreshold = 40; |
| 47 static const int sizingSmallWidthThreshold = 250; | 45 static const int sizingSmallWidthThreshold = 250; |
| 48 static const int sizingMediumWidthThreshold = 450; | 46 static const int sizingMediumWidthThreshold = 450; |
| 49 static const int sizingMediumHeightThreshold = 300; | 47 static const int sizingMediumHeightThreshold = 300; |
| 50 static const float sizingFullPageAreaRatioThreshold = 0.96; | 48 static const float sizingFullPageAreaRatioThreshold = 0.96; |
| 51 static const float autostartSoonAfterUserGestureThreshold = 5.0; | 49 static const float autostartSoonAfterUserGestureThreshold = 5.0; |
| 52 | 50 |
| 53 HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
ument& document, bool createdByParser, PreferPlugInsForImagesOption preferPlugIn
sForImagesOption) | 51 HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
ument& document, bool createdByParser, PreferPlugInsForImagesOption preferPlugIn
sForImagesOption) |
| 54 : HTMLPlugInElement(tagName, document, createdByParser, preferPlugInsForImag
esOption) | 52 : HTMLPlugInElement(tagName, document, createdByParser, preferPlugInsForImag
esOption) |
| 55 , m_createdDuringUserGesture(UserGestureIndicator::processingUserGesture()) | 53 , m_createdDuringUserGesture(UserGestureIndicator::processingUserGesture()) |
| 56 { | 54 { |
| 57 setHasCustomStyleCallbacks(); | |
| 58 } | 55 } |
| 59 | 56 |
| 60 HTMLPlugInImageElement::~HTMLPlugInImageElement() | 57 HTMLPlugInImageElement::~HTMLPlugInImageElement() |
| 61 { | 58 { |
| 62 } | 59 } |
| 63 | 60 |
| 64 // We don't use m_url, as it may not be the final URL that the object loads, | |
| 65 // depending on <param> values. | |
| 66 bool HTMLPlugInImageElement::allowedToLoadFrameURL(const String& url) | |
| 67 { | |
| 68 KURL completeURL = document().completeURL(url); | |
| 69 | |
| 70 if (contentFrame() && protocolIsJavaScript(completeURL) | |
| 71 && !document().securityOrigin()->canAccess(contentDocument()->securityOr
igin())) | |
| 72 return false; | |
| 73 | |
| 74 return document().frame()->isURLAllowed(completeURL); | |
| 75 } | |
| 76 | |
| 77 // We don't use m_url, or m_serviceType as they may not be the final values | |
| 78 // that <object> uses depending on <param> values. | |
| 79 bool HTMLPlugInImageElement::wouldLoadAsNetscapePlugin(const String& url, const
String& serviceType) | |
| 80 { | |
| 81 ASSERT(document().frame()); | |
| 82 KURL completedURL; | |
| 83 if (!url.isEmpty()) | |
| 84 completedURL = document().completeURL(url); | |
| 85 | |
| 86 FrameLoader& frameLoader = document().frame()->loader(); | |
| 87 if (frameLoader.client()->objectContentType(completedURL, serviceType, shoul
dPreferPlugInsForImages()) == ObjectContentNetscapePlugin) | |
| 88 return true; | |
| 89 return false; | |
| 90 } | |
| 91 | |
| 92 RenderObject* HTMLPlugInImageElement::createRenderer(RenderStyle* style) | |
| 93 { | |
| 94 // Fallback content breaks the DOM->Renderer class relationship of this | |
| 95 // class and all superclasses because createObject won't necessarily | |
| 96 // return a RenderEmbeddedObject, RenderPart or even RenderWidget. | |
| 97 if (useFallbackContent()) | |
| 98 return RenderObject::createObject(this, style); | |
| 99 | |
| 100 if (isImageType()) { | |
| 101 RenderImage* image = new RenderImage(this); | |
| 102 image->setImageResource(RenderImageResource::create()); | |
| 103 return image; | |
| 104 } | |
| 105 | |
| 106 return new RenderEmbeddedObject(this); | |
| 107 } | |
| 108 | |
| 109 void HTMLPlugInImageElement::willRecalcStyle(StyleRecalcChange) | |
| 110 { | |
| 111 // FIXME: Why is this necessary? Manual re-attach is almost always wrong. | |
| 112 if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageTy
pe()) | |
| 113 reattach(); | |
| 114 } | |
| 115 | |
| 116 void HTMLPlugInImageElement::finishParsingChildren() | |
| 117 { | |
| 118 HTMLPlugInElement::finishParsingChildren(); | |
| 119 if (useFallbackContent()) | |
| 120 return; | |
| 121 | |
| 122 setNeedsWidgetUpdate(true); | |
| 123 if (inDocument()) | |
| 124 setNeedsStyleRecalc(); | |
| 125 } | |
| 126 | |
| 127 bool HTMLPlugInImageElement::requestObject(const String& url, const String& mime
Type, const Vector<String>& paramNames, const Vector<String>& paramValues) | 61 bool HTMLPlugInImageElement::requestObject(const String& url, const String& mime
Type, const Vector<String>& paramNames, const Vector<String>& paramValues) |
| 128 { | 62 { |
| 129 if (url.isEmpty() && mimeType.isEmpty()) | 63 if (url.isEmpty() && mimeType.isEmpty()) |
| 130 return false; | 64 return false; |
| 131 | 65 |
| 132 // FIXME: None of this code should use renderers! | 66 // FIXME: None of this code should use renderers! |
| 133 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 67 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
| 134 ASSERT(renderer); | 68 ASSERT(renderer); |
| 135 if (!renderer) | 69 if (!renderer) |
| 136 return false; | 70 return false; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); | 166 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); |
| 233 return false; | 167 return false; |
| 234 } | 168 } |
| 235 | 169 |
| 236 if (!frame->loader().mixedContentChecker()->canRunInsecureContent(document()
.securityOrigin(), url)) | 170 if (!frame->loader().mixedContentChecker()->canRunInsecureContent(document()
.securityOrigin(), url)) |
| 237 return false; | 171 return false; |
| 238 return true; | 172 return true; |
| 239 } | 173 } |
| 240 | 174 |
| 241 } // namespace WebCore | 175 } // namespace WebCore |
| OLD | NEW |