1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIDNService_h__
7 #define nsIDNService_h__
9 #include "nsIIDNService.h"
11 #include "nsIObserver.h"
12 #include "nsWeakReference.h"
13 #include "nsIUnicodeNormalizer.h"
14 #include "nsIDNKitInterface.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 #define kACEPrefixLen 4
25 class nsIDNService
: public nsIIDNService
,
27 public nsSupportsWeakReference
30 NS_DECL_THREADSAFE_ISUPPORTS
39 virtual ~nsIDNService();
42 void normalizeFullStops(nsAString
& s
);
43 nsresult
stringPrepAndACE(const nsAString
& in
, nsACString
& out
,
44 bool allowUnassigned
, bool convertAllLabels
);
45 nsresult
encodeToACE(const nsAString
& in
, nsACString
& out
);
46 nsresult
stringPrep(const nsAString
& in
, nsAString
& out
,
47 bool allowUnassigned
);
48 nsresult
decodeACE(const nsACString
& in
, nsACString
& out
,
49 bool allowUnassigned
, bool convertAllLabels
);
50 nsresult
SelectiveUTF8toACE(const nsACString
& input
, nsACString
& ace
);
51 nsresult
SelectiveACEtoUTF8(const nsACString
& input
, nsACString
& _retval
);
52 nsresult
UTF8toACE(const nsACString
& input
, nsACString
& ace
,
53 bool allowUnassigned
, bool convertAllLabels
);
54 nsresult
ACEtoUTF8(const nsACString
& input
, nsACString
& _retval
,
55 bool allowUnassigned
, bool convertAllLabels
);
56 bool isInWhitelist(const nsACString
&host
);
57 void prefsChanged(nsIPrefBranch
*prefBranch
, const char16_t
*pref
);
58 bool isLabelSafe(const nsAString
&label
);
59 bool illegalScriptCombo(int32_t script
, int32_t& savedScript
);
61 bool mMultilingualTestBed
; // if true generates extra node for multilingual testbed
62 idn_nameprep_t mNamePrepHandle
;
63 nsCOMPtr
<nsIUnicodeNormalizer
> mNormalizer
;
64 char mACEPrefix
[kACEPrefixLen
+1];
65 nsXPIDLString mIDNBlacklist
;
67 enum restrictionProfile
{
69 eHighlyRestrictiveProfile
,
70 eModeratelyRestrictiveProfile
72 restrictionProfile mRestrictionProfile
;
73 nsCOMPtr
<nsIPrefBranch
> mIDNWhitelistPrefBranch
;
74 bool mIDNUseWhitelist
;
77 #endif // nsIDNService_h__