1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsContentDLF_h__
8 #define nsContentDLF_h__
10 #include "nsIDocumentLoaderFactory.h"
11 #include "nsMimeTypes.h"
15 class nsIContentViewer
;
17 class nsIStreamListener
;
19 #define CONTENT_DLF_CONTRACTID "@mozilla.org/content/document-loader-factory;1"
20 #define PLUGIN_DLF_CONTRACTID \
21 "@mozilla.org/content/plugin/document-loader-factory;1"
23 class nsContentDLF final
: public nsIDocumentLoaderFactory
{
25 virtual ~nsContentDLF();
31 NS_DECL_NSIDOCUMENTLOADERFACTORY
33 nsresult
InitUAStyleSheet();
35 typedef already_AddRefed
<mozilla::dom::Document
> (*DocumentCreator
)();
36 nsresult
CreateDocument(const char* aCommand
, nsIChannel
* aChannel
,
37 nsILoadGroup
* aLoadGroup
, nsIDocShell
* aContainer
,
38 DocumentCreator aDocumentCreator
,
39 nsIStreamListener
** aDocListener
,
40 nsIContentViewer
** aContentViewer
);
42 nsresult
CreateXULDocument(const char* aCommand
, nsIChannel
* aChannel
,
43 nsILoadGroup
* aLoadGroup
, nsIDocShell
* aContainer
,
44 nsISupports
* aExtraInfo
,
45 nsIStreamListener
** aDocListener
,
46 nsIContentViewer
** aContentViewer
);
49 * Create a blank document using the given loadgroup and given
50 * principal. aPrincipal is allowed to be null, in which case the
51 * new document will get the about:blank codebase principal.
53 static already_AddRefed
<mozilla::dom::Document
> CreateBlankDocument(
54 nsILoadGroup
* aLoadGroup
, nsIPrincipal
* aPrincipal
,
55 nsDocShell
* aContainer
);
58 static nsresult
EnsureUAStyleSheet();
59 static bool IsImageContentType(const char* aContentType
);
62 nsresult
NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory
** aResult
);
66 #define CONTENTDLF_WEBM_CATEGORIES \
67 { "Gecko-Content-Viewers", VIDEO_WEBM, "@mozilla.org/content/document-loader-factory;1" }, \
68 { "Gecko-Content-Viewers", AUDIO_WEBM, "@mozilla.org/content/document-loader-factory;1" },
70 #define CONTENTDLF_WEBM_CATEGORIES
73 #define CONTENTDLF_CATEGORIES \
74 { "Gecko-Content-Viewers", TEXT_HTML, "@mozilla.org/content/document-loader-factory;1" }, \
75 { "Gecko-Content-Viewers", TEXT_PLAIN, "@mozilla.org/content/document-loader-factory;1" }, \
76 { "Gecko-Content-Viewers", TEXT_CACHE_MANIFEST, "@mozilla.org/content/document-loader-factory;1" }, \
77 { "Gecko-Content-Viewers", TEXT_CSS, "@mozilla.org/content/document-loader-factory;1" }, \
78 { "Gecko-Content-Viewers", TEXT_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
79 { "Gecko-Content-Viewers", TEXT_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
80 { "Gecko-Content-Viewers", APPLICATION_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
81 { "Gecko-Content-Viewers", APPLICATION_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
82 { "Gecko-Content-Viewers", APPLICATION_XJAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
83 { "Gecko-Content-Viewers", APPLICATION_JSON, "@mozilla.org/content/document-loader-factory;1" }, \
84 { "Gecko-Content-Viewers", TEXT_JSON, "@mozilla.org/content/document-loader-factory;1" }, \
85 { "Gecko-Content-Viewers", APPLICATION_XHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \
86 { "Gecko-Content-Viewers", TEXT_XML, "@mozilla.org/content/document-loader-factory;1" }, \
87 { "Gecko-Content-Viewers", APPLICATION_XML, "@mozilla.org/content/document-loader-factory;1" }, \
88 { "Gecko-Content-Viewers", APPLICATION_RDF_XML, "@mozilla.org/content/document-loader-factory;1" }, \
89 { "Gecko-Content-Viewers", TEXT_RDF, "@mozilla.org/content/document-loader-factory;1" }, \
90 { "Gecko-Content-Viewers", TEXT_XUL, "@mozilla.org/content/document-loader-factory;1" }, \
91 { "Gecko-Content-Viewers", APPLICATION_CACHED_XUL, "@mozilla.org/content/document-loader-factory;1" }, \
92 { "Gecko-Content-Viewers", VIEWSOURCE_CONTENT_TYPE, "@mozilla.org/content/document-loader-factory;1" }, \
93 { "Gecko-Content-Viewers", IMAGE_SVG_XML, "@mozilla.org/content/document-loader-factory;1" }, \
94 { "Gecko-Content-Viewers", APPLICATION_MATHML_XML, "@mozilla.org/content/document-loader-factory;1" }, \
95 { "Gecko-Content-Viewers", TEXT_VTT, "@mozilla.org/content/document-loader-factory;1" }, \
96 { "Gecko-Content-Viewers", APPLICATION_WAPXHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \
97 CONTENTDLF_WEBM_CATEGORIES