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

Side by Side Diff: components/subresource_filter/core/common/first_party_origin.cc

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Update new uses post-rebase Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/subresource_filter/core/common/first_party_origin.h" 5 #include "components/subresource_filter/core/common/first_party_origin.h"
6 6
7 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 7 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
8 8
9 namespace subresource_filter { 9 namespace subresource_filter {
10 10
11 namespace { 11 namespace {
12 12
13 bool IsThirdPartyImpl(const GURL& url, const url::Origin& first_party_origin) { 13 bool IsThirdPartyImpl(const GURL& url, const url::Origin& first_party_origin) {
14 return !net::registry_controlled_domains::SameDomainOrHost( 14 return !net::registry_controlled_domains::SameDomainOrHost(
15 url, first_party_origin, 15 url, first_party_origin,
16 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 16 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
17 } 17 }
18 18
19 } // namespace 19 } // namespace
20 20
21 FirstPartyOrigin::FirstPartyOrigin(url::Origin document_origin) 21 FirstPartyOrigin::FirstPartyOrigin(url::Origin document_origin)
22 : document_origin_(std::move(document_origin)) {} 22 : document_origin_(std::move(document_origin)) {}
23 23
24 bool FirstPartyOrigin::IsThirdParty(const GURL& url) const { 24 bool FirstPartyOrigin::IsThirdParty(const GURL& url) const {
25 if (document_origin_.unique()) 25 if (document_origin_.opaque())
26 return true; 26 return true;
27 base::StringPiece host_piece = url.host_piece(); 27 base::StringPiece host_piece = url.host_piece();
28 if (!last_checked_host_.empty() && host_piece == last_checked_host_) 28 if (!last_checked_host_.empty() && host_piece == last_checked_host_)
29 return last_checked_host_was_third_party_; 29 return last_checked_host_was_third_party_;
30 30
31 last_checked_host_.assign(host_piece.data(), host_piece.size()); 31 last_checked_host_.assign(host_piece.data(), host_piece.size());
32 last_checked_host_was_third_party_ = IsThirdPartyImpl(url, document_origin_); 32 last_checked_host_was_third_party_ = IsThirdPartyImpl(url, document_origin_);
33 return last_checked_host_was_third_party_; 33 return last_checked_host_was_third_party_;
34 } 34 }
35 35
36 bool FirstPartyOrigin::IsThirdParty(const GURL& url, 36 bool FirstPartyOrigin::IsThirdParty(const GURL& url,
37 const url::Origin& first_party_origin) { 37 const url::Origin& first_party_origin) {
38 return first_party_origin.unique() || 38 return first_party_origin.opaque() ||
39 IsThirdPartyImpl(url, first_party_origin); 39 IsThirdPartyImpl(url, first_party_origin);
40 } 40 }
41 41
42 } // namespace subresouce_filter 42 } // namespace subresouce_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698