2009-03-29 11:49:31 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-09-26 03:49:08 +04:00
|
|
|
|
|
|
|
#ifndef nsIDNService_h__
|
|
|
|
#define nsIDNService_h__
|
|
|
|
|
|
|
|
#include "nsIIDNService.h"
|
2003-01-18 02:56:33 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2003-04-11 21:05:56 +04:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
2003-01-18 02:56:33 +03:00
|
|
|
#include "nsIUnicodeNormalizer.h"
|
|
|
|
#include "nsIDNKitInterface.h"
|
2005-07-22 19:07:33 +04:00
|
|
|
#include "nsString.h"
|
2002-09-26 03:49:08 +04:00
|
|
|
|
2005-02-17 23:02:37 +03:00
|
|
|
class nsIPrefBranch;
|
|
|
|
|
2002-09-26 03:49:08 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// nsIDNService
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2003-03-26 02:18:41 +03:00
|
|
|
#define kACEPrefixLen 4
|
2003-01-18 02:56:33 +03:00
|
|
|
|
2003-04-11 21:05:56 +04:00
|
|
|
class nsIDNService : public nsIIDNService,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
2002-09-26 03:49:08 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIIDNSERVICE
|
2003-04-11 21:05:56 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2002-09-26 03:49:08 +04:00
|
|
|
|
|
|
|
nsIDNService();
|
|
|
|
virtual ~nsIDNService();
|
2003-01-18 02:56:33 +03:00
|
|
|
|
2003-04-11 21:05:56 +04:00
|
|
|
nsresult Init();
|
|
|
|
|
2003-01-18 02:56:33 +03:00
|
|
|
private:
|
|
|
|
void normalizeFullStops(nsAString& s);
|
2009-03-29 11:49:31 +04:00
|
|
|
nsresult stringPrepAndACE(const nsAString& in, nsACString& out,
|
2013-03-01 15:56:44 +04:00
|
|
|
bool allowUnassigned, bool convertAllLabels);
|
2003-01-18 02:56:33 +03:00
|
|
|
nsresult encodeToACE(const nsAString& in, nsACString& out);
|
2009-03-29 11:49:31 +04:00
|
|
|
nsresult stringPrep(const nsAString& in, nsAString& out,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allowUnassigned);
|
2009-03-29 11:49:31 +04:00
|
|
|
nsresult decodeACE(const nsACString& in, nsACString& out,
|
2013-03-01 15:56:44 +04:00
|
|
|
bool allowUnassigned, bool convertAllLabels);
|
|
|
|
nsresult SelectiveUTF8toACE(const nsACString& input, nsACString& ace);
|
|
|
|
nsresult SelectiveACEtoUTF8(const nsACString& input, nsACString& _retval);
|
|
|
|
nsresult UTF8toACE(const nsACString& input, nsACString& ace,
|
|
|
|
bool allowUnassigned, bool convertAllLabels);
|
|
|
|
nsresult ACEtoUTF8(const nsACString& input, nsACString& _retval,
|
|
|
|
bool allowUnassigned, bool convertAllLabels);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isInWhitelist(const nsACString &host);
|
2005-02-17 23:02:37 +03:00
|
|
|
void prefsChanged(nsIPrefBranch *prefBranch, const PRUnichar *pref);
|
2013-03-01 15:56:44 +04:00
|
|
|
bool isLabelSafe(const nsAString &label);
|
|
|
|
bool illegalScriptCombo(int32_t script, int32_t& savedScript);
|
2005-07-22 19:07:33 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mMultilingualTestBed; // if true generates extra node for multilingual testbed
|
2003-01-18 02:56:33 +03:00
|
|
|
idn_nameprep_t mNamePrepHandle;
|
|
|
|
nsCOMPtr<nsIUnicodeNormalizer> mNormalizer;
|
|
|
|
char mACEPrefix[kACEPrefixLen+1];
|
2005-07-22 19:07:33 +04:00
|
|
|
nsXPIDLString mIDNBlacklist;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mShowPunycode;
|
2013-03-01 15:56:44 +04:00
|
|
|
enum restrictionProfile {
|
|
|
|
eASCIIOnlyProfile,
|
|
|
|
eHighlyRestrictiveProfile,
|
|
|
|
eModeratelyRestrictiveProfile
|
|
|
|
};
|
|
|
|
restrictionProfile mRestrictionProfile;
|
2007-12-04 09:30:47 +03:00
|
|
|
nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch;
|
2013-03-01 15:56:44 +04:00
|
|
|
bool mIDNUseWhitelist;
|
2002-09-26 03:49:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsIDNService_h__
|