|
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/. */ |
|
5 |
|
6 #ifndef nsIDNService_h__ |
|
7 #define nsIDNService_h__ |
|
8 |
|
9 #include "nsIIDNService.h" |
|
10 #include "nsCOMPtr.h" |
|
11 #include "nsIObserver.h" |
|
12 #include "nsWeakReference.h" |
|
13 #include "nsIUnicodeNormalizer.h" |
|
14 #include "nsIDNKitInterface.h" |
|
15 #include "nsString.h" |
|
16 |
|
17 class nsIPrefBranch; |
|
18 |
|
19 //----------------------------------------------------------------------------- |
|
20 // nsIDNService |
|
21 //----------------------------------------------------------------------------- |
|
22 |
|
23 #define kACEPrefixLen 4 |
|
24 |
|
25 class nsIDNService : public nsIIDNService, |
|
26 public nsIObserver, |
|
27 public nsSupportsWeakReference |
|
28 { |
|
29 public: |
|
30 NS_DECL_THREADSAFE_ISUPPORTS |
|
31 NS_DECL_NSIIDNSERVICE |
|
32 NS_DECL_NSIOBSERVER |
|
33 |
|
34 nsIDNService(); |
|
35 virtual ~nsIDNService(); |
|
36 |
|
37 nsresult Init(); |
|
38 |
|
39 private: |
|
40 void normalizeFullStops(nsAString& s); |
|
41 nsresult stringPrepAndACE(const nsAString& in, nsACString& out, |
|
42 bool allowUnassigned, bool convertAllLabels); |
|
43 nsresult encodeToACE(const nsAString& in, nsACString& out); |
|
44 nsresult stringPrep(const nsAString& in, nsAString& out, |
|
45 bool allowUnassigned); |
|
46 nsresult decodeACE(const nsACString& in, nsACString& out, |
|
47 bool allowUnassigned, bool convertAllLabels); |
|
48 nsresult SelectiveUTF8toACE(const nsACString& input, nsACString& ace); |
|
49 nsresult SelectiveACEtoUTF8(const nsACString& input, nsACString& _retval); |
|
50 nsresult UTF8toACE(const nsACString& input, nsACString& ace, |
|
51 bool allowUnassigned, bool convertAllLabels); |
|
52 nsresult ACEtoUTF8(const nsACString& input, nsACString& _retval, |
|
53 bool allowUnassigned, bool convertAllLabels); |
|
54 bool isInWhitelist(const nsACString &host); |
|
55 void prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref); |
|
56 bool isLabelSafe(const nsAString &label); |
|
57 bool illegalScriptCombo(int32_t script, int32_t& savedScript); |
|
58 |
|
59 bool mMultilingualTestBed; // if true generates extra node for multilingual testbed |
|
60 idn_nameprep_t mNamePrepHandle; |
|
61 nsCOMPtr<nsIUnicodeNormalizer> mNormalizer; |
|
62 char mACEPrefix[kACEPrefixLen+1]; |
|
63 nsXPIDLString mIDNBlacklist; |
|
64 bool mShowPunycode; |
|
65 enum restrictionProfile { |
|
66 eASCIIOnlyProfile, |
|
67 eHighlyRestrictiveProfile, |
|
68 eModeratelyRestrictiveProfile |
|
69 }; |
|
70 restrictionProfile mRestrictionProfile; |
|
71 nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch; |
|
72 bool mIDNUseWhitelist; |
|
73 }; |
|
74 |
|
75 #endif // nsIDNService_h__ |