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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // We don't use m_url, or m_serviceType as they may not be the final values | 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. | 78 // that <object> uses depending on <param> values. |
79 bool HTMLPlugInImageElement::wouldLoadAsNetscapePlugin(const String& url, const
String& serviceType) | 79 bool HTMLPlugInImageElement::wouldLoadAsNetscapePlugin(const String& url, const
String& serviceType) |
80 { | 80 { |
81 ASSERT(document().frame()); | 81 ASSERT(document().frame()); |
82 KURL completedURL; | 82 KURL completedURL; |
83 if (!url.isEmpty()) | 83 if (!url.isEmpty()) |
84 completedURL = document().completeURL(url); | 84 completedURL = document().completeURL(url); |
85 | 85 |
86 FrameLoader* frameLoader = document().frame()->loader(); | 86 FrameLoader& frameLoader = document().frame()->loader(); |
87 ASSERT(frameLoader); | 87 if (frameLoader.client()->objectContentType(completedURL, serviceType, shoul
dPreferPlugInsForImages()) == ObjectContentNetscapePlugin) |
88 if (frameLoader->client()->objectContentType(completedURL, serviceType, shou
ldPreferPlugInsForImages()) == ObjectContentNetscapePlugin) | |
89 return true; | 88 return true; |
90 return false; | 89 return false; |
91 } | 90 } |
92 | 91 |
93 RenderObject* HTMLPlugInImageElement::createRenderer(RenderStyle* style) | 92 RenderObject* HTMLPlugInImageElement::createRenderer(RenderStyle* style) |
94 { | 93 { |
95 // Fallback content breaks the DOM->Renderer class relationship of this | 94 // Fallback content breaks the DOM->Renderer class relationship of this |
96 // class and all superclasses because createObject won't necessarily | 95 // class and all superclasses because createObject won't necessarily |
97 // return a RenderEmbeddedObject, RenderPart or even RenderWidget. | 96 // return a RenderEmbeddedObject, RenderPart or even RenderWidget. |
98 if (useFallbackContent()) | 97 if (useFallbackContent()) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // If the plug-in element already contains a subframe, loadOrRedirectSubfram
e will re-use it. Otherwise, | 146 // If the plug-in element already contains a subframe, loadOrRedirectSubfram
e will re-use it. Otherwise, |
148 // it will create a new frame and set it as the RenderPart's widget, causing
what was previously | 147 // it will create a new frame and set it as the RenderPart's widget, causing
what was previously |
149 // in the widget to be torn down. | 148 // in the widget to be torn down. |
150 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); | 149 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); |
151 } | 150 } |
152 | 151 |
153 bool HTMLPlugInImageElement::loadPlugin(const KURL& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFa
llback) | 152 bool HTMLPlugInImageElement::loadPlugin(const KURL& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFa
llback) |
154 { | 153 { |
155 Frame* frame = document().frame(); | 154 Frame* frame = document().frame(); |
156 | 155 |
157 if (!frame->loader()->allowPlugins(AboutToInstantiatePlugin)) | 156 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) |
158 return false; | 157 return false; |
159 | 158 |
160 if (!pluginIsLoadable(url, mimeType)) | 159 if (!pluginIsLoadable(url, mimeType)) |
161 return false; | 160 return false; |
162 | 161 |
163 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 162 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
164 | 163 |
165 // FIXME: This code should not depend on renderer! | 164 // FIXME: This code should not depend on renderer! |
166 if (!renderer || useFallback) | 165 if (!renderer || useFallback) |
167 return false; | 166 return false; |
168 | 167 |
169 LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); | 168 LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); |
170 LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); | 169 LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); |
171 m_loadedUrl = url; | 170 m_loadedUrl = url; |
172 | 171 |
173 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re
nderer->contentHeight())); | 172 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re
nderer->contentHeight())); |
174 bool loadManually = document().isPluginDocument() && !frame->loader()->conta
insPlugins() && toPluginDocument(document()).shouldLoadPluginManually(); | 173 bool loadManually = document().isPluginDocument() && !frame->loader().contai
nsPlugins() && toPluginDocument(document()).shouldLoadPluginManually(); |
175 RefPtr<Widget> widget = frame->loader()->client()->createPlugin(contentSize,
this, url, paramNames, paramValues, mimeType, loadManually); | 174 RefPtr<Widget> widget = frame->loader().client()->createPlugin(contentSize,
this, url, paramNames, paramValues, mimeType, loadManually); |
176 | 175 |
177 if (!widget) { | 176 if (!widget) { |
178 if (!renderer->showsUnavailablePluginIndicator()) | 177 if (!renderer->showsUnavailablePluginIndicator()) |
179 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::Plugin
Missing); | 178 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::Plugin
Missing); |
180 return false; | 179 return false; |
181 } | 180 } |
182 | 181 |
183 renderer->setWidget(widget); | 182 renderer->setWidget(widget); |
184 frame->loader()->setContainsPlugins(); | 183 frame->loader().setContainsPlugins(); |
185 setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); | 184 setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
186 return true; | 185 return true; |
187 } | 186 } |
188 | 187 |
189 bool HTMLPlugInImageElement::shouldUsePlugin(const KURL& url, const String& mime
Type, bool hasFallback, bool& useFallback) | 188 bool HTMLPlugInImageElement::shouldUsePlugin(const KURL& url, const String& mime
Type, bool hasFallback, bool& useFallback) |
190 { | 189 { |
191 // Allow other plug-ins to win over QuickTime because if the user has instal
led a plug-in that | 190 // Allow other plug-ins to win over QuickTime because if the user has instal
led a plug-in that |
192 // can handle TIFF (which QuickTime can also handle) they probably intended
to override QT. | 191 // can handle TIFF (which QuickTime can also handle) they probably intended
to override QT. |
193 if (document().frame()->page() && (mimeType == "image/tiff" || mimeType == "
image/tif" || mimeType == "image/x-tiff")) { | 192 if (document().frame()->page() && (mimeType == "image/tiff" || mimeType == "
image/tif" || mimeType == "image/x-tiff")) { |
194 const PluginData* pluginData = document().frame()->page()->pluginData(); | 193 const PluginData* pluginData = document().frame()->page()->pluginData(); |
195 String pluginName = pluginData ? pluginData->pluginNameForMimeType(mimeT
ype) : String(); | 194 String pluginName = pluginData ? pluginData->pluginNameForMimeType(mimeT
ype) : String(); |
196 if (!pluginName.isEmpty() && !pluginName.contains("QuickTime", false)) | 195 if (!pluginName.isEmpty() && !pluginName.contains("QuickTime", false)) |
197 return true; | 196 return true; |
198 } | 197 } |
199 | 198 |
200 ObjectContentType objectType = document().frame()->loader()->client()->objec
tContentType(url, mimeType, shouldPreferPlugInsForImages()); | 199 ObjectContentType objectType = document().frame()->loader().client()->object
ContentType(url, mimeType, shouldPreferPlugInsForImages()); |
201 // If an object's content can't be handled and it has no fallback, let | 200 // If an object's content can't be handled and it has no fallback, let |
202 // it be handled as a plugin to show the broken plugin icon. | 201 // it be handled as a plugin to show the broken plugin icon. |
203 useFallback = objectType == ObjectContentNone && hasFallback; | 202 useFallback = objectType == ObjectContentNone && hasFallback; |
204 return objectType == ObjectContentNone || objectType == ObjectContentNetscap
ePlugin || objectType == ObjectContentOtherPlugin; | 203 return objectType == ObjectContentNone || objectType == ObjectContentNetscap
ePlugin || objectType == ObjectContentOtherPlugin; |
205 | 204 |
206 } | 205 } |
207 | 206 |
208 bool HTMLPlugInImageElement::pluginIsLoadable(const KURL& url, const String& mim
eType) | 207 bool HTMLPlugInImageElement::pluginIsLoadable(const KURL& url, const String& mim
eType) |
209 { | 208 { |
210 Frame* frame = document().frame(); | 209 Frame* frame = document().frame(); |
(...skipping 16 matching lines...) Expand all Loading... |
227 | 226 |
228 String declaredMimeType = document().isPluginDocument() && document().ownerE
lement() ? | 227 String declaredMimeType = document().isPluginDocument() && document().ownerE
lement() ? |
229 document().ownerElement()->fastGetAttribute(HTMLNames::typeAttr) : | 228 document().ownerElement()->fastGetAttribute(HTMLNames::typeAttr) : |
230 fastGetAttribute(HTMLNames::typeAttr); | 229 fastGetAttribute(HTMLNames::typeAttr); |
231 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) | 230 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) |
232 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar
edMimeType, url)) { | 231 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar
edMimeType, url)) { |
233 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); | 232 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); |
234 return false; | 233 return false; |
235 } | 234 } |
236 | 235 |
237 if (frame->loader() && !frame->loader()->mixedContentChecker()->canRunInsecu
reContent(document().securityOrigin(), url)) | 236 if (!frame->loader().mixedContentChecker()->canRunInsecureContent(document()
.securityOrigin(), url)) |
238 return false; | 237 return false; |
239 return true; | 238 return true; |
240 } | 239 } |
241 | 240 |
242 } // namespace WebCore | 241 } // namespace WebCore |
OLD | NEW |