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_GURL_H_ | 5 #ifndef URL_GURL_H_ |
6 #define URL_GURL_H_ | 6 #define URL_GURL_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 // are often treated separately by some programs. | 216 // are often treated separately by some programs. |
217 bool SchemeIsFile() const { | 217 bool SchemeIsFile() const { |
218 return SchemeIs(url::kFileScheme); | 218 return SchemeIs(url::kFileScheme); |
219 } | 219 } |
220 | 220 |
221 // FileSystem URLs need to be treated differently in some cases. | 221 // FileSystem URLs need to be treated differently in some cases. |
222 bool SchemeIsFileSystem() const { | 222 bool SchemeIsFileSystem() const { |
223 return SchemeIs(url::kFileSystemScheme); | 223 return SchemeIs(url::kFileSystemScheme); |
224 } | 224 } |
225 | 225 |
226 // If the scheme indicates a secure connection | 226 // Returns true if the scheme indicates a secure connection. |
227 bool SchemeIsSecure() const { | 227 bool SchemeIsSecure() const { |
228 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme) || | 228 return SchemeIs(url::kFileScheme) || SchemeIs(url::kHttpsScheme) || |
davidben
2015/04/06 21:02:55
I'm worried changing this behavior outright will b
| |
229 (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); | 229 SchemeIs(url::kWssScheme) || (SchemeIsFileSystem() && inner_url() && |
brettw
2015/04/06 20:19:05
I found the old way of SchemeIsFileSystem on the s
| |
230 inner_url()->SchemeIsSecure()); | |
230 } | 231 } |
231 | 232 |
232 // Returns true if the scheme is "blob". | 233 // Returns true if the scheme is "blob". |
233 bool SchemeIsBlob() const { | 234 bool SchemeIsBlob() const { |
234 return SchemeIs(url::kBlobScheme); | 235 return SchemeIs(url::kBlobScheme); |
235 } | 236 } |
236 | 237 |
237 // The "content" of the URL is everything after the scheme (skipping the | 238 // The "content" of the URL is everything after the scheme (skipping the |
238 // scheme delimiting colon). It is an error to get the origin of an invalid | 239 // scheme delimiting colon). It is an error to get the origin of an invalid |
239 // URL. The result will be an empty string. | 240 // URL. The result will be an empty string. |
240 std::string GetContent() const; | 241 std::string GetContent() const; |
241 | 242 |
242 // Returns true if the hostname is an IP address. Note: this function isn't | 243 // Returns true if the hostname is an IP address. Note: this function isn't |
243 // as cheap as a simple getter because it re-parses the hostname to verify. | 244 // as cheap as a simple getter because it re-parses the hostname to verify. |
244 // This currently identifies only IPv4 addresses (bug 822685). | |
245 bool HostIsIPAddress() const; | 245 bool HostIsIPAddress() const; |
246 | 246 |
247 // Getters for various components of the URL. The returned string will be | 247 // Getters for various components of the URL. The returned string will be |
248 // empty if the component is empty or is not present. | 248 // empty if the component is empty or is not present. |
249 std::string scheme() const { // Not including the colon. See also SchemeIs. | 249 std::string scheme() const { // Not including the colon. See also SchemeIs. |
250 return ComponentString(parsed_.scheme); | 250 return ComponentString(parsed_.scheme); |
251 } | 251 } |
252 std::string username() const { | 252 std::string username() const { |
253 return ComponentString(parsed_.username); | 253 return ComponentString(parsed_.username); |
254 } | 254 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 return parsed_.query.len >= 0; | 303 return parsed_.query.len >= 0; |
304 } | 304 } |
305 bool has_ref() const { | 305 bool has_ref() const { |
306 return parsed_.ref.len >= 0; | 306 return parsed_.ref.len >= 0; |
307 } | 307 } |
308 | 308 |
309 // Returns a parsed version of the port. Can also be any of the special | 309 // Returns a parsed version of the port. Can also be any of the special |
310 // values defined in Parsed for ExtractPort. | 310 // values defined in Parsed for ExtractPort. |
311 int IntPort() const; | 311 int IntPort() const; |
312 | 312 |
313 // Returns the port number of the url, or the default port number. | 313 // Returns the port number of the URL, or the default port number. |
314 // If the scheme has no concept of port (or unknown default) returns | 314 // If the scheme has no concept of port (or unknown default) returns |
315 // PORT_UNSPECIFIED. | 315 // PORT_UNSPECIFIED. |
316 int EffectiveIntPort() const; | 316 int EffectiveIntPort() const; |
317 | 317 |
318 // Extracts the filename portion of the path and returns it. The filename | 318 // Extracts the filename portion of the path and returns it. The filename |
319 // is everything after the last slash in the path. This may be empty. | 319 // is everything after the last slash in the path. This may be empty. |
320 std::string ExtractFileName() const; | 320 std::string ExtractFileName() const; |
321 | 321 |
322 // Returns the path that should be sent to the server. This is the path, | 322 // Returns the path that should be sent to the server. This is the path, |
323 // parameter, and query portions of the URL. It is guaranteed to be ASCII. | 323 // parameter, and query portions of the URL. It is guaranteed to be ASCII. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 // Used for nested schemes [currently only filesystem:]. | 396 // Used for nested schemes [currently only filesystem:]. |
397 scoped_ptr<GURL> inner_url_; | 397 scoped_ptr<GURL> inner_url_; |
398 | 398 |
399 // TODO bug 684583: Add encoding for query params. | 399 // TODO bug 684583: Add encoding for query params. |
400 }; | 400 }; |
401 | 401 |
402 // Stream operator so GURL can be used in assertion statements. | 402 // Stream operator so GURL can be used in assertion statements. |
403 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); | 403 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); |
404 | 404 |
405 #endif // URL_GURL_H_ | 405 #endif // URL_GURL_H_ |
OLD | NEW |