Commit 3f3d6e7c authored by Steven Bingler's avatar Steven Bingler Committed by Commit Bot

Check SiteForCookies validity using IsNull instead of scheme_.empty

SiteForCookies's member functions check the scheme length to
determine if the object is valid for that operation.

In an effort to centralize the logic use IsNull instead.

Change-Id: I131a946d5547d1cf944c365fabebe9a67391ae73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135899Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Commit-Queue: Steven Bingler <bingler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756783}
parent 5b70048c
...@@ -70,7 +70,7 @@ std::string SiteForCookies::ToDebugString() const { ...@@ -70,7 +70,7 @@ std::string SiteForCookies::ToDebugString() const {
} }
bool SiteForCookies::IsFirstParty(const GURL& url) const { bool SiteForCookies::IsFirstParty(const GURL& url) const {
if (scheme_.empty() || !url.is_valid()) if (IsNull() || !url.is_valid())
return false; return false;
std::string other_registrable_domain = RegistrableDomainOrHost(url.host()); std::string other_registrable_domain = RegistrableDomainOrHost(url.host());
...@@ -82,8 +82,8 @@ bool SiteForCookies::IsFirstParty(const GURL& url) const { ...@@ -82,8 +82,8 @@ bool SiteForCookies::IsFirstParty(const GURL& url) const {
} }
bool SiteForCookies::IsEquivalent(const SiteForCookies& other) const { bool SiteForCookies::IsEquivalent(const SiteForCookies& other) const {
if (scheme_.empty()) if (IsNull())
return other.scheme_.empty(); return other.IsNull();
if (registrable_domain_.empty()) if (registrable_domain_.empty())
return other.registrable_domain_.empty() && (scheme_ == other.scheme_); return other.registrable_domain_.empty() && (scheme_ == other.scheme_);
...@@ -92,7 +92,7 @@ bool SiteForCookies::IsEquivalent(const SiteForCookies& other) const { ...@@ -92,7 +92,7 @@ bool SiteForCookies::IsEquivalent(const SiteForCookies& other) const {
} }
GURL SiteForCookies::RepresentativeUrl() const { GURL SiteForCookies::RepresentativeUrl() const {
if (scheme_.empty()) if (IsNull())
return GURL(); return GURL();
GURL result(base::StrCat({scheme_, "://", registrable_domain_, "/"})); GURL result(base::StrCat({scheme_, "://", registrable_domain_, "/"}));
DCHECK(result.is_valid()); DCHECK(result.is_valid());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment