OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef URL_URL_UTIL_H_ | 5 #ifndef URL_URL_UTIL_H_ |
6 #define URL_URL_UTIL_H_ | 6 #define URL_URL_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // the list of allowed schemes for referrers (see AddReferrerScheme). | 126 // the list of allowed schemes for referrers (see AddReferrerScheme). |
127 URL_EXPORT bool IsReferrerScheme(const char* spec, const Component& scheme); | 127 URL_EXPORT bool IsReferrerScheme(const char* spec, const Component& scheme); |
128 | 128 |
129 // Returns true and sets |type| to the SchemeType of the given scheme | 129 // Returns true and sets |type| to the SchemeType of the given scheme |
130 // identified by |scheme| within |spec| if the scheme is in the list of known | 130 // identified by |scheme| within |spec| if the scheme is in the list of known |
131 // standard-format schemes (see AddStandardScheme). | 131 // standard-format schemes (see AddStandardScheme). |
132 URL_EXPORT bool GetStandardSchemeType(const char* spec, | 132 URL_EXPORT bool GetStandardSchemeType(const char* spec, |
133 const Component& scheme, | 133 const Component& scheme, |
134 SchemeType* type); | 134 SchemeType* type); |
135 | 135 |
136 // Domains --------------------------------------------------------------------- | 136 // Hosts ---------------------------------------------------------------------- |
137 | 137 |
138 // Returns true if the |canonicalized_host| matches or is in the same domain as | 138 // Returns true if the |canonicalized_host| matches or is in the same domain as |
139 // the given |lower_ascii_domain| string. For example, if the canonicalized | 139 // the given |lower_ascii_domain| string. For example, if the canonicalized |
140 // hostname is "www.google.com", this will return true for "com", "google.com", | 140 // hostname is "www.google.com", this will return true for "com", "google.com", |
141 // and "www.google.com" domains. | 141 // and "www.google.com" domains. |
142 // | 142 // |
143 // If either of the input StringPieces is empty, the return value is false. The | 143 // If either of the input StringPieces is empty, the return value is false. The |
144 // input domain should be a lower-case ASCII string in order to match the | 144 // input domain should be a lower-case ASCII string in order to match the |
145 // canonicalized host. | 145 // canonicalized host. |
146 URL_EXPORT bool DomainIs(base::StringPiece canonicalized_host, | 146 URL_EXPORT bool DomainIs(base::StringPiece canonicalized_host, |
147 base::StringPiece lower_ascii_domain); | 147 base::StringPiece lower_ascii_domain); |
148 | 148 |
| 149 // Returns true if the hostname is an IP address. Note: this function isn't very |
| 150 // cheap, as it must re-parse the host to verify. |
| 151 URL_EXPORT bool HostIsIPAddress(base::StringPiece host); |
| 152 |
149 // URL library wrappers -------------------------------------------------------- | 153 // URL library wrappers -------------------------------------------------------- |
150 | 154 |
151 // Parses the given spec according to the extracted scheme type. Normal users | 155 // Parses the given spec according to the extracted scheme type. Normal users |
152 // should use the URL object, although this may be useful if performance is | 156 // should use the URL object, although this may be useful if performance is |
153 // critical and you don't want to do the heap allocation for the std::string. | 157 // critical and you don't want to do the heap allocation for the std::string. |
154 // | 158 // |
155 // As with the Canonicalize* functions, the charset converter can | 159 // As with the Canonicalize* functions, the charset converter can |
156 // be NULL to use UTF-8 (it will be faster in this case). | 160 // be NULL to use UTF-8 (it will be faster in this case). |
157 // | 161 // |
158 // Returns true if a valid URL was produced, false if not. On failure, the | 162 // Returns true if a valid URL was produced, false if not. On failure, the |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 231 |
228 // Escapes the given string as defined by the JS method encodeURIComponent. See | 232 // Escapes the given string as defined by the JS method encodeURIComponent. See |
229 // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeUR
IComponent | 233 // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeUR
IComponent |
230 URL_EXPORT void EncodeURIComponent(const char* input, | 234 URL_EXPORT void EncodeURIComponent(const char* input, |
231 int length, | 235 int length, |
232 CanonOutput* output); | 236 CanonOutput* output); |
233 | 237 |
234 } // namespace url | 238 } // namespace url |
235 | 239 |
236 #endif // URL_URL_UTIL_H_ | 240 #endif // URL_URL_UTIL_H_ |
OLD | NEW |