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/. */
|
2007-02-28 02:49:44 +03:00
|
|
|
|
|
|
|
#ifndef nsUrlClassifierUtils_h_
|
|
|
|
#define nsUrlClassifierUtils_h_
|
|
|
|
|
|
|
|
#include "nsIUrlClassifierUtils.h"
|
2016-11-04 12:54:05 +03:00
|
|
|
#include "nsClassHashtable.h"
|
|
|
|
#include "nsIObserver.h"
|
2007-02-28 02:49:44 +03:00
|
|
|
|
2017-01-27 13:02:36 +03:00
|
|
|
#define TESTING_TABLE_PROVIDER_NAME "test"
|
|
|
|
|
2016-11-04 12:54:05 +03:00
|
|
|
class nsUrlClassifierUtils final : public nsIUrlClassifierUtils,
|
|
|
|
public nsIObserver
|
2007-02-28 02:49:44 +03:00
|
|
|
{
|
2016-11-04 12:54:05 +03:00
|
|
|
public:
|
|
|
|
typedef nsClassHashtable<nsCStringHashKey, nsCString> ProviderDictType;
|
|
|
|
|
2007-02-28 02:49:44 +03:00
|
|
|
nsUrlClassifierUtils();
|
|
|
|
|
2016-08-04 13:10:12 +03:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2007-07-26 07:11:43 +04:00
|
|
|
NS_DECL_NSIURLCLASSIFIERUTILS
|
2016-11-04 12:54:05 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
2007-07-26 05:49:20 +04:00
|
|
|
|
2007-07-26 10:38:43 +04:00
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
nsresult CanonicalizeHostname(const nsACString & hostname,
|
|
|
|
nsACString & _retval);
|
|
|
|
nsresult CanonicalizePath(const nsACString & url, nsACString & _retval);
|
|
|
|
|
2007-02-28 02:49:44 +03:00
|
|
|
// This function will encode all "special" characters in typical url encoding,
|
|
|
|
// that is %hh where h is a valid hex digit. The characters which are encoded
|
|
|
|
// by this function are any ascii characters under 32(control characters and
|
|
|
|
// space), 37(%), and anything 127 or above (special characters). Url is the
|
|
|
|
// string to encode, ret is the encoded string. Function returns true if
|
|
|
|
// ret != url.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SpecialEncode(const nsACString & url,
|
|
|
|
bool foldSlashes,
|
2007-07-26 10:38:43 +04:00
|
|
|
nsACString & _retval);
|
2007-02-28 02:49:44 +03:00
|
|
|
|
2007-07-26 10:38:43 +04:00
|
|
|
void ParseIPAddress(const nsACString & host, nsACString & _retval);
|
|
|
|
void CanonicalNum(const nsACString & num,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t bytes,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allowOctal,
|
2007-07-26 10:38:43 +04:00
|
|
|
nsACString & _retval);
|
2008-02-27 11:51:02 +03:00
|
|
|
|
2007-02-28 02:49:44 +03:00
|
|
|
private:
|
2014-06-24 02:40:02 +04:00
|
|
|
~nsUrlClassifierUtils() {}
|
|
|
|
|
2007-02-28 02:49:44 +03:00
|
|
|
// Disallow copy constructor
|
|
|
|
nsUrlClassifierUtils(const nsUrlClassifierUtils&);
|
|
|
|
|
|
|
|
// Function to tell if we should encode a character.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ShouldURLEscape(const unsigned char c) const;
|
2007-03-05 08:58:05 +03:00
|
|
|
|
2007-07-26 10:38:43 +04:00
|
|
|
void CleanupHostname(const nsACString & host, nsACString & _retval);
|
|
|
|
|
2016-11-04 12:54:05 +03:00
|
|
|
nsresult ReadProvidersFromPrefs(ProviderDictType& aDict);
|
|
|
|
|
|
|
|
// The provider lookup table and its mutex.
|
|
|
|
ProviderDictType mProviderDict;
|
|
|
|
mozilla::Mutex mProviderDictLock;
|
2007-02-28 02:49:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsUrlClassifierUtils_h_
|