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

Unified Diff: components/subresource_filter/core/common/first_party_origin.cc

Issue 2668213002: Remove Origin->GURL conversion in DocumentSubresourceFilter (Closed)
Patch Set: reviews (std::string::assign + comment) Created 3 years, 11 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 | « components/subresource_filter/core/common/first_party_origin.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/subresource_filter/core/common/first_party_origin.cc
diff --git a/components/subresource_filter/core/common/first_party_origin.cc b/components/subresource_filter/core/common/first_party_origin.cc
index a622c698ba747aaa5008aa903b591a8843070b6f..46a218f9962eb862aa8fcbbd71b240ec1545a0c0 100644
--- a/components/subresource_filter/core/common/first_party_origin.cc
+++ b/components/subresource_filter/core/common/first_party_origin.cc
@@ -10,36 +10,33 @@ namespace subresource_filter {
namespace {
-bool IsThirdPartyImpl(const GURL& url, const GURL& first_party_url) {
+bool IsThirdPartyImpl(const GURL& url, const url::Origin& first_party_origin) {
return !net::registry_controlled_domains::SameDomainOrHost(
- url, first_party_url,
+ url, first_party_origin,
net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
}
} // namespace
FirstPartyOrigin::FirstPartyOrigin(url::Origin document_origin)
- : document_origin_(std::move(document_origin)) {
- document_origin_as_gurl_ = GURL(document_origin_.Serialize());
-}
+ : document_origin_(std::move(document_origin)) {}
bool FirstPartyOrigin::IsThirdParty(const GURL& url) const {
if (document_origin_.unique())
return true;
- if (!last_checked_host_.empty() && url.host_piece() == last_checked_host_)
+ base::StringPiece host_piece = url.host_piece();
+ if (!last_checked_host_.empty() && host_piece == last_checked_host_)
return last_checked_host_was_third_party_;
- url.host_piece().CopyToString(&last_checked_host_);
- last_checked_host_was_third_party_ =
- IsThirdPartyImpl(url, document_origin_as_gurl_);
+ last_checked_host_.assign(host_piece.data(), host_piece.size());
+ last_checked_host_was_third_party_ = IsThirdPartyImpl(url, document_origin_);
return last_checked_host_was_third_party_;
}
bool FirstPartyOrigin::IsThirdParty(const GURL& url,
const url::Origin& first_party_origin) {
- // TODO(pkalinnikov): Avoid converting Origin to GURL.
return first_party_origin.unique() ||
- IsThirdPartyImpl(url, GURL(first_party_origin.Serialize()));
+ IsThirdPartyImpl(url, first_party_origin);
}
} // namespace subresouce_filter
« no previous file with comments | « components/subresource_filter/core/common/first_party_origin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698