netwerk/dns/nsIDNService.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/dns/nsIDNService.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsIDNService_h__
    1.10 +#define nsIDNService_h__
    1.11 +
    1.12 +#include "nsIIDNService.h"
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsIObserver.h"
    1.15 +#include "nsWeakReference.h"
    1.16 +#include "nsIUnicodeNormalizer.h"
    1.17 +#include "nsIDNKitInterface.h"
    1.18 +#include "nsString.h"
    1.19 +
    1.20 +class nsIPrefBranch;
    1.21 +
    1.22 +//-----------------------------------------------------------------------------
    1.23 +// nsIDNService
    1.24 +//-----------------------------------------------------------------------------
    1.25 +
    1.26 +#define kACEPrefixLen 4 
    1.27 +
    1.28 +class nsIDNService : public nsIIDNService,
    1.29 +                     public nsIObserver,
    1.30 +                     public nsSupportsWeakReference
    1.31 +{
    1.32 +public:
    1.33 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.34 +  NS_DECL_NSIIDNSERVICE
    1.35 +  NS_DECL_NSIOBSERVER
    1.36 +
    1.37 +  nsIDNService();
    1.38 +  virtual ~nsIDNService();
    1.39 +
    1.40 +  nsresult Init();
    1.41 +
    1.42 +private:
    1.43 +  void normalizeFullStops(nsAString& s);
    1.44 +  nsresult stringPrepAndACE(const nsAString& in, nsACString& out,
    1.45 +                            bool allowUnassigned, bool convertAllLabels);
    1.46 +  nsresult encodeToACE(const nsAString& in, nsACString& out);
    1.47 +  nsresult stringPrep(const nsAString& in, nsAString& out,
    1.48 +                      bool allowUnassigned);
    1.49 +  nsresult decodeACE(const nsACString& in, nsACString& out,
    1.50 +                     bool allowUnassigned, bool convertAllLabels);
    1.51 +  nsresult SelectiveUTF8toACE(const nsACString& input, nsACString& ace);
    1.52 +  nsresult SelectiveACEtoUTF8(const nsACString& input, nsACString& _retval);
    1.53 +  nsresult UTF8toACE(const nsACString& input, nsACString& ace,
    1.54 +                     bool allowUnassigned, bool convertAllLabels);
    1.55 +  nsresult ACEtoUTF8(const nsACString& input, nsACString& _retval,
    1.56 +                     bool allowUnassigned, bool convertAllLabels);
    1.57 +  bool isInWhitelist(const nsACString &host);
    1.58 +  void prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref);
    1.59 +  bool isLabelSafe(const nsAString &label);
    1.60 +  bool illegalScriptCombo(int32_t script, int32_t& savedScript);
    1.61 +
    1.62 +  bool mMultilingualTestBed;  // if true generates extra node for multilingual testbed 
    1.63 +  idn_nameprep_t mNamePrepHandle;
    1.64 +  nsCOMPtr<nsIUnicodeNormalizer> mNormalizer;
    1.65 +  char mACEPrefix[kACEPrefixLen+1];
    1.66 +  nsXPIDLString mIDNBlacklist;
    1.67 +  bool mShowPunycode;
    1.68 +  enum restrictionProfile {
    1.69 +    eASCIIOnlyProfile,
    1.70 +    eHighlyRestrictiveProfile,
    1.71 +    eModeratelyRestrictiveProfile
    1.72 +  };
    1.73 +  restrictionProfile mRestrictionProfile;
    1.74 +  nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch;
    1.75 +  bool mIDNUseWhitelist;
    1.76 +};
    1.77 +
    1.78 +#endif  // nsIDNService_h__

mercurial