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| (if | |
229 // you just want to know if a scheme uses TLS for network transport) or | |
230 // Chromium's |content::IsOriginSecure| or |IsOriginSecure| for a higher-level | |
231 // test about an origin's security. See those functions' documentation for | |
232 // more detail. | |
233 // | |
234 // TODO(palmer): Audit callers and change them to |SchemeUsesTLS| or | |
235 // |content::IsOriginSecure|, as appropriate. Then remove |SchemeIsSecure|. | |
davidben
2015/04/16 17:20:36
Missed a spot. :-)
content::IsOriginSecure -> IsO
palmer
2015/04/16 17:26:07
Done.
| |
236 // crbug.com/362214 | |
227 bool SchemeIsSecure() const { | 237 bool SchemeIsSecure() const { |
228 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme) || | 238 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme) || |
229 (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); | 239 (SchemeIsFileSystem() && inner_url() && |
240 inner_url()->SchemeIsSecure()); | |
241 } | |
242 | |
243 // Returns true if the scheme indicates a network connection that uses TLS for | |
244 // security. | |
245 // | |
246 // This function is a not a complete test of whether or not an origin's code | |
247 // is minimally trustworthy. For that, see Chromium's |IsOriginSecure| for a | |
248 // higher-level and more complete semantics. See that function's documentation | |
249 // for more detail. | |
250 bool SchemeUsesTLS() const { | |
251 return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme); | |
230 } | 252 } |
231 | 253 |
232 // Returns true if the scheme is "blob". | 254 // Returns true if the scheme is "blob". |
233 bool SchemeIsBlob() const { | 255 bool SchemeIsBlob() const { |
234 return SchemeIs(url::kBlobScheme); | 256 return SchemeIs(url::kBlobScheme); |
235 } | 257 } |
236 | 258 |
237 // The "content" of the URL is everything after the scheme (skipping the | 259 // 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 | 260 // scheme delimiting colon). It is an error to get the origin of an invalid |
239 // URL. The result will be an empty string. | 261 // URL. The result will be an empty string. |
240 std::string GetContent() const; | 262 std::string GetContent() const; |
241 | 263 |
242 // Returns true if the hostname is an IP address. Note: this function isn't | 264 // 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. | 265 // 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; | 266 bool HostIsIPAddress() const; |
246 | 267 |
247 // Getters for various components of the URL. The returned string will be | 268 // Getters for various components of the URL. The returned string will be |
248 // empty if the component is empty or is not present. | 269 // empty if the component is empty or is not present. |
249 std::string scheme() const { // Not including the colon. See also SchemeIs. | 270 std::string scheme() const { // Not including the colon. See also SchemeIs. |
250 return ComponentString(parsed_.scheme); | 271 return ComponentString(parsed_.scheme); |
251 } | 272 } |
252 std::string username() const { | 273 std::string username() const { |
253 return ComponentString(parsed_.username); | 274 return ComponentString(parsed_.username); |
254 } | 275 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 return parsed_.query.len >= 0; | 324 return parsed_.query.len >= 0; |
304 } | 325 } |
305 bool has_ref() const { | 326 bool has_ref() const { |
306 return parsed_.ref.len >= 0; | 327 return parsed_.ref.len >= 0; |
307 } | 328 } |
308 | 329 |
309 // Returns a parsed version of the port. Can also be any of the special | 330 // Returns a parsed version of the port. Can also be any of the special |
310 // values defined in Parsed for ExtractPort. | 331 // values defined in Parsed for ExtractPort. |
311 int IntPort() const; | 332 int IntPort() const; |
312 | 333 |
313 // Returns the port number of the url, or the default port number. | 334 // 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 | 335 // If the scheme has no concept of port (or unknown default) returns |
315 // PORT_UNSPECIFIED. | 336 // PORT_UNSPECIFIED. |
316 int EffectiveIntPort() const; | 337 int EffectiveIntPort() const; |
317 | 338 |
318 // Extracts the filename portion of the path and returns it. The filename | 339 // 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. | 340 // is everything after the last slash in the path. This may be empty. |
320 std::string ExtractFileName() const; | 341 std::string ExtractFileName() const; |
321 | 342 |
322 // Returns the path that should be sent to the server. This is the path, | 343 // 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. | 344 // 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:]. | 417 // Used for nested schemes [currently only filesystem:]. |
397 scoped_ptr<GURL> inner_url_; | 418 scoped_ptr<GURL> inner_url_; |
398 | 419 |
399 // TODO bug 684583: Add encoding for query params. | 420 // TODO bug 684583: Add encoding for query params. |
400 }; | 421 }; |
401 | 422 |
402 // Stream operator so GURL can be used in assertion statements. | 423 // Stream operator so GURL can be used in assertion statements. |
403 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); | 424 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); |
404 | 425 |
405 #endif // URL_GURL_H_ | 426 #endif // URL_GURL_H_ |
OLD | NEW |