Chromium Code Reviews| Index: url/origin.h |
| diff --git a/url/origin.h b/url/origin.h |
| index 777e4e1ef481bc062557b2fc8d7fe2437f784c0d..b79e434645d19b2d3182b9e15c67c086c52044a6 100644 |
| --- a/url/origin.h |
| +++ b/url/origin.h |
| @@ -7,27 +7,57 @@ |
| #include <string> |
| +#include "url/gurl.h" |
| #include "url/url_export.h" |
| namespace url { |
| -// Origin represents a Web Origin serialized to a string. |
| -// See RFC6454 for details. |
| +// Origin represents a scheme/host/port tuple, as described in RFC6454. |
| class URL_EXPORT Origin { |
| public: |
| + // Creates a unique Origin. Note that unique origins are not == to _any_ |
| + // other origin, including themselves. |
| Origin(); |
| - explicit Origin(const std::string& origin); |
| - const std::string& string() const { return string_; } |
| + explicit Origin(const GURL& url); |
| + explicit Origin(const std::string& origin); |
|
Ryan Sleevi
2015/05/22 02:50:03
Not a fan of having a string constructor - gives u
|
| - bool IsSameAs(const Origin& that) const { |
| - return string_ == that.string_; |
| + bool SchemeIs(const std::string& scheme) const; |
| + bool SchemeIsCryptographic() const { |
| + return SchemeIs("https") || SchemeIs("wss"); |
| } |
| + std::string scheme() const { return scheme_; } |
| + std::string host() const { return host_; } |
| + unsigned short port() const { return port_; } |
| + bool unique() const { return unique_; } |
| + |
| + // Returns a serialization of the origin, suitable for passing around via IPC. |
| + // This is _not_ the serialization of the origin which ought to be displayed |
| + // to a user in Chrome's UI. |
| + std::string serialize() const; |
| + |
| + // TODO(mkwst): Remove this. |
| + std::string string() const { return serialize(); } |
|
Ryan Sleevi
2015/05/22 02:50:03
Generally not a fan of classes managing their own
|
| + |
| + bool operator==(const Origin& other) const; |
| + bool operator!=(const Origin& other) const; |
|
Ryan Sleevi
2015/05/22 02:50:03
Blink vs Chrome will strike again - http://google-
|
| + |
| private: |
| + void Init(const GURL& url); |
| + |
| + std::string scheme_; |
| + std::string host_; |
| + unsigned short port_; |
| + bool unique_; |
| + bool is_default_port_; |
| + |
| std::string string_; |
| }; |
| +// Stream operator so Origin can be used in assertion statements. |
| +URL_EXPORT std::ostream& operator<<(std::ostream& out, const url::Origin& url); |
| + |
| } // namespace url |
| #endif // URL_ORIGIN_H_ |