Bumping manifests a=b2g-bump
[gecko.git] / netwerk / dns / nsIDNService.h
bloba5932487250ac2c593f565f706357332271ef495
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"
10 #include "nsCOMPtr.h"
11 #include "nsIObserver.h"
12 #include "nsWeakReference.h"
13 #include "nsIUnicodeNormalizer.h"
14 #include "nsIDNKitInterface.h"
15 #include "nsString.h"
17 class nsIPrefBranch;
19 //-----------------------------------------------------------------------------
20 // nsIDNService
21 //-----------------------------------------------------------------------------
23 #define kACEPrefixLen 4
25 class nsIDNService : public nsIIDNService,
26 public nsIObserver,
27 public nsSupportsWeakReference
29 public:
30 NS_DECL_THREADSAFE_ISUPPORTS
31 NS_DECL_NSIIDNSERVICE
32 NS_DECL_NSIOBSERVER
34 nsIDNService();
36 nsresult Init();
38 protected:
39 virtual ~nsIDNService();
41 private:
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;
66 bool mShowPunycode;
67 enum restrictionProfile {
68 eASCIIOnlyProfile,
69 eHighlyRestrictiveProfile,
70 eModeratelyRestrictiveProfile
72 restrictionProfile mRestrictionProfile;
73 nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch;
74 bool mIDNUseWhitelist;
77 #endif // nsIDNService_h__