2009-03-29 07:49:31 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-25 23:49:08 +00:00
|
|
|
|
|
|
|
#ifndef nsIDNService_h__
|
|
|
|
#define nsIDNService_h__
|
|
|
|
|
|
|
|
#include "nsIIDNService.h"
|
2003-01-17 23:56:33 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2003-04-11 17:05:56 +00:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
2003-01-17 23:56:33 +00:00
|
|
|
#include "nsIUnicodeNormalizer.h"
|
|
|
|
#include "nsIDNKitInterface.h"
|
2005-07-22 15:07:33 +00:00
|
|
|
#include "nsString.h"
|
2002-09-25 23:49:08 +00:00
|
|
|
|
2005-02-17 20:02:37 +00:00
|
|
|
class nsIPrefBranch;
|
|
|
|
|
2002-09-25 23:49:08 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// nsIDNService
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2003-03-25 23:18:41 +00:00
|
|
|
#define kACEPrefixLen 4
|
2003-01-17 23:56:33 +00:00
|
|
|
|
2003-04-11 17:05:56 +00:00
|
|
|
class nsIDNService : public nsIIDNService,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
2002-09-25 23:49:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:24:13 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2002-09-25 23:49:08 +00:00
|
|
|
NS_DECL_NSIIDNSERVICE
|
2003-04-11 17:05:56 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2002-09-25 23:49:08 +00:00
|
|
|
|
|
|
|
nsIDNService();
|
2003-01-17 23:56:33 +00:00
|
|
|
|
2003-04-11 17:05:56 +00:00
|
|
|
nsresult Init();
|
|
|
|
|
2014-06-24 16:36:44 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsIDNService();
|
|
|
|
|
2003-01-17 23:56:33 +00:00
|
|
|
private:
|
|
|
|
void normalizeFullStops(nsAString& s);
|
2009-03-29 07:49:31 +00:00
|
|
|
nsresult stringPrepAndACE(const nsAString& in, nsACString& out,
|
2013-03-01 11:56:44 +00:00
|
|
|
bool allowUnassigned, bool convertAllLabels);
|
2003-01-17 23:56:33 +00:00
|
|
|
nsresult encodeToACE(const nsAString& in, nsACString& out);
|
2009-03-29 07:49:31 +00:00
|
|
|
nsresult stringPrep(const nsAString& in, nsAString& out,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool allowUnassigned);
|
2009-03-29 07:49:31 +00:00
|
|
|
nsresult decodeACE(const nsACString& in, nsACString& out,
|
2013-03-01 11:56:44 +00: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 06:19:26 +00:00
|
|
|
bool isInWhitelist(const nsACString &host);
|
2014-01-04 15:02:17 +00:00
|
|
|
void prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref);
|
2013-03-01 11:56:44 +00:00
|
|
|
bool isLabelSafe(const nsAString &label);
|
|
|
|
bool illegalScriptCombo(int32_t script, int32_t& savedScript);
|
2005-07-22 15:07:33 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mMultilingualTestBed; // if true generates extra node for multilingual testbed
|
2003-01-17 23:56:33 +00:00
|
|
|
idn_nameprep_t mNamePrepHandle;
|
|
|
|
nsCOMPtr<nsIUnicodeNormalizer> mNormalizer;
|
|
|
|
char mACEPrefix[kACEPrefixLen+1];
|
2005-07-22 15:07:33 +00:00
|
|
|
nsXPIDLString mIDNBlacklist;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mShowPunycode;
|
2013-03-01 11:56:44 +00:00
|
|
|
enum restrictionProfile {
|
|
|
|
eASCIIOnlyProfile,
|
|
|
|
eHighlyRestrictiveProfile,
|
|
|
|
eModeratelyRestrictiveProfile
|
|
|
|
};
|
|
|
|
restrictionProfile mRestrictionProfile;
|
2007-12-04 06:30:47 +00:00
|
|
|
nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch;
|
2013-03-01 11:56:44 +00:00
|
|
|
bool mIDNUseWhitelist;
|
2002-09-25 23:49:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsIDNService_h__
|