Chromium Code Reviews| Index: url/gurl.h |
| diff --git a/url/gurl.h b/url/gurl.h |
| index 566fc5e18317f899738a705c310c81b03ec13b7a..3dd9603e2b246d0ace2b6c910553e1616672c703 100644 |
| --- a/url/gurl.h |
| +++ b/url/gurl.h |
| @@ -223,12 +223,26 @@ class URL_EXPORT GURL { |
| return SchemeIs(url::kFileSystemScheme); |
| } |
| - // If the scheme indicates a secure connection |
| + // Returns true if the scheme indicates a secure connection. |
| + // |
| + // TODO(palmer): Consider removing this function and changing its callers to |
| + // call |OriginIsSecure|, or a wrapper around |OriginIsSecure| that takes the |
| + // schemes registered with |WebSecurityPolicy::registerURLSchemeAsSecure| into |
| + // account. crbug.com/362214. |
| bool SchemeIsSecure() const { |
| - return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme) || |
| - (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); |
| + return SchemeIs(url::kFileScheme) || SchemeIs(url::kHttpsScheme) || |
| + SchemeIs(url::kWssScheme) || (SchemeIsFileSystem() && inner_url() && |
| + inner_url()->SchemeIsSecure()); |
| } |
| + // Returns true if the origin is secure. See |
| + // https://www.w3.org/TR/powerful-features/#is-origin-trustworthy. |
| + // |
| + // TODO(palmer): In a higher layer, such as content/, add a new function that |
| + // wraps this function and takes into account the schemes registered with |
| + // |WebSecurityPolicy::registerURLSchemeAsSecure| in Blink. crbug.com/362214. |
| + bool OriginIsSecure() const { return SchemeIsSecure() || HostIsLocal(); } |
| + |
| // Returns true if the scheme is "blob". |
| bool SchemeIsBlob() const { |
| return SchemeIs(url::kBlobScheme); |
| @@ -241,9 +255,12 @@ class URL_EXPORT GURL { |
| // Returns true if the hostname is an IP address. Note: this function isn't |
| // as cheap as a simple getter because it re-parses the hostname to verify. |
| - // This currently identifies only IPv4 addresses (bug 822685). |
| bool HostIsIPAddress() const; |
| + // Returns true if the hostname is "localhost" or if it is the IPv6 localhost |
| + // address (::1) or if it is a localhost IPv4 address (127/8). |
| + bool HostIsLocal() const; |
|
felt
2015/04/01 18:03:18
this seems redundant with net::IsLocalhost (also w
palmer
2015/04/03 22:59:29
Yes, I have 2 reasons to move this code to content
|
| + |
| // Getters for various components of the URL. The returned string will be |
| // empty if the component is empty or is not present. |
| std::string scheme() const { // Not including the colon. See also SchemeIs. |
| @@ -310,7 +327,7 @@ class URL_EXPORT GURL { |
| // values defined in Parsed for ExtractPort. |
| int IntPort() const; |
| - // Returns the port number of the url, or the default port number. |
| + // Returns the port number of the URL, or the default port number. |
| // If the scheme has no concept of port (or unknown default) returns |
| // PORT_UNSPECIFIED. |
| int EffectiveIntPort() const; |