-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9095 from /issues/15906-cookieoptions-migration
Unify ephemeral storage trigger logic to use net::CookieOptions.
- Loading branch information
Showing
30 changed files
with
947 additions
and
171 deletions.
There are no files selected for viewing
286 changes: 236 additions & 50 deletions
286
browser/ephemeral_storage/ephemeral_storage_browsertest.cc
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include_rules = [ | ||
"+../../../../../components/content_settings/browser", | ||
"+components/content_settings/browser", | ||
"+components/content_settings/common", | ||
] |
23 changes: 23 additions & 0 deletions
23
chromium_src/components/content_settings/browser/content_settings_manager_impl.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "components/content_settings/browser/content_settings_manager_impl.h" | ||
|
||
#include "../../../../../components/content_settings/browser/content_settings_manager_impl.cc" | ||
|
||
namespace content_settings { | ||
|
||
void ContentSettingsManagerImpl::AllowEphemeralStorageAccess( | ||
int32_t render_frame_id, | ||
StorageType storage_type, | ||
const url::Origin& origin, | ||
const GURL& site_for_cookies, | ||
const url::Origin& top_frame_origin, | ||
base::OnceCallback<void(bool)> callback) { | ||
std::move(callback).Run(cookie_settings_->ShouldUseEphemeralStorage( | ||
origin.GetURL(), site_for_cookies, top_frame_origin)); | ||
} | ||
|
||
} // namespace content_settings |
24 changes: 24 additions & 0 deletions
24
chromium_src/components/content_settings/browser/content_settings_manager_impl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Copyright 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_CONTENT_SETTINGS_BROWSER_CONTENT_SETTINGS_MANAGER_IMPL_H_ | ||
#define BRAVE_CHROMIUM_SRC_COMPONENTS_CONTENT_SETTINGS_BROWSER_CONTENT_SETTINGS_MANAGER_IMPL_H_ | ||
|
||
#include "components/content_settings/common/content_settings_manager.mojom.h" | ||
|
||
#define OnContentBlocked \ | ||
NotUsed() {} \ | ||
void AllowEphemeralStorageAccess( \ | ||
int32_t render_frame_id, StorageType storage_type, \ | ||
const url::Origin& origin, const GURL& site_for_cookies, \ | ||
const url::Origin& top_frame_origin, \ | ||
base::OnceCallback<void(bool)> callback) override; \ | ||
void OnContentBlocked | ||
|
||
#include "../../../../../components/content_settings/browser/content_settings_manager_impl.h" | ||
|
||
#undef OnContentBlocked | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_CONTENT_SETTINGS_BROWSER_CONTENT_SETTINGS_MANAGER_IMPL_H_ |
15 changes: 15 additions & 0 deletions
15
chromium_src/components/content_settings/common/content_settings_manager.mojom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module content_settings.mojom; | ||
|
||
import "url/mojom/origin.mojom"; | ||
import "url/mojom/url.mojom"; | ||
|
||
[BraveExtend] | ||
interface ContentSettingsManager { | ||
[Sync] | ||
AllowEphemeralStorageAccess( | ||
int32 render_frame_id, | ||
StorageType storage_type, | ||
url.mojom.Origin origin, | ||
url.mojom.Url site_for_cookies, | ||
url.mojom.Origin top_frame_origin) => (bool ephemeral_storage_allowed); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "net/cookies/cookie_access_delegate.h" | ||
|
||
#include "base/notreached.h" | ||
|
||
#include "../../../../net/cookies/cookie_access_delegate.cc" | ||
|
||
namespace net { | ||
|
||
bool CookieAccessDelegate::NotUsed() const { | ||
return false; | ||
} | ||
|
||
bool CookieAccessDelegate::ShouldUseEphemeralStorage( | ||
const GURL& url, | ||
const net::SiteForCookies& site_for_cookies, | ||
const base::Optional<url::Origin>& top_frame_origin) const { | ||
NOTREACHED() << "Should be overridden"; | ||
return false; | ||
} | ||
|
||
} // namespace net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_NET_COOKIES_COOKIE_ACCESS_DELEGATE_H_ | ||
#define BRAVE_CHROMIUM_SRC_NET_COOKIES_COOKIE_ACCESS_DELEGATE_H_ | ||
|
||
#include "base/optional.h" | ||
#include "net/cookies/site_for_cookies.h" | ||
#include "url/gurl.h" | ||
#include "url/origin.h" | ||
|
||
#define ShouldTreatUrlAsTrustworthy \ | ||
NotUsed() const; \ | ||
virtual bool ShouldUseEphemeralStorage( \ | ||
const GURL& url, const net::SiteForCookies& site_for_cookies, \ | ||
const base::Optional<url::Origin>& top_frame_origin) const; \ | ||
virtual bool ShouldTreatUrlAsTrustworthy | ||
|
||
#include "../../../../net/cookies/cookie_access_delegate.h" | ||
|
||
#undef ShouldTreatUrlAsTrustworthy | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_NET_COOKIES_COOKIE_ACCESS_DELEGATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "net/cookies/cookie_options.h" | ||
|
||
#include "net/cookies/cookie_access_delegate.h" | ||
|
||
#define CookieOptions CookieOptions_ChromiumImpl | ||
#include "../../../../net/cookies/cookie_options.cc" | ||
#undef CookieOptions | ||
|
||
namespace net { | ||
|
||
CookieOptions::CookieOptions() = default; | ||
CookieOptions::CookieOptions(const CookieOptions&) = default; | ||
CookieOptions::CookieOptions(CookieOptions&&) = default; | ||
CookieOptions::~CookieOptions() = default; | ||
CookieOptions& CookieOptions::operator=(const CookieOptions&) = default; | ||
CookieOptions& CookieOptions::operator=(CookieOptions&&) = default; | ||
|
||
CookieOptions::CookieOptions(const CookieOptions_ChromiumImpl& rhs) | ||
: CookieOptions_ChromiumImpl(rhs) {} | ||
CookieOptions::CookieOptions(CookieOptions_ChromiumImpl&& rhs) | ||
: CookieOptions_ChromiumImpl(std::move(rhs)) {} | ||
|
||
void FillEphemeralStorageParams( | ||
const GURL& url, | ||
const SiteForCookies& site_for_cookies, | ||
const base::Optional<url::Origin>& top_frame_origin, | ||
const CookieAccessDelegate* cookie_access_delegate, | ||
CookieOptions* cookie_options) { | ||
DCHECK(cookie_options); | ||
if (!cookie_access_delegate) { | ||
return; | ||
} | ||
cookie_options->set_should_use_ephemeral_storage( | ||
cookie_access_delegate->ShouldUseEphemeralStorage(url, site_for_cookies, | ||
top_frame_origin)); | ||
if (cookie_options->should_use_ephemeral_storage()) { | ||
cookie_options->set_site_for_cookies(site_for_cookies); | ||
cookie_options->set_top_frame_origin(top_frame_origin); | ||
} | ||
} | ||
|
||
} // namespace net |
Oops, something went wrong.