Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / xpinstall / src / nsXPITriggerInfo.h
blobb588a1fb407464b2ccf167026821170827dcc2e6
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
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/
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.
15 * The Original Code is Mozilla Communicator client code, released
16 * March 31, 1998.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998-1999
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Daniel Veditz <dveditz@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef nsXPITriggerInfo_h
41 #define nsXPITriggerInfo_h
43 #include "nsString.h"
44 #include "nsVoidArray.h"
45 #include "nsCOMPtr.h"
46 #include "nsISupportsUtils.h"
47 #include "nsILocalFile.h"
48 #include "nsIOutputStream.h"
49 #include "jsapi.h"
50 #include "prthread.h"
51 #include "nsIXPConnect.h"
52 #include "nsICryptoHash.h"
53 #include "nsIPrincipal.h"
54 #include "nsThreadUtils.h"
56 struct XPITriggerEvent : public nsRunnable {
57 nsString URL;
58 PRInt32 status;
59 JSContext* cx;
60 jsval global;
61 jsval cbval;
62 nsCOMPtr<nsISupports> ref;
63 nsCOMPtr<nsIPrincipal> princ;
65 virtual ~XPITriggerEvent();
66 NS_IMETHOD Run();
69 class nsXPITriggerItem
71 public:
72 nsXPITriggerItem( const PRUnichar* name,
73 const PRUnichar* URL,
74 const PRUnichar* iconURL,
75 const char* hash = nsnull,
76 PRInt32 flags = 0);
77 ~nsXPITriggerItem();
79 nsString mName;
80 nsString mURL;
81 nsString mIconURL;
82 nsString mArguments;
83 nsString mCertName;
85 PRBool mHashFound; // this flag indicates that we found _some_ hash info in the trigger
86 nsCString mHash;
87 nsCOMPtr<nsICryptoHash> mHasher;
88 PRInt32 mFlags;
90 nsCOMPtr<nsILocalFile> mFile;
91 nsCOMPtr<nsIOutputStream> mOutStream;
92 nsCOMPtr<nsIPrincipal> mPrincipal;
94 void SetPrincipal(nsIPrincipal* aPrincipal);
96 PRBool IsFileURL() { return StringBeginsWith(mURL, NS_LITERAL_STRING("file:/")); }
97 PRBool IsRelativeURL();
99 const PRUnichar* GetSafeURLString();
101 private:
102 //-- prevent inadvertent copies and assignments
103 nsXPITriggerItem& operator=(const nsXPITriggerItem& rhs);
104 nsXPITriggerItem(const nsXPITriggerItem& rhs);
106 nsString mSafeURL;
111 class nsXPITriggerInfo
113 public:
114 nsXPITriggerInfo();
115 ~nsXPITriggerInfo();
117 void Add( nsXPITriggerItem *aItem )
118 { if ( aItem ) mItems.AppendElement( (void*)aItem ); }
120 nsXPITriggerItem* Get( PRUint32 aIndex )
121 { return (nsXPITriggerItem*)mItems.ElementAt(aIndex);}
123 void SaveCallback( JSContext *aCx, jsval aVal );
125 PRUint32 Size() { return mItems.Count(); }
127 void SendStatus(const PRUnichar* URL, PRInt32 status);
129 void SetPrincipal(nsIPrincipal* aPrinc) { mPrincipal = aPrinc; }
132 private:
133 nsVoidArray mItems;
134 JSContext *mCx;
135 nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobalWrapper;
136 jsval mCbval;
137 nsCOMPtr<nsIThread> mThread;
139 nsCOMPtr<nsIPrincipal> mPrincipal;
141 //-- prevent inadvertent copies and assignments
142 nsXPITriggerInfo& operator=(const nsXPITriggerInfo& rhs);
143 nsXPITriggerInfo(const nsXPITriggerInfo& rhs);
146 #endif /* nsXPITriggerInfo_h */