Chromium Code Reviews| Index: url/origin.h |
| diff --git a/url/origin.h b/url/origin.h |
| index 273622edc8a0624901af12e2a8eac3d6e5a96b8c..088a059ece20c89f8b7734fada73e24fec49d523 100644 |
| --- a/url/origin.h |
| +++ b/url/origin.h |
| @@ -109,19 +109,34 @@ class URL_EXPORT Origin { |
| const std::string& host() const { return tuple_.host(); } |
| uint16_t port() const { return tuple_.port(); } |
| + // Note that an origin without a suborgin will return the empty string. |
| + const std::string& suborigin() const { return suborigin_; } |
| + |
| bool unique() const { return unique_; } |
| // An ASCII serialization of the Origin as per Section 6.2 of RFC 6454, with |
| // the addition that all Origins with a 'file' scheme serialize to "file://". |
| + // If the Origin has a suborigin, it will be serialized per |
| + // https://w3c.github.io/webappsec-suborigins/#serializing. |
| std::string Serialize() const; |
| + // Same as above, but ignores the suborigin component of the origin, if it |
| + // exists, returning only the physical origin.. For example, when |
|
Mike West
2016/10/11 07:40:41
Nit: ..
jww
2016/10/11 18:16:27
Done.
|
| + // SerializePhysicalOrigin() is called on the origin |
| + // https-so://foobar.example.com, it will return https://example.com. |
| + std::string SerializePhysicalOrigin() const; |
| + |
| // Two Origins are "same-origin" if their schemes, hosts, and ports are exact |
| - // matches; and neither is unique. |
| + // matches; and neither is unique. If either of the origins have suborigins, |
| + // the suborigins also must be exact matches. |
| bool IsSameOriginWith(const Origin& other) const; |
| bool operator==(const Origin& other) const { |
| return IsSameOriginWith(other); |
| } |
| + // Same as above, but ignores suborigins if they exist. |
| + bool IsSamePhysicalOriginWith(const Origin& other) const; |
| + |
| // Efficiently returns what GURL(Serialize()) would without re-parsing the |
| // URL. This can be used for the (rare) times a GURL representation is needed |
| // for an Origin. |
| @@ -142,11 +157,13 @@ class URL_EXPORT Origin { |
| SchemeHostPort tuple_; |
| bool unique_; |
| + std::string suborigin_; |
| }; |
| URL_EXPORT std::ostream& operator<<(std::ostream& out, const Origin& origin); |
| URL_EXPORT bool IsSameOriginWith(const GURL& a, const GURL& b); |
| +URL_EXPORT bool IsSamePhysicalOriginWith(const GURL& a, const GURL& b); |
| } // namespace url |