Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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
28 {
29 public:
30 NS_DECL_THREADSAFE_ISUPPORTS
31 NS_DECL_NSIIDNSERVICE
32 NS_DECL_NSIOBSERVER
34 nsIDNService();
35 virtual ~nsIDNService();
37 nsresult Init();
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);
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 };
75 #endif // nsIDNService_h__