Skip to content

Commit

Permalink
Shared Storage: We reject promises when Shared Storage is disabled.
Browse files Browse the repository at this point in the history
We hook up the permission check method
`privacy_sandbox_settings::IsSharedStorageAllowed()`. This involves
changing the mojo interface for `SharedStorageDocumentService`.

We also add some test utils in content/public/test/ to make it possible
to test at the chrome/ layer, and export
`SharedStorageDocumentServiceImpl` to make it visible to these test
utils in component builds.

Bug: 1325020,1218540
Change-Id: Iaa2f1e71c2e6fc99764212c6a9e9299c218a6062
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3612224
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Cammie Smith Barnes <cammie@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1002891}
  • Loading branch information
pythagoraskitty authored and Chromium LUCI CQ committed May 12, 2022
1 parent ab8fbd8 commit 3921f06
Show file tree
Hide file tree
Showing 18 changed files with 1,027 additions and 40 deletions.
13 changes: 13 additions & 0 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2898,6 +2898,19 @@ bool ChromeContentBrowserClient::IsConversionMeasurementOperationAllowed(
}
}

bool ChromeContentBrowserClient::IsSharedStorageAllowed(
content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,
const url::Origin& accessing_origin) {
Profile* profile = Profile::FromBrowserContext(browser_context);
auto* privacy_sandbox_settings =
PrivacySandboxSettingsFactory::GetForProfile(profile);
DCHECK(privacy_sandbox_settings);

return privacy_sandbox_settings->IsSharedStorageAllowed(top_frame_origin,
accessing_origin);
}

#if BUILDFLAG(IS_CHROMEOS)
void ChromeContentBrowserClient::OnTrustAnchorUsed(
content::BrowserContext* browser_context) {
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/chrome_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const url::Origin* impression_origin,
const url::Origin* conversion_origin,
const url::Origin* reporting_origin) override;
bool IsSharedStorageAllowed(content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,
const url::Origin& accessing_origin) override;
#if BUILDFLAG(IS_CHROMEOS)
void OnTrustAnchorUsed(content::BrowserContext* browser_context) override;
#endif
Expand Down

0 comments on commit 3921f06

Please sign in to comment.