PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, bool inViewSourceMode) { if (inViewSourceMode) { if (type == "text/html" || type == "application/xhtml+xml" || type == "image/svg+xml" || isTextMIMEType(type) || isXMLMIMEType(type)) return HTMLViewSourceDocument::create(frame, type); } // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. if (type == "text/html") return HTMLDocument::create(frame); if (type == "application/xhtml+xml") return Document::createXHTML(frame); #if ENABLE(FTPDIR) // Plugins cannot take FTP from us either if (type == "application/x-ftp-directory") return FTPDirectoryDocument::create(frame); #endif PluginData* pluginData = 0; if (frame && frame->page() && frame->page()->settings()->arePluginsEnabled()) pluginData = frame->page()->pluginData(); // PDF is one image type for which a plugin can override built-in support. // We do not want QuickTime to take over all image types, obviously. if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type)) return PluginDocument::create(frame); if (Image::supportsType(type)) return ImageDocument::create(frame); #if ENABLE(VIDEO) // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument if (MediaPlayer::supportsType(type)) return MediaDocument::create(frame); #endif // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed. // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle, // and also serves as an optimization to prevent loading the plug-in database in the common case. if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) return PluginDocument::create(frame); if (isTextMIMEType(type)) return TextDocument::create(frame); #if ENABLE(SVG) if (type == "image/svg+xml") { #if ENABLE(DASHBOARD_SUPPORT) Settings* settings = frame ? frame->settings() : 0; if (!settings || !settings->usesDashboardBackwardCompatibilityMode()) #endif return SVGDocument::create(frame); } #endif if (isXMLMIMEType(type)) return Document::create(frame); return HTMLDocument::create(frame); }
PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url) { // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. if (type == "text/html") return HTMLDocument::create(frame, url); if (type == "application/xhtml+xml") return Document::createXHTML(frame, url); #if ENABLE(FTPDIR) // Plugins cannot take FTP from us either if (type == "application/x-ftp-directory") return FTPDirectoryDocument::create(frame, url); #endif PluginData* pluginData = 0; PluginData::AllowedPluginTypes allowedPluginTypes = PluginData::OnlyApplicationPlugins; if (frame && frame->page()) { if (frame->loader().subframeLoader().allowPlugins(NotAboutToInstantiatePlugin)) allowedPluginTypes = PluginData::AllPlugins; pluginData = &frame->page()->pluginData(); } // PDF is one image type for which a plugin can override built-in support. // We do not want QuickTime to take over all image types, obviously. if ((MIMETypeRegistry::isPDFOrPostScriptMIMEType(type)) && pluginData && pluginData->supportsMimeType(type, allowedPluginTypes)) return PluginDocument::create(frame, url); if (Image::supportsType(type)) return ImageDocument::create(frame, url); #if ENABLE(VIDEO) && !ENABLE(PLUGIN_PROXY_FOR_VIDEO) // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument // Key system is not applicable here. DOMImplementationSupportsTypeClient client(frame && frame->settings().needsSiteSpecificQuirks(), url.host()); MediaEngineSupportParameters parameters; parameters.type = type; parameters.url = url; if (MediaPlayer::supportsType(parameters, &client)) return MediaDocument::create(frame, url); #endif // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed. // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle, // and also serves as an optimization to prevent loading the plug-in database in the common case. if (type != "text/plain" && ((pluginData && pluginData->supportsMimeType(type, allowedPluginTypes)) || (frame && frame->loader().client().shouldAlwaysUsePluginDocument(type)))) return PluginDocument::create(frame, url); if (isTextMIMEType(type)) return TextDocument::create(frame, url); if (type == "image/svg+xml") return SVGDocument::create(frame, url); if (isXMLMIMEType(type)) return Document::create(frame, url); return HTMLDocument::create(frame, url); }
PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, bool inViewSourceMode) { if (inViewSourceMode) { if (type == "text/html" || type == "application/xhtml+xml" || type == "image/svg+xml" || isTextMIMEType(type) || isXMLMIMEType(type)) return new HTMLViewSourceDocument(this, frame, type); } // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. if (type == "text/html") return new HTMLDocument(this, frame); if (type == "application/xhtml+xml") return new Document(this, frame, true); #if ENABLE(FTPDIR) // Plugins cannot take FTP from us either if (type == "application/x-ftp-directory") return new FTPDirectoryDocument(this, frame); #endif // PDF is one image type for which a plugin can override built-in support. // We do not want QuickTime to take over all image types, obviously. if ((type == "application/pdf" || type == "text/pdf") && PlugInInfoStore::supportsMIMEType(type)) return new PluginDocument(this, frame); if (Image::supportsType(type)) return new ImageDocument(this, frame); // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed. // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle, // and also serves as an optimization to prevent loading the plug-in database in the common case. if (type != "text/plain" && PlugInInfoStore::supportsMIMEType(type)) return new PluginDocument(this, frame); if (isTextMIMEType(type)) return new TextDocument(this, frame); #if ENABLE(SVG) if (type == "image/svg+xml") { Settings* settings = frame ? frame->settings() : 0; if (!settings || !settings->usesDashboardBackwardCompatibilityMode()) return new SVGDocument(this, frame); } #endif if (isXMLMIMEType(type)) return new Document(this, frame); return new HTMLDocument(this, frame); }
PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const KURL& url, bool inViewSourceMode) { if (inViewSourceMode) return HTMLViewSourceDocument::create(frame, url, type); // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. if (type == "text/html") return HTMLDocument::create(frame, url); if (type == "application/xhtml+xml") return Document::createXHTML(frame, url); PluginData* pluginData = 0; if (frame && frame->page() && frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin)) pluginData = frame->page()->pluginData(); // PDF is one image type for which a plugin can override built-in support. // We do not want QuickTime to take over all image types, obviously. if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type)) return PluginDocument::create(frame, url); if (Image::supportsType(type)) return ImageDocument::create(frame, url); // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument // Key system is not applicable here. if (MediaPlayer::supportsType(ContentType(type), String(), url)) return MediaDocument::create(frame, url); // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed. // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle, // and also serves as an optimization to prevent loading the plug-in database in the common case. if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) return PluginDocument::create(frame, url); if (isTextMIMEType(type)) return TextDocument::create(frame, url); #if ENABLE(SVG) if (type == "image/svg+xml") return SVGDocument::create(frame, url); #endif if (isXMLMIMEType(type)) return Document::create(frame, url); return HTMLDocument::create(frame, url); }
PassRefPtrWillBeRawPtr<Document> DOMImplementation::createDocument(const String& type, const DocumentInit& init, bool inViewSourceMode) { if (inViewSourceMode) return HTMLViewSourceDocument::create(init, type); // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. if (type == "text/html") return HTMLDocument::create(init); if (type == "application/xhtml+xml" || type == "application/vnd.wap.xhtml+xml") return XMLDocument::createXHTML(init); if (type == "text/vnd.wap.wml") return XMLDocument::createWML(init); PluginData* pluginData = 0; if (init.frame() && init.frame()->page() && init.frame()->loader().allowPlugins(NotAboutToInstantiatePlugin)) pluginData = init.frame()->page()->pluginData(); // PDF is one image type for which a plugin can override built-in support. // We do not want QuickTime to take over all image types, obviously. if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type)) return PluginDocument::create(init); if (Image::supportsType(type)) return ImageDocument::create(init); // Check to see if the type can be played by our media player, if so create a MediaDocument if (HTMLMediaElement::supportsType(ContentType(type))) return MediaDocument::create(init); // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed. // Disallowing plugins to use text/plain prevents plugins from hijacking a fundamental type that the browser is expected to handle, // and also serves as an optimization to prevent loading the plugin database in the common case. if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) return PluginDocument::create(init); if (isTextMIMEType(type)) return TextDocument::create(init); if (type == "image/svg+xml") return XMLDocument::createSVG(init); if (isXMLMIMEType(type)) return XMLDocument::create(init); return HTMLDocument::create(init); }