| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ORIGIN_H_ | 5 #ifndef URL_ORIGIN_H_ |
| 6 #define URL_ORIGIN_H_ | 6 #define URL_ORIGIN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // | 82 // |
| 83 // 1. If |url| is invalid or non-standard, a unique Origin is constructed. | 83 // 1. If |url| is invalid or non-standard, a unique Origin is constructed. |
| 84 // 2. 'filesystem' URLs behave as 'blob' URLs (that is, the origin is parsed | 84 // 2. 'filesystem' URLs behave as 'blob' URLs (that is, the origin is parsed |
| 85 // out of everything in the URL which follows the scheme). | 85 // out of everything in the URL which follows the scheme). |
| 86 // 3. 'file' URLs all parse as ("file", "", 0). | 86 // 3. 'file' URLs all parse as ("file", "", 0). |
| 87 explicit Origin(const GURL& url); | 87 explicit Origin(const GURL& url); |
| 88 | 88 |
| 89 ~Origin(); | 89 ~Origin(); |
| 90 | 90 |
| 91 // For unique origins, these return ("", "", 0). | 91 // For unique origins, these return ("", "", 0). |
| 92 // | 92 const std::string& scheme() const { return tuple_.scheme(); } |
| 93 // TODO(mkwst): These should be 'const std::string&', along with their | 93 const std::string& host() const { return tuple_.host(); } |
| 94 // 'url::SchemeHostPort' analogs. | |
| 95 std::string scheme() const { return tuple_.scheme(); } | |
| 96 std::string host() const { return tuple_.host(); } | |
| 97 uint16 port() const { return tuple_.port(); } | 94 uint16 port() const { return tuple_.port(); } |
| 98 | 95 |
| 99 bool unique() const { return unique_; } | 96 bool unique() const { return unique_; } |
| 100 | 97 |
| 101 // An ASCII serialization of the Origin as per Section 6.2 of RFC 6454, with | 98 // An ASCII serialization of the Origin as per Section 6.2 of RFC 6454, with |
| 102 // the addition that all Origins with a 'file' scheme serialize to "file://". | 99 // the addition that all Origins with a 'file' scheme serialize to "file://". |
| 103 std::string Serialize() const; | 100 std::string Serialize() const; |
| 104 | 101 |
| 105 // Two Origins are "same-origin" if their schemes, hosts, and ports are exact | 102 // Two Origins are "same-origin" if their schemes, hosts, and ports are exact |
| 106 // matches; and neither is unique. | 103 // matches; and neither is unique. |
| 107 bool IsSameOriginWith(const Origin& other) const; | 104 bool IsSameOriginWith(const Origin& other) const; |
| 108 | 105 |
| 109 // Allows SchemeHostPort to used as a key in STL (for example, a std::set or | 106 // Allows SchemeHostPort to used as a key in STL (for example, a std::set or |
| 110 // std::map). | 107 // std::map). |
| 111 bool operator<(const Origin& other) const; | 108 bool operator<(const Origin& other) const; |
| 112 | 109 |
| 113 private: | 110 private: |
| 114 SchemeHostPort tuple_; | 111 SchemeHostPort tuple_; |
| 115 bool unique_; | 112 bool unique_; |
| 116 | 113 |
| 117 DISALLOW_COPY_AND_ASSIGN(Origin); | 114 DISALLOW_COPY_AND_ASSIGN(Origin); |
| 118 }; | 115 }; |
| 119 | 116 |
| 120 URL_EXPORT std::ostream& operator<<(std::ostream& out, | 117 URL_EXPORT std::ostream& operator<<(std::ostream& out, |
| 121 const Origin& origin); | 118 const Origin& origin); |
| 122 | 119 |
| 123 } // namespace url | 120 } // namespace url |
| 124 | 121 |
| 125 #endif // URL_SCHEME_HOST_PORT_H_ | 122 #endif // URL_SCHEME_HOST_PORT_H_ |
| OLD | NEW |