Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Unified Diff: url/origin.cc

Issue 1726323002: Have Permission{Manager,Service} use Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/origin.h ('k') | url/origin_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/origin.cc
diff --git a/url/origin.cc b/url/origin.cc
index 97e24f208d5b2098df01078615a7791503d30fbf..f540e940cc704e625dd55b1a05dae06659dc9716 100644
--- a/url/origin.cc
+++ b/url/origin.cc
@@ -17,12 +17,13 @@
namespace url {
-Origin::Origin() : unique_(true) {
-}
+Origin::Origin() : unique_(true), empty_(false) {}
-Origin::Origin(const GURL& url) : unique_(true) {
- if (!url.is_valid() || (!url.IsStandard() && !url.SchemeIsBlob()))
+Origin::Origin(const GURL& url)
+ : unique_(!url.is_empty()), empty_(url.is_empty()) {
+ if (!url.is_valid() || (!url.IsStandard() && !url.SchemeIsBlob())) {
return;
+ }
if (url.SchemeIsFileSystem()) {
tuple_ = SchemeHostPort(*url.inner_url());
@@ -39,9 +40,12 @@ Origin::Origin(const GURL& url) : unique_(true) {
unique_ = tuple_.IsInvalid();
}
+Origin::Origin(const std::string& url_string) : Origin(GURL(url_string)) {}
+
Origin::Origin(base::StringPiece scheme, base::StringPiece host, uint16_t port)
: tuple_(scheme, host, port) {
unique_ = tuple_.IsInvalid();
+ empty_ = scheme.empty() && host.empty() && port == 0;
}
Origin::~Origin() {
@@ -56,6 +60,9 @@ Origin Origin::UnsafelyCreateOriginWithoutNormalization(
}
std::string Origin::Serialize() const {
+ if (empty())
+ return "";
+
if (unique())
return "null";
@@ -66,6 +73,9 @@ std::string Origin::Serialize() const {
}
bool Origin::IsSameOriginWith(const Origin& other) const {
+ if (empty_ && other.empty_)
+ return true;
+
if (unique_ || other.unique_)
return false;
« no previous file with comments | « url/origin.h ('k') | url/origin_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698