| 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) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) | 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 8 * (http://www.torchmobile.com/) |
| 8 * | 9 * |
| 9 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 11 * modify it under the terms of the GNU Library General Public |
| 11 * License as published by the Free Software Foundation; either | 12 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 13 * version 2 of the License, or (at your option) any later version. |
| 13 * | 14 * |
| 14 * This library is distributed in the hope that it will be useful, | 15 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 18 * Library General Public License for more details. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 d->setContextFeatures(document().contextFeatures()); | 218 d->setContextFeatures(document().contextFeatures()); |
| 218 return d; | 219 return d; |
| 219 } | 220 } |
| 220 | 221 |
| 221 Document* DOMImplementation::createDocument(const String& type, | 222 Document* DOMImplementation::createDocument(const String& type, |
| 222 const DocumentInit& init, | 223 const DocumentInit& init, |
| 223 bool inViewSourceMode) { | 224 bool inViewSourceMode) { |
| 224 if (inViewSourceMode) | 225 if (inViewSourceMode) |
| 225 return HTMLViewSourceDocument::create(init, type); | 226 return HTMLViewSourceDocument::create(init, type); |
| 226 | 227 |
| 227 // Plugins cannot take HTML and XHTML from us, and we don't even need to initi
alize the plugin database for those. | 228 // Plugins cannot take HTML and XHTML from us, and we don't even need to |
| 229 // initialize the plugin database for those. |
| 228 if (type == "text/html") | 230 if (type == "text/html") |
| 229 return HTMLDocument::create(init); | 231 return HTMLDocument::create(init); |
| 230 if (type == "application/xhtml+xml") | 232 if (type == "application/xhtml+xml") |
| 231 return XMLDocument::createXHTML(init); | 233 return XMLDocument::createXHTML(init); |
| 232 | 234 |
| 233 PluginData* pluginData = nullptr; | 235 PluginData* pluginData = nullptr; |
| 234 if (init.frame() && init.frame()->page() && | 236 if (init.frame() && init.frame()->page() && |
| 235 init.frame()->loader().allowPlugins(NotAboutToInstantiatePlugin)) { | 237 init.frame()->loader().allowPlugins(NotAboutToInstantiatePlugin)) { |
| 236 // If the document is being created for the main frame, init.frame()->tree()
.top()->securityContext() returns nullptr. | 238 // If the document is being created for the main frame, |
| 239 // init.frame()->tree().top()->securityContext() returns nullptr. |
| 237 // For that reason, the origin must be retrieved directly from init.url(). | 240 // For that reason, the origin must be retrieved directly from init.url(). |
| 238 if (init.frame()->isMainFrame()) { | 241 if (init.frame()->isMainFrame()) { |
| 239 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(init.url()); | 242 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(init.url()); |
| 240 pluginData = init.frame()->page()->pluginData(origin.get()); | 243 pluginData = init.frame()->page()->pluginData(origin.get()); |
| 241 } else { | 244 } else { |
| 242 pluginData = init.frame()->page()->pluginData( | 245 pluginData = init.frame()->page()->pluginData( |
| 243 init.frame()->tree().top()->securityContext()->getSecurityOrigin()); | 246 init.frame()->tree().top()->securityContext()->getSecurityOrigin()); |
| 244 } | 247 } |
| 245 } | 248 } |
| 246 | 249 |
| 247 // PDF is one image type for which a plugin can override built-in support. | 250 // PDF is one image type for which a plugin can override built-in support. |
| 248 // We do not want QuickTime to take over all image types, obviously. | 251 // We do not want QuickTime to take over all image types, obviously. |
| 249 if ((type == "application/pdf" || type == "text/pdf") && pluginData && | 252 if ((type == "application/pdf" || type == "text/pdf") && pluginData && |
| 250 pluginData->supportsMimeType(type)) | 253 pluginData->supportsMimeType(type)) |
| 251 return PluginDocument::create(init); | 254 return PluginDocument::create(init); |
| 252 // multipart/x-mixed-replace is only supported for images. | 255 // multipart/x-mixed-replace is only supported for images. |
| 253 if (Image::supportsType(type) || type == "multipart/x-mixed-replace") | 256 if (Image::supportsType(type) || type == "multipart/x-mixed-replace") |
| 254 return ImageDocument::create(init); | 257 return ImageDocument::create(init); |
| 255 | 258 |
| 256 // Check to see if the type can be played by our media player, if so create a
MediaDocument | 259 // Check to see if the type can be played by our media player, if so create a |
| 260 // MediaDocument |
| 257 if (HTMLMediaElement::supportsType(ContentType(type))) | 261 if (HTMLMediaElement::supportsType(ContentType(type))) |
| 258 return MediaDocument::create(init); | 262 return MediaDocument::create(init); |
| 259 | 263 |
| 260 // Everything else except text/plain can be overridden by plugins. In particul
ar, Adobe SVG Viewer should be used for SVG, if installed. | 264 // Everything else except text/plain can be overridden by plugins. In |
| 261 // Disallowing plugins to use text/plain prevents plugins from hijacking a fun
damental type that the browser is expected to handle, | 265 // particular, Adobe SVG Viewer should be used for SVG, if installed. |
| 262 // and also serves as an optimization to prevent loading the plugin database i
n the common case. | 266 // Disallowing plugins to use text/plain prevents plugins from hijacking a |
| 267 // fundamental type that the browser is expected to handle, and also serves as |
| 268 // an optimization to prevent loading the plugin database in the common case. |
| 263 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) | 269 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) |
| 264 return PluginDocument::create(init); | 270 return PluginDocument::create(init); |
| 265 if (isTextMIMEType(type)) | 271 if (isTextMIMEType(type)) |
| 266 return TextDocument::create(init); | 272 return TextDocument::create(init); |
| 267 if (type == "image/svg+xml") | 273 if (type == "image/svg+xml") |
| 268 return XMLDocument::createSVG(init); | 274 return XMLDocument::createSVG(init); |
| 269 if (isXMLMIMEType(type)) | 275 if (isXMLMIMEType(type)) |
| 270 return XMLDocument::create(init); | 276 return XMLDocument::create(init); |
| 271 | 277 |
| 272 return HTMLDocument::create(init); | 278 return HTMLDocument::create(init); |
| 273 } | 279 } |
| 274 | 280 |
| 275 DEFINE_TRACE(DOMImplementation) { | 281 DEFINE_TRACE(DOMImplementation) { |
| 276 visitor->trace(m_document); | 282 visitor->trace(m_document); |
| 277 } | 283 } |
| 278 | 284 |
| 279 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |