Skip to content

Commit

Permalink
Rename "first_party_for_cookies" to "site_for_cookies".
Browse files Browse the repository at this point in the history
This is consistent with the language used in
https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site to
describe the difference in behavior for "same-site" and "cross-site"
requests, and more accurately describes the extent of the check
that's happening under the hood when users choose to "block
third-party cookies".

This change is completely mechanical, produced by the following:

git grep -n -l \
  -e 'first_party_for_cookies' -e 'west-first-party-cookies' \
  -e 'FirstPartyForCookies' -e 'firstPartyForCookies' -- \
  "*.h" "*.hpp" "*.cpp" "*.c" "*.cc" "*.cpp" "*.inl" "*.grd" \
  "*.idl" "*.m" "*.mm" "*.py" "*.sh" "*.cfg" "*.tac" "*.go" \
  "*SConscript" "SConscript*" "*.scons" "*.vcproj" "*.vsprops" \
  "*.make" "*.gyp" "*.gypi" "*.isolate" "*.js" "*.html" "*.css" \
  "*.ebuild" "*.pl" "*.pm" \
  | xargs -L1 sed -i '' \
      -e 's/first_party_for_cookies/site_for_cookies/g' \
      -e 's/west-first-party-cookies/ietf-httpbis-cookie-same-site/' \
      -e 's/FirstPartyForCookies/SiteForCookies/g' \
      -e 's/firstPartyforCookies/siteForCookies/g' \
&& git cl format

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: I8e6d48ae2ff15ba82b9d3b62d2a53faf4608819f
Reviewed-on: https://chromium-review.googlesource.com/590451
Commit-Queue: Mike West <mkwst@chromium.org>
Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#493378}
  • Loading branch information
mikewest authored and Commit Bot committed Aug 10, 2017
1 parent 8d20621 commit b85da8e
Show file tree
Hide file tree
Showing 176 changed files with 509 additions and 576 deletions.
4 changes: 2 additions & 2 deletions android_webview/browser/aw_cookie_access_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool AwCookieAccessPolicy::OnCanGetCookies(const net::URLRequest& request,
bool global = GetShouldAcceptCookies();
bool thirdParty = GetShouldAcceptThirdPartyCookies(request);
return AwStaticCookiePolicy(global, thirdParty)
.AllowGet(request.url(), request.first_party_for_cookies());
.AllowGet(request.url(), request.site_for_cookies());
}

bool AwCookieAccessPolicy::OnCanSetCookie(const net::URLRequest& request,
Expand All @@ -90,7 +90,7 @@ bool AwCookieAccessPolicy::OnCanSetCookie(const net::URLRequest& request,
bool global = GetShouldAcceptCookies();
bool thirdParty = GetShouldAcceptThirdPartyCookies(request);
return AwStaticCookiePolicy(global, thirdParty)
.AllowSet(request.url(), request.first_party_for_cookies());
.AllowSet(request.url(), request.site_for_cookies());
}

bool AwCookieAccessPolicy::AllowGetCookie(const GURL& url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ TEST_F(WebRequestRulesRegistryTest, GetMatchesDifferentUrls) {
std::unique_ptr<net::URLRequest> http_request(context.CreateRequest(
urls[i], net::DEFAULT_PRIORITY, NULL, TRAFFIC_ANNOTATION_FOR_TESTS));
WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST);
http_request->set_first_party_for_cookies(firstPartyUrls[i]);
http_request->set_site_for_cookies(firstPartyUrls[i]);
// Now run both rules on the input.
matches = registry->GetMatches(request_data);
SCOPED_TRACE(testing::Message("i = ") << i << ", rule id = "
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/loader/predictor_resource_throttle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void PredictorResourceThrottle::WillStartRequest(bool* defer) {
predictor_->timed_cache()->SetRecentlySeen(request_scheme_host);
if (resource_type == content::RESOURCE_TYPE_SUB_FRAME) {
predictor_->PredictFrameSubresources(request_scheme_host,
request_->first_party_for_cookies());
request_->site_for_cookies());
}
}
}
Expand Down Expand Up @@ -115,8 +115,8 @@ void PredictorResourceThrottle::WillRedirectRequest(
}

predictor_->timed_cache()->SetRecentlySeen(new_scheme_host);
predictor_->PredictFrameSubresources(
new_scheme_host, redirect_info.new_first_party_for_cookies);
predictor_->PredictFrameSubresources(new_scheme_host,
redirect_info.new_site_for_cookies);
}

const char* PredictorResourceThrottle::GetNameForLogging() const {
Expand Down
19 changes: 9 additions & 10 deletions chrome/browser/media/android/remote/remote_media_player_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ RemoteMediaPlayerBridge::RemoteMediaPlayerBridge(
int player_id,
const std::string& user_agent,
RemoteMediaPlayerManager* manager)
: MediaPlayerAndroid(
player_id,
manager,
base::Bind(&DoNothing),
manager->GetLocalPlayer(player_id)->frame_url()),
: MediaPlayerAndroid(player_id,
manager,
base::Bind(&DoNothing),
manager->GetLocalPlayer(player_id)->frame_url()),
width_(0),
height_(0),
url_(manager->GetLocalPlayer(player_id)->GetUrl()),
first_party_for_cookies_(
manager->GetLocalPlayer(player_id)->GetFirstPartyForCookies()),
site_for_cookies_(
manager->GetLocalPlayer(player_id)->GetSiteForCookies()),
user_agent_(user_agent),
weak_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
Expand Down Expand Up @@ -428,16 +427,16 @@ GURL RemoteMediaPlayerBridge::GetUrl() {
return url_;
}

GURL RemoteMediaPlayerBridge::GetFirstPartyForCookies() {
return first_party_for_cookies_;
GURL RemoteMediaPlayerBridge::GetSiteForCookies() {
return site_for_cookies_;
}

void RemoteMediaPlayerBridge::Initialize() {
cookies_.clear();
media::MediaResourceGetter* resource_getter =
manager()->GetMediaResourceGetter();
resource_getter->GetCookies(
url_, first_party_for_cookies_,
url_, site_for_cookies_,
base::Bind(&RemoteMediaPlayerBridge::OnCookiesRetrieved,
weak_factory_.GetWeakPtr()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RemoteMediaPlayerBridge : public media::MediaPlayerAndroid {
bool CanSeekBackward() override;
bool IsPlayerReady() override;
GURL GetUrl() override;
GURL GetFirstPartyForCookies() override;
GURL GetSiteForCookies() override;

// JNI functions
void OnPlaying(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
Expand Down Expand Up @@ -131,7 +131,7 @@ class RemoteMediaPlayerBridge : public media::MediaPlayerAndroid {
GURL url_;

// First party url for cookies.
GURL first_party_for_cookies_;
GURL site_for_cookies_;

// Cookies for |url_|.
std::string cookies_;
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/net/chrome_network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@ bool ChromeNetworkDelegate::OnCanGetCookies(
return true;

bool allow = cookie_settings_->IsCookieAccessAllowed(
request.url(), request.first_party_for_cookies());
request.url(), request.site_for_cookies());

const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
if (info) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&TabSpecificContentSettings::CookiesRead,
info->GetWebContentsGetterForRequest(), request.url(),
request.first_party_for_cookies(), cookie_list, !allow));
request.site_for_cookies(), cookie_list, !allow));
}

return allow;
Expand All @@ -433,15 +433,15 @@ bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
return true;

bool allow = cookie_settings_->IsCookieAccessAllowed(
request.url(), request.first_party_for_cookies());
request.url(), request.site_for_cookies());

const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
if (info) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&TabSpecificContentSettings::CookieChanged,
info->GetWebContentsGetterForRequest(), request.url(),
request.first_party_for_cookies(), cookie_line, *options,
request.site_for_cookies(), cookie_line, *options,
!allow));
}

Expand Down Expand Up @@ -538,12 +538,12 @@ void ChromeNetworkDelegate::EnableAccessToAllFilesForTesting(bool enabled) {

bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const {
const GURL& site_for_cookies) const {
// nullptr during tests, or when we're running in the system context.
if (!cookie_settings_.get())
return false;

return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies);
return !cookie_settings_->IsCookieAccessAllowed(url, site_for_cookies);
}

bool ChromeNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/net/chrome_network_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegateImpl {
bool OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& original_path,
const base::FilePath& absolute_path) const override;
bool OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const override;
bool OnCanEnablePrivacyMode(const GURL& url,
const GURL& site_for_cookies) const override;
bool OnAreExperimentalCookieFeaturesEnabled() const override;
bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(
const net::URLRequest& request,
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/net/loading_predictor_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void LoadingPredictorObserver::OnRequestStarted(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&LoadingPredictorObserver::OnRequestStartedOnUIThread,
base::Unretained(this), base::Passed(std::move(summary)),
web_contents_getter, request->first_party_for_cookies(),
web_contents_getter, request->site_for_cookies(),
request->creation_time()));

if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME)
Expand Down Expand Up @@ -142,7 +142,7 @@ void LoadingPredictorObserver::OnRequestRedirected(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&LoadingPredictorObserver::OnRequestRedirectedOnUIThread,
base::Unretained(this), base::Passed(std::move(summary)),
web_contents_getter, request->first_party_for_cookies(),
web_contents_getter, request->site_for_cookies(),
request->creation_time()));

if (request_info &&
Expand Down Expand Up @@ -177,7 +177,7 @@ void LoadingPredictorObserver::OnResponseStarted(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&LoadingPredictorObserver::OnResponseStartedOnUIThread,
base::Unretained(this), base::Passed(std::move(summary)),
web_contents_getter, request->first_party_for_cookies(),
web_contents_getter, request->site_for_cookies(),
request->creation_time()));

ReportRequestStats(REQUEST_STATS_TOTAL_PROCESSED_RESPONSES);
Expand Down
32 changes: 15 additions & 17 deletions chrome/browser/net/predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) {
}

void Predictor::PreconnectUrlAndSubresources(const GURL& url,
const GURL& first_party_for_cookies) {
const GURL& site_for_cookies) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!PredictorEnabled())
Expand All @@ -293,10 +293,10 @@ void Predictor::PreconnectUrlAndSubresources(const GURL& url,
return;
UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
const int kConnectionsNeeded = 1;
PreconnectUrl(canonicalized_url, first_party_for_cookies, motivation,
PreconnectUrl(canonicalized_url, site_for_cookies, motivation,
kAllowCredentialsOnPreconnectByDefault, kConnectionsNeeded);
PredictFrameSubresources(canonicalized_url.GetWithEmptyPath(),
first_party_for_cookies);
site_for_cookies);
}

std::vector<GURL> Predictor::GetPredictedUrlListAtStartup(
Expand Down Expand Up @@ -769,7 +769,7 @@ void Predictor::WriteDnsPrefetchState(base::ListValue* startup_list,
}

void Predictor::PreconnectUrl(const GURL& url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
UrlInfo::ResolutionMotivation motivation,
bool allow_credentials,
int count) {
Expand All @@ -778,20 +778,20 @@ void Predictor::PreconnectUrl(const GURL& url,
DCHECK(url.is_valid());

if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
PreconnectUrlOnIOThread(url, first_party_for_cookies, motivation,
PreconnectUrlOnIOThread(url, site_for_cookies, motivation,
allow_credentials, count);
} else {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&Predictor::PreconnectUrlOnIOThread,
base::Unretained(this), url, first_party_for_cookies,
base::Unretained(this), url, site_for_cookies,
motivation, allow_credentials, count));
}
}

void Predictor::PreconnectUrlOnIOThread(
const GURL& original_url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
UrlInfo::ResolutionMotivation motivation,
bool allow_credentials,
int count) {
Expand All @@ -802,8 +802,7 @@ void Predictor::PreconnectUrlOnIOThread(
// for the URLRequestContextGetter. The predictor tests should be fixed to
// allow for this, as they currently expect a callback with no getter.
if (observer_) {
observer_->OnPreconnectUrl(
url, first_party_for_cookies, motivation, count);
observer_->OnPreconnectUrl(url, site_for_cookies, motivation, count);
}

net::URLRequestContextGetter* getter = url_request_context_getter_.get();
Expand Down Expand Up @@ -833,12 +832,12 @@ void Predictor::PreconnectUrlOnIOThread(
}
UMA_HISTOGRAM_ENUMERATION("Net.PreconnectMotivation", motivation,
UrlInfo::MAX_MOTIVATED);
content::PreconnectUrl(getter, url, first_party_for_cookies, count,
content::PreconnectUrl(getter, url, site_for_cookies, count,
allow_credentials, request_motivation);
}

void Predictor::PredictFrameSubresources(const GURL& url,
const GURL& first_party_for_cookies) {
const GURL& site_for_cookies) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!PredictorEnabled())
Expand All @@ -849,12 +848,12 @@ void Predictor::PredictFrameSubresources(const GURL& url,
// Add one pass through the message loop to allow current navigation to
// proceed.
if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
PrepareFrameSubresources(url, first_party_for_cookies);
PrepareFrameSubresources(url, site_for_cookies);
} else {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&Predictor::PrepareFrameSubresources,
base::Unretained(this), url, first_party_for_cookies));
base::Unretained(this), url, site_for_cookies));
}
}

Expand Down Expand Up @@ -886,7 +885,7 @@ enum SubresourceValue {
};

void Predictor::PrepareFrameSubresources(const GURL& original_url,
const GURL& first_party_for_cookies) {
const GURL& site_for_cookies) {
// Apply HSTS redirect early so it is taken into account when looking up
// subresources.
GURL url = GetHSTSRedirectOnIOThread(original_url);
Expand All @@ -903,7 +902,7 @@ void Predictor::PrepareFrameSubresources(const GURL& original_url,
// size of the list with all the "Leaf" nodes in the tree (nodes that don't
// load any subresources). If we learn about this resource, we will instead
// provide a more carefully estimated preconnection count.
PreconnectUrlOnIOThread(url, first_party_for_cookies,
PreconnectUrlOnIOThread(url, site_for_cookies,
UrlInfo::SELF_REFERAL_MOTIVATED,
kAllowCredentialsOnPreconnectByDefault, 2);
return;
Expand All @@ -927,8 +926,7 @@ void Predictor::PrepareFrameSubresources(const GURL& original_url,
int count = static_cast<int>(std::ceil(connection_expectation));
if (url.host_piece() == future_url->first.host_piece())
++count;
PreconnectUrlOnIOThread(future_url->first, first_party_for_cookies,
motivation,
PreconnectUrlOnIOThread(future_url->first, site_for_cookies, motivation,
kAllowCredentialsOnPreconnectByDefault, count);
} else if (connection_expectation > kDNSPreresolutionWorthyExpectedValue) {
evalution = PRERESOLUTION;
Expand Down
14 changes: 6 additions & 8 deletions chrome/browser/net/predictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PredictorObserver {
virtual ~PredictorObserver() {}

virtual void OnPreconnectUrl(const GURL& original_url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
UrlInfo::ResolutionMotivation motivation,
int count) {}
virtual void OnLearnFromNavigation(const GURL& referring_url,
Expand Down Expand Up @@ -150,7 +150,7 @@ class Predictor {

// Preconnect a URL and all of its subresource domains.
void PreconnectUrlAndSubresources(const GURL& url,
const GURL& first_party_for_cookies);
const GURL& site_for_cookies);

static std::vector<GURL> GetPredictedUrlListAtStartup(
PrefService* user_prefs);
Expand Down Expand Up @@ -247,13 +247,13 @@ class Predictor {
// May be called from either the IO or UI thread and will PostTask
// to the IO thread if necessary.
void PreconnectUrl(const GURL& url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
UrlInfo::ResolutionMotivation motivation,
bool allow_credentials,
int count);

void PreconnectUrlOnIOThread(const GURL& url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
UrlInfo::ResolutionMotivation motivation,
bool allow_credentials,
int count);
Expand All @@ -267,8 +267,7 @@ class Predictor {
// more-embedded resources on a page). This method will actually post a task
// to do the actual work, so as not to jump ahead of the frame navigation that
// instigated this activity.
void PredictFrameSubresources(const GURL& url,
const GURL& first_party_for_cookies);
void PredictFrameSubresources(const GURL& url, const GURL& site_for_cookies);

// Put URL in canonical form, including a scheme, host, and port.
// Returns GURL::EmptyGURL() if the scheme is not http/https or if the url
Expand Down Expand Up @@ -372,8 +371,7 @@ class Predictor {
// Perform actual resolution or preconnection to subresources now. This is
// an internal worker method that is reached via a post task from
// PredictFrameSubresources().
void PrepareFrameSubresources(const GURL& url,
const GURL& first_party_for_cookies);
void PrepareFrameSubresources(const GURL& url, const GURL& site_for_cookies);

// Access method for use by async lookup request to pass resolution result.
void OnLookupFinished(const GURL& url, int result);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/net/predictor_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class CrossSitePredictorObserver

void OnPreconnectUrl(
const GURL& original_url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
chrome_browser_net::UrlInfo::ResolutionMotivation motivation,
int count) override {
base::AutoLock lock(lock_);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/net/predictor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class TestPredictorObserver : public PredictorObserver {
public:
// PredictorObserver implementation:
void OnPreconnectUrl(const GURL& url,
const GURL& first_party_for_cookies,
const GURL& site_for_cookies,
UrlInfo::ResolutionMotivation motivation,
int count) override {
preconnected_urls_.push_back(url);
Expand Down
Loading

0 comments on commit b85da8e

Please sign in to comment.