/src/mozilla-central/toolkit/components/url-classifier/nsUrlClassifierUtils.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #ifndef nsUrlClassifierUtils_h_ |
6 | | #define nsUrlClassifierUtils_h_ |
7 | | |
8 | | #include "nsIUrlClassifierUtils.h" |
9 | | #include "nsClassHashtable.h" |
10 | | #include "nsIObserver.h" |
11 | | |
12 | 0 | #define TESTING_TABLE_PROVIDER_NAME "test" |
13 | | |
14 | | class nsUrlClassifierUtils final : public nsIUrlClassifierUtils, |
15 | | public nsIObserver |
16 | | { |
17 | | public: |
18 | | typedef nsClassHashtable<nsCStringHashKey, nsCString> ProviderDictType; |
19 | | |
20 | | nsUrlClassifierUtils(); |
21 | | |
22 | | NS_DECL_THREADSAFE_ISUPPORTS |
23 | | NS_DECL_NSIURLCLASSIFIERUTILS |
24 | | NS_DECL_NSIOBSERVER |
25 | | |
26 | | nsresult Init(); |
27 | | |
28 | | nsresult CanonicalizeHostname(const nsACString & hostname, |
29 | | nsACString & _retval); |
30 | | nsresult CanonicalizePath(const nsACString & url, nsACString & _retval); |
31 | | |
32 | | // This function will encode all "special" characters in typical url encoding, |
33 | | // that is %hh where h is a valid hex digit. The characters which are encoded |
34 | | // by this function are any ascii characters under 32(control characters and |
35 | | // space), 37(%), and anything 127 or above (special characters). Url is the |
36 | | // string to encode, ret is the encoded string. Function returns true if |
37 | | // ret != url. |
38 | | bool SpecialEncode(const nsACString & url, |
39 | | bool foldSlashes, |
40 | | nsACString & _retval); |
41 | | |
42 | | void ParseIPAddress(const nsACString & host, nsACString & _retval); |
43 | | void CanonicalNum(const nsACString & num, |
44 | | uint32_t bytes, |
45 | | bool allowOctal, |
46 | | nsACString & _retval); |
47 | | |
48 | | private: |
49 | 0 | ~nsUrlClassifierUtils() {} |
50 | | |
51 | | // Disallow copy constructor |
52 | | nsUrlClassifierUtils(const nsUrlClassifierUtils&); |
53 | | |
54 | | // Function to tell if we should encode a character. |
55 | | bool ShouldURLEscape(const unsigned char c) const; |
56 | | |
57 | | void CleanupHostname(const nsACString & host, nsACString & _retval); |
58 | | |
59 | | nsresult ReadProvidersFromPrefs(ProviderDictType& aDict); |
60 | | |
61 | | // The provider lookup table and its mutex. |
62 | | ProviderDictType mProviderDict; |
63 | | mozilla::Mutex mProviderDictLock; |
64 | | }; |
65 | | |
66 | | #endif // nsUrlClassifierUtils_h_ |