1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Communicator client code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef mozilla_dom_MediaDocument_h
39 : #define mozilla_dom_MediaDocument_h
40 :
41 : #include "nsHTMLDocument.h"
42 : #include "nsGenericHTMLElement.h"
43 : #include "nsAutoPtr.h"
44 : #include "nsIStringBundle.h"
45 :
46 : #define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
47 :
48 : namespace mozilla {
49 : namespace dom {
50 :
51 : class MediaDocument : public nsHTMLDocument
52 : {
53 : public:
54 : MediaDocument();
55 : virtual ~MediaDocument();
56 :
57 : virtual nsresult Init();
58 :
59 : virtual nsresult StartDocumentLoad(const char* aCommand,
60 : nsIChannel* aChannel,
61 : nsILoadGroup* aLoadGroup,
62 : nsISupports* aContainer,
63 : nsIStreamListener** aDocListener,
64 : bool aReset = true,
65 : nsIContentSink* aSink = nsnull);
66 :
67 : virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
68 :
69 : protected:
70 : virtual nsresult CreateSyntheticDocument();
71 :
72 : friend class MediaDocumentStreamListener;
73 : nsresult StartLayout();
74 :
75 : void GetFileName(nsAString& aResult);
76 :
77 : nsresult LinkStylesheet(const nsAString& aStylesheet);
78 :
79 : // |aFormatNames[]| needs to have four elements in the following order:
80 : // a format name with neither dimension nor file, a format name with
81 : // filename but w/o dimension, a format name with dimension but w/o filename,
82 : // a format name with both of them. For instance, it can have
83 : // "ImageTitleWithNeitherDimensionsNorFile", "ImageTitleWithoutDimensions",
84 : // "ImageTitleWithDimesions", "ImageTitleWithDimensionsAndFile".
85 : //
86 : // Also see MediaDocument.properties if you want to define format names
87 : // for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
88 : // but could be in other units for other 'media', in which case you have to
89 : // define format names accordingly.
90 : void UpdateTitleAndCharset(const nsACString& aTypeStr,
91 : const char* const* aFormatNames = sFormatNames,
92 : PRInt32 aWidth = 0,
93 : PRInt32 aHeight = 0,
94 0 : const nsAString& aStatus = EmptyString());
95 :
96 : nsCOMPtr<nsIStringBundle> mStringBundle;
97 : static const char* const sFormatNames[4];
98 :
99 : private:
100 : enum {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile};
101 : bool mDocumentElementInserted;
102 : };
103 :
104 :
105 : class MediaDocumentStreamListener: public nsIStreamListener
106 : {
107 : public:
108 : MediaDocumentStreamListener(MediaDocument *aDocument);
109 : virtual ~MediaDocumentStreamListener();
110 : void SetStreamListener(nsIStreamListener *aListener);
111 :
112 : NS_DECL_ISUPPORTS
113 :
114 : NS_DECL_NSIREQUESTOBSERVER
115 :
116 : NS_DECL_NSISTREAMLISTENER
117 :
118 : nsRefPtr<MediaDocument> mDocument;
119 : nsCOMPtr<nsIStreamListener> mNextStream;
120 : };
121 :
122 : } // namespace dom
123 : } // namespace mozilla
124 :
125 : #endif /* mozilla_dom_MediaDocument_h */
|