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 // | |
228 // NOTE: This function is deprecated. You probably want |SchemeUsesTLS| or | |
229 // Chromium's |content::IsOriginSecure|. | |
felt
2015/04/08 00:10:08
Can you add an explanation of when to use which on
palmer
2015/04/08 00:50:07
Done.
| |
230 // | |
231 // TODO(palmer): Audit callers and change them to |SchemeUsesTLS| or | |
232 // |content::IsOriginSecure|, as appropriate. Then remove |SchemeIsSecure|. | |
233 // crbug.com/362214 | |
227 bool SchemeIsSecure() const { | 234 bool SchemeIsSecure() const { |
228 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme) || | 235 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme) || |
229 (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); | 236 (SchemeIsFileSystem() && inner_url() && |
237 inner_url()->SchemeIsSecure()); | |
238 } | |
239 | |
240 // Returns true if the scheme indicates a network connection that uses TLS for | |
241 // security. | |
felt
2015/04/08 00:10:08
Can you add a note here saying you might want cont
palmer
2015/04/08 00:50:07
Done.
| |
242 bool SchemeUsesTLS() const { | |
243 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme); | |
230 } | 244 } |
231 | 245 |
232 // Returns true if the scheme is "blob". | 246 // Returns true if the scheme is "blob". |
233 bool SchemeIsBlob() const { | 247 bool SchemeIsBlob() const { |
234 return SchemeIs(url::kBlobScheme); | 248 return SchemeIs(url::kBlobScheme); |
235 } | 249 } |
236 | 250 |
237 // The "content" of the URL is everything after the scheme (skipping the | 251 // 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 | 252 // scheme delimiting colon). It is an error to get the origin of an invalid |
239 // URL. The result will be an empty string. | 253 // URL. The result will be an empty string. |
240 std::string GetContent() const; | 254 std::string GetContent() const; |
241 | 255 |
242 // Returns true if the hostname is an IP address. Note: this function isn't | 256 // 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. | 257 // 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; | 258 bool HostIsIPAddress() const; |
246 | 259 |
247 // Getters for various components of the URL. The returned string will be | 260 // Getters for various components of the URL. The returned string will be |
248 // empty if the component is empty or is not present. | 261 // empty if the component is empty or is not present. |
249 std::string scheme() const { // Not including the colon. See also SchemeIs. | 262 std::string scheme() const { // Not including the colon. See also SchemeIs. |
250 return ComponentString(parsed_.scheme); | 263 return ComponentString(parsed_.scheme); |
251 } | 264 } |
252 std::string username() const { | 265 std::string username() const { |
253 return ComponentString(parsed_.username); | 266 return ComponentString(parsed_.username); |
254 } | 267 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 return parsed_.query.len >= 0; | 316 return parsed_.query.len >= 0; |
304 } | 317 } |
305 bool has_ref() const { | 318 bool has_ref() const { |
306 return parsed_.ref.len >= 0; | 319 return parsed_.ref.len >= 0; |
307 } | 320 } |
308 | 321 |
309 // Returns a parsed version of the port. Can also be any of the special | 322 // Returns a parsed version of the port. Can also be any of the special |
310 // values defined in Parsed for ExtractPort. | 323 // values defined in Parsed for ExtractPort. |
311 int IntPort() const; | 324 int IntPort() const; |
312 | 325 |
313 // Returns the port number of the url, or the default port number. | 326 // 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 | 327 // If the scheme has no concept of port (or unknown default) returns |
315 // PORT_UNSPECIFIED. | 328 // PORT_UNSPECIFIED. |
316 int EffectiveIntPort() const; | 329 int EffectiveIntPort() const; |
317 | 330 |
318 // Extracts the filename portion of the path and returns it. The filename | 331 // 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. | 332 // is everything after the last slash in the path. This may be empty. |
320 std::string ExtractFileName() const; | 333 std::string ExtractFileName() const; |
321 | 334 |
322 // Returns the path that should be sent to the server. This is the path, | 335 // 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. | 336 // 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:]. | 409 // Used for nested schemes [currently only filesystem:]. |
397 scoped_ptr<GURL> inner_url_; | 410 scoped_ptr<GURL> inner_url_; |
398 | 411 |
399 // TODO bug 684583: Add encoding for query params. | 412 // TODO bug 684583: Add encoding for query params. |
400 }; | 413 }; |
401 | 414 |
402 // Stream operator so GURL can be used in assertion statements. | 415 // Stream operator so GURL can be used in assertion statements. |
403 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); | 416 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); |
404 | 417 |
405 #endif // URL_GURL_H_ | 418 #endif // URL_GURL_H_ |
OLD | NEW |