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
15 * The Original Code is Mozilla Communicator client code, released
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.
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
44 #include "nsVoidArray.h"
46 #include "nsISupportsUtils.h"
47 #include "nsILocalFile.h"
48 #include "nsIOutputStream.h"
51 #include "nsIXPConnect.h"
52 #include "nsICryptoHash.h"
53 #include "nsIPrincipal.h"
54 #include "nsThreadUtils.h"
56 struct XPITriggerEvent
: public nsRunnable
{
62 nsCOMPtr
<nsISupports
> ref
;
63 nsCOMPtr
<nsIPrincipal
> princ
;
65 virtual ~XPITriggerEvent();
69 class nsXPITriggerItem
72 nsXPITriggerItem( const PRUnichar
* name
,
74 const PRUnichar
* iconURL
,
75 const char* hash
= nsnull
,
85 PRBool mHashFound
; // this flag indicates that we found _some_ hash info in the trigger
87 nsCOMPtr
<nsICryptoHash
> mHasher
;
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();
102 //-- prevent inadvertent copies and assignments
103 nsXPITriggerItem
& operator=(const nsXPITriggerItem
& rhs
);
104 nsXPITriggerItem(const nsXPITriggerItem
& rhs
);
111 class 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
; }
135 nsCOMPtr
<nsIXPConnectJSObjectHolder
> mGlobalWrapper
;
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 */