Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsIDNService_h__ |
michael@0 | 7 | #define nsIDNService_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIIDNService.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "nsIObserver.h" |
michael@0 | 12 | #include "nsWeakReference.h" |
michael@0 | 13 | #include "nsIUnicodeNormalizer.h" |
michael@0 | 14 | #include "nsIDNKitInterface.h" |
michael@0 | 15 | #include "nsString.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsIPrefBranch; |
michael@0 | 18 | |
michael@0 | 19 | //----------------------------------------------------------------------------- |
michael@0 | 20 | // nsIDNService |
michael@0 | 21 | //----------------------------------------------------------------------------- |
michael@0 | 22 | |
michael@0 | 23 | #define kACEPrefixLen 4 |
michael@0 | 24 | |
michael@0 | 25 | class nsIDNService : public nsIIDNService, |
michael@0 | 26 | public nsIObserver, |
michael@0 | 27 | public nsSupportsWeakReference |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 31 | NS_DECL_NSIIDNSERVICE |
michael@0 | 32 | NS_DECL_NSIOBSERVER |
michael@0 | 33 | |
michael@0 | 34 | nsIDNService(); |
michael@0 | 35 | virtual ~nsIDNService(); |
michael@0 | 36 | |
michael@0 | 37 | nsresult Init(); |
michael@0 | 38 | |
michael@0 | 39 | private: |
michael@0 | 40 | void normalizeFullStops(nsAString& s); |
michael@0 | 41 | nsresult stringPrepAndACE(const nsAString& in, nsACString& out, |
michael@0 | 42 | bool allowUnassigned, bool convertAllLabels); |
michael@0 | 43 | nsresult encodeToACE(const nsAString& in, nsACString& out); |
michael@0 | 44 | nsresult stringPrep(const nsAString& in, nsAString& out, |
michael@0 | 45 | bool allowUnassigned); |
michael@0 | 46 | nsresult decodeACE(const nsACString& in, nsACString& out, |
michael@0 | 47 | bool allowUnassigned, bool convertAllLabels); |
michael@0 | 48 | nsresult SelectiveUTF8toACE(const nsACString& input, nsACString& ace); |
michael@0 | 49 | nsresult SelectiveACEtoUTF8(const nsACString& input, nsACString& _retval); |
michael@0 | 50 | nsresult UTF8toACE(const nsACString& input, nsACString& ace, |
michael@0 | 51 | bool allowUnassigned, bool convertAllLabels); |
michael@0 | 52 | nsresult ACEtoUTF8(const nsACString& input, nsACString& _retval, |
michael@0 | 53 | bool allowUnassigned, bool convertAllLabels); |
michael@0 | 54 | bool isInWhitelist(const nsACString &host); |
michael@0 | 55 | void prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref); |
michael@0 | 56 | bool isLabelSafe(const nsAString &label); |
michael@0 | 57 | bool illegalScriptCombo(int32_t script, int32_t& savedScript); |
michael@0 | 58 | |
michael@0 | 59 | bool mMultilingualTestBed; // if true generates extra node for multilingual testbed |
michael@0 | 60 | idn_nameprep_t mNamePrepHandle; |
michael@0 | 61 | nsCOMPtr<nsIUnicodeNormalizer> mNormalizer; |
michael@0 | 62 | char mACEPrefix[kACEPrefixLen+1]; |
michael@0 | 63 | nsXPIDLString mIDNBlacklist; |
michael@0 | 64 | bool mShowPunycode; |
michael@0 | 65 | enum restrictionProfile { |
michael@0 | 66 | eASCIIOnlyProfile, |
michael@0 | 67 | eHighlyRestrictiveProfile, |
michael@0 | 68 | eModeratelyRestrictiveProfile |
michael@0 | 69 | }; |
michael@0 | 70 | restrictionProfile mRestrictionProfile; |
michael@0 | 71 | nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch; |
michael@0 | 72 | bool mIDNUseWhitelist; |
michael@0 | 73 | }; |
michael@0 | 74 | |
michael@0 | 75 | #endif // nsIDNService_h__ |