Chromium Code Reviews| 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 #include "url/origin.h" | 5 #include "url/origin.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 151 |
| 152 GURL tuple_url(tuple_.GetURL()); | 152 GURL tuple_url(tuple_.GetURL()); |
| 153 | 153 |
| 154 if (!suborigin_.empty()) | 154 if (!suborigin_.empty()) |
| 155 return AddSuboriginToUrl(tuple_url, suborigin_); | 155 return AddSuboriginToUrl(tuple_url, suborigin_); |
| 156 | 156 |
| 157 return tuple_url; | 157 return tuple_url; |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool Origin::IsSameOriginWith(const Origin& other) const { | 160 bool Origin::IsSameOriginWith(const Origin& other) const { |
| 161 if (this == &other) | |
| 162 return true; | |
| 163 | |
| 161 if (unique_ || other.unique_) | 164 if (unique_ || other.unique_) |
| 162 return false; | 165 return false; |
| 163 | 166 |
| 164 return tuple_.Equals(other.tuple_) && suborigin_ == other.suborigin_; | 167 return tuple_.Equals(other.tuple_) && suborigin_ == other.suborigin_; |
| 165 } | 168 } |
| 166 | 169 |
| 167 bool Origin::IsSamePhysicalOriginWith(const Origin& other) const { | 170 bool Origin::IsSamePhysicalOriginWith(const Origin& other) const { |
|
Marijn Kruisselbrink
2017/02/23 23:39:18
Shouldn't an opaque origin also be considered same
| |
| 168 return GetPhysicalOrigin().IsSameOriginWith(other.GetPhysicalOrigin()); | 171 return GetPhysicalOrigin().IsSameOriginWith(other.GetPhysicalOrigin()); |
| 169 } | 172 } |
| 170 | 173 |
| 171 bool Origin::DomainIs(base::StringPiece lower_ascii_domain) const { | 174 bool Origin::DomainIs(base::StringPiece lower_ascii_domain) const { |
| 172 return !unique_ && url::DomainIs(tuple_.host(), lower_ascii_domain); | 175 return !unique_ && url::DomainIs(tuple_.host(), lower_ascii_domain); |
| 173 } | 176 } |
| 174 | 177 |
| 175 bool Origin::operator<(const Origin& other) const { | 178 bool Origin::operator<(const Origin& other) const { |
| 176 return tuple_ < other.tuple_; | 179 return tuple_ < other.tuple_; |
| 177 } | 180 } |
| 178 | 181 |
| 179 std::ostream& operator<<(std::ostream& out, const url::Origin& origin) { | 182 std::ostream& operator<<(std::ostream& out, const url::Origin& origin) { |
| 180 return out << origin.Serialize(); | 183 return out << origin.Serialize(); |
| 181 } | 184 } |
| 182 | 185 |
| 183 bool IsSameOriginWith(const GURL& a, const GURL& b) { | 186 bool IsSameOriginWith(const GURL& a, const GURL& b) { |
| 184 return Origin(a).IsSameOriginWith(Origin(b)); | 187 return Origin(a).IsSameOriginWith(Origin(b)); |
| 185 } | 188 } |
| 186 | 189 |
| 187 bool IsSamePhysicalOriginWith(const GURL& a, const GURL& b) { | 190 bool IsSamePhysicalOriginWith(const GURL& a, const GURL& b) { |
| 188 return Origin(a).IsSamePhysicalOriginWith(Origin(b)); | 191 return Origin(a).IsSamePhysicalOriginWith(Origin(b)); |
| 189 } | 192 } |
| 190 | 193 |
| 191 } // namespace url | 194 } // namespace url |
| OLD | NEW |