michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsIDNService_h__ michael@0: #define nsIDNService_h__ michael@0: michael@0: #include "nsIIDNService.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsIUnicodeNormalizer.h" michael@0: #include "nsIDNKitInterface.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsIPrefBranch; michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // nsIDNService michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: #define kACEPrefixLen 4 michael@0: michael@0: class nsIDNService : public nsIIDNService, michael@0: public nsIObserver, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIIDNSERVICE michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: nsIDNService(); michael@0: virtual ~nsIDNService(); michael@0: michael@0: nsresult Init(); michael@0: michael@0: private: michael@0: void normalizeFullStops(nsAString& s); michael@0: nsresult stringPrepAndACE(const nsAString& in, nsACString& out, michael@0: bool allowUnassigned, bool convertAllLabels); michael@0: nsresult encodeToACE(const nsAString& in, nsACString& out); michael@0: nsresult stringPrep(const nsAString& in, nsAString& out, michael@0: bool allowUnassigned); michael@0: nsresult decodeACE(const nsACString& in, nsACString& out, michael@0: bool allowUnassigned, bool convertAllLabels); michael@0: nsresult SelectiveUTF8toACE(const nsACString& input, nsACString& ace); michael@0: nsresult SelectiveACEtoUTF8(const nsACString& input, nsACString& _retval); michael@0: nsresult UTF8toACE(const nsACString& input, nsACString& ace, michael@0: bool allowUnassigned, bool convertAllLabels); michael@0: nsresult ACEtoUTF8(const nsACString& input, nsACString& _retval, michael@0: bool allowUnassigned, bool convertAllLabels); michael@0: bool isInWhitelist(const nsACString &host); michael@0: void prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref); michael@0: bool isLabelSafe(const nsAString &label); michael@0: bool illegalScriptCombo(int32_t script, int32_t& savedScript); michael@0: michael@0: bool mMultilingualTestBed; // if true generates extra node for multilingual testbed michael@0: idn_nameprep_t mNamePrepHandle; michael@0: nsCOMPtr mNormalizer; michael@0: char mACEPrefix[kACEPrefixLen+1]; michael@0: nsXPIDLString mIDNBlacklist; michael@0: bool mShowPunycode; michael@0: enum restrictionProfile { michael@0: eASCIIOnlyProfile, michael@0: eHighlyRestrictiveProfile, michael@0: eModeratelyRestrictiveProfile michael@0: }; michael@0: restrictionProfile mRestrictionProfile; michael@0: nsCOMPtr mIDNWhitelistPrefBranch; michael@0: bool mIDNUseWhitelist; michael@0: }; michael@0: michael@0: #endif // nsIDNService_h__