Chromium Code Reviews| Index: url/origin.h |
| diff --git a/url/origin.h b/url/origin.h |
| index 89d81da5820823c94b42ef2ac26fc061bc95c0fb..beb24a05707e124a131d9843e7947f681d285100 100644 |
| --- a/url/origin.h |
| +++ b/url/origin.h |
| @@ -116,19 +116,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 |
| + // 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; |
|
michaeln
2016/10/19 20:36:02
Might be nice to have an Origin GetPhysicalOrigin(
jww
2016/10/19 22:11:23
Indeed. Per a suggestion from nasko@, I'm thinking
jww
2016/10/20 06:03:47
Changed my mind and added it in this CL. I think i
|
| + |
| // 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. |
| @@ -152,11 +167,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 |