| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 base::StringPiece host, | 102 base::StringPiece host, |
| 103 uint16_t port); | 103 uint16_t port); |
| 104 | 104 |
| 105 // Creates an origin without sanity checking that the host is canonicalized. | 105 // Creates an origin without sanity checking that the host is canonicalized. |
| 106 // This should only be used when converting between already normalized types, | 106 // This should only be used when converting between already normalized types, |
| 107 // and should NOT be used for IPC. | 107 // and should NOT be used for IPC. |
| 108 static Origin CreateFromNormalizedTuple(base::StringPiece scheme, | 108 static Origin CreateFromNormalizedTuple(base::StringPiece scheme, |
| 109 base::StringPiece host, | 109 base::StringPiece host, |
| 110 uint16_t port); | 110 uint16_t port); |
| 111 | 111 |
| 112 // Same as CreateFromNormalizedTuple() above, but adds a suborigin component |
| 113 // as well. |
| 114 static Origin CreateFromNormalizedTupleWithSuborigin( |
| 115 base::StringPiece scheme, |
| 116 base::StringPiece host, |
| 117 uint16_t port, |
| 118 base::StringPiece suborigin); |
| 119 |
| 112 ~Origin(); | 120 ~Origin(); |
| 113 | 121 |
| 114 // For unique origins, these return ("", "", 0). | 122 // For unique origins, these return ("", "", 0). |
| 115 const std::string& scheme() const { return tuple_.scheme(); } | 123 const std::string& scheme() const { return tuple_.scheme(); } |
| 116 const std::string& host() const { return tuple_.host(); } | 124 const std::string& host() const { return tuple_.host(); } |
| 117 uint16_t port() const { return tuple_.port(); } | 125 uint16_t port() const { return tuple_.port(); } |
| 118 | 126 |
| 119 // Note that an origin without a suborgin will return the empty string. | 127 // Note that an origin without a suborgin will return the empty string. |
| 120 const std::string& suborigin() const { return suborigin_; } | 128 const std::string& suborigin() const { return suborigin_; } |
| 121 | 129 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 bool DomainIs(base::StringPiece lower_ascii_domain) const; | 164 bool DomainIs(base::StringPiece lower_ascii_domain) const; |
| 157 | 165 |
| 158 // Allows Origin to be used as a key in STL (for example, a std::set or | 166 // Allows Origin to be used as a key in STL (for example, a std::set or |
| 159 // std::map). | 167 // std::map). |
| 160 bool operator<(const Origin& other) const; | 168 bool operator<(const Origin& other) const; |
| 161 | 169 |
| 162 private: | 170 private: |
| 163 Origin(base::StringPiece scheme, | 171 Origin(base::StringPiece scheme, |
| 164 base::StringPiece host, | 172 base::StringPiece host, |
| 165 uint16_t port, | 173 uint16_t port, |
| 174 base::StringPiece suborigin, |
| 166 SchemeHostPort::ConstructPolicy policy); | 175 SchemeHostPort::ConstructPolicy policy); |
| 167 | 176 |
| 168 SchemeHostPort tuple_; | 177 SchemeHostPort tuple_; |
| 169 bool unique_; | 178 bool unique_; |
| 170 std::string suborigin_; | 179 std::string suborigin_; |
| 171 }; | 180 }; |
| 172 | 181 |
| 173 URL_EXPORT std::ostream& operator<<(std::ostream& out, const Origin& origin); | 182 URL_EXPORT std::ostream& operator<<(std::ostream& out, const Origin& origin); |
| 174 | 183 |
| 175 URL_EXPORT bool IsSameOriginWith(const GURL& a, const GURL& b); | 184 URL_EXPORT bool IsSameOriginWith(const GURL& a, const GURL& b); |
| 176 URL_EXPORT bool IsSamePhysicalOriginWith(const GURL& a, const GURL& b); | 185 URL_EXPORT bool IsSamePhysicalOriginWith(const GURL& a, const GURL& b); |
| 177 | 186 |
| 178 } // namespace url | 187 } // namespace url |
| 179 | 188 |
| 180 #endif // URL_ORIGIN_H_ | 189 #endif // URL_ORIGIN_H_ |
| OLD | NEW |