Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3777,6 +3777,7 @@ source_set("browser") {
"interest_group/*",
"private_aggregation/*",
"aggregation_service/*",
"fenced_frame/*",
"devtools/auction_worklet_devtools_agent_host.*",
])
sources = []
Expand Down
5 changes: 4 additions & 1 deletion content/browser/client_hints/client_hints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "content/browser/devtools/devtools_instrumentation.h"
#include "content/browser/preloading/prerender/prerender_host.h"
#include "content/browser/renderer_host/frame_tree.h"
Expand Down Expand Up @@ -547,12 +548,14 @@ struct ClientHintsExtendedData {
// fenced frame properties from the urn iframe because it does a bottom
// up traversal.
// See crbug.com/1470634.
base::span<const network::mojom::PermissionsPolicyFeature> permissions;
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
const std::optional<FencedFrameProperties>& fenced_frame_properties =
frame_tree_node->GetFencedFrameProperties();
base::span<const network::mojom::PermissionsPolicyFeature> permissions;
if (fenced_frame_properties) {
permissions = fenced_frame_properties->effective_enabled_permissions();
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
permissions_policy =
network::PermissionsPolicy::CreateFixedForFencedFrame(
resource_origin, /*header_policy=*/{}, permissions);
Expand Down
5 changes: 5 additions & 0 deletions content/browser/renderer_host/ancestor_throttle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <algorithm>

#include "base/feature_list.h"
#include "build/buildflag.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_split.h"
Expand Down Expand Up @@ -59,6 +60,7 @@ bool HeadersContainFrameAncestorsCSP(
RenderFrameHostImpl* GetParentForFrameAncestors(NavigationRequest* request,
RenderFrameHostImpl* frame) {
bool allows_information_inflow = false;
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
if (base::FeatureList::IsEnabled(
blink::features::kFencedFramesLocalUnpartitionedDataAccess)) {
if (request) {
Expand All @@ -76,6 +78,9 @@ RenderFrameHostImpl* GetParentForFrameAncestors(NavigationRequest* request,
} else {
allows_information_inflow = !frame->IsFencedFrameRoot();
}
#else
allows_information_inflow = !frame->IsFencedFrameRoot();
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

if (!allows_information_inflow && request &&
base::FeatureList::IsEnabled(
Expand Down
5 changes: 5 additions & 0 deletions content/browser/renderer_host/frame_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "base/trace_event/optional_trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "base/types/cxx23_from_range.h"
#include "build/buildflag.h"
#include "base/unguessable_token.h"
#include "content/browser/renderer_host/batched_proxy_ipc_sender.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
Expand Down Expand Up @@ -433,7 +434,9 @@ FrameTreeNode* FrameTree::AddFrame(
document_token, devtools_frame_token, frame_policy, frame_name,
frame_unique_name);

#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
added_node->SetFencedFramePropertiesIfNeeded();
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

if (browser_interface_broker_receiver.is_valid()) {
added_node->current_frame_host()->BindBrowserInterfaceBrokerReceiver(
Expand Down Expand Up @@ -949,7 +952,9 @@ void FrameTree::Init(SiteInstanceImpl* main_frame_site_instance,
root_.render_manager()->InitRoot(main_frame_site_instance,
renderer_initiated_creation, frame_policy,
main_frame_name, devtools_frame_token);
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
root_.SetFencedFramePropertiesIfNeeded();
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

// The initial empty document should inherit the origin (the origin may
// change after the first commit) and other state (such as the
Expand Down
14 changes: 14 additions & 0 deletions content/browser/renderer_host/frame_tree_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ bool FrameTreeNode::IsInFencedFrameTree() const {
return fenced_frame_status_ != FencedFrameStatus::kNotNestedInFencedFrame;
}

#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
FrameTreeNode* FrameTreeNode::GetClosestAncestorWithFencedFrameProperties() {
FrameTreeNode* node = this;
while (node) {
Expand Down Expand Up @@ -1073,8 +1074,10 @@ size_t FrameTreeNode::GetFencedFrameDepth(

return depth;
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

std::optional<base::UnguessableToken> FrameTreeNode::GetFencedFrameNonce() {
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
// For partition nonce, all nested frame inside a fenced frame tree should
// operate on the partition nonce of the frame tree root.
auto& root_fenced_frame_properties = GetFencedFrameProperties(
Expand All @@ -1091,8 +1094,12 @@ std::optional<base::UnguessableToken> FrameTreeNode::GetFencedFrameNonce() {
CHECK(blink::features::IsAllowURNsInIframeEnabled());
CHECK(!IsInFencedFrameTree());
return std::nullopt;
#else
return std::nullopt;
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
}

#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
void FrameTreeNode::SetFencedFramePropertiesIfNeeded() {
if (!IsFencedFrameRoot()) {
return;
Expand All @@ -1102,9 +1109,11 @@ void FrameTreeNode::SetFencedFramePropertiesIfNeeded() {
// In the future, they will be set on the FrameTree instead.
fenced_frame_properties_ = FencedFrameProperties();
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

blink::FencedFrame::DeprecatedFencedFrameMode
FrameTreeNode::GetDeprecatedFencedFrameMode() {
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
if (!IsInFencedFrameTree()) {
return blink::FencedFrame::DeprecatedFencedFrameMode::kDefault;
}
Expand All @@ -1124,6 +1133,9 @@ FrameTreeNode::GetDeprecatedFencedFrameMode() {
}

return root_fenced_frame_properties->mode();
#else
return blink::FencedFrame::DeprecatedFencedFrameMode::kDefault;
#endif
}

bool FrameTreeNode::IsErrorPageIsolationEnabled() const {
Expand All @@ -1135,6 +1147,7 @@ void FrameTreeNode::SetSrcdocValue(const std::string& srcdoc_value) {
srcdoc_value_ = srcdoc_value;
}

#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
std::vector<const SharedStorageBudgetMetadata*>
FrameTreeNode::FindSharedStorageBudgetMetadata() {
std::vector<const SharedStorageBudgetMetadata*> result;
Expand Down Expand Up @@ -1170,6 +1183,7 @@ FrameTreeNode::GetEmbedderSharedStorageContextIfAllowed() {
}
return properties->embedder_shared_storage_context();
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

const scoped_refptr<BrowsingContextState>&
FrameTreeNode::GetBrowsingContextStateForSubframe() const {
Expand Down
11 changes: 11 additions & 0 deletions content/browser/renderer_host/frame_tree_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/observer_list.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/time/time.h"
#include "build/buildflag.h"
#include "content/browser/renderer_host/navigator.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_frame_host_manager.h"
Expand Down Expand Up @@ -538,6 +539,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
// this means setting a new fenced frame nonce. See comment on
// fenced_frame_nonce() for when it is set to a non-null value. Invoked
// by FrameTree::Init() or FrameTree::AddFrame().
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
void SetFencedFramePropertiesIfNeeded();

// Set the current FencedFrameProperties to have "opaque ads mode".
Expand All @@ -553,6 +555,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
->SetFencedFramePropertiesOpaqueAdsModeForTesting();
}
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

// Returns the mode attribute from the `FencedFrameProperties` if this frame
// is in a fenced frame tree, otherwise returns `kDefault`.
Expand Down Expand Up @@ -591,6 +594,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
void SetSrcdocValue(const std::string& srcdoc_value);
const std::string& srcdoc_value() const { return srcdoc_value_; }

#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
void set_fenced_frame_properties(
const std::optional<FencedFrameProperties>& fenced_frame_properties) {
// TODO(crbug.com/40202462): Reenable this DCHECK once ShadowDOM and
Expand All @@ -599,6 +603,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
// RenderFrameHostImpl::FencedFrameStatus::kFencedFrameRoot);
fenced_frame_properties_ = fenced_frame_properties;
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

// This function returns the fenced frame properties associated with the given
// source.
Expand All @@ -612,6 +617,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
// iframe.
// - `kFrameTreeRoot`: returns the fenced frame properties from the fenced
// frame.
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
// Clients should decide which one to use depending on how the application of
// the fenced frame properties interact with urn iframes.
// TODO(crbug.com/40060657): Once navigation support for urn::uuid in iframes
Expand All @@ -628,6 +634,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
bool HasFencedFrameProperties() const {
return fenced_frame_properties_.has_value();
}
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

// Returns the number of fenced frame boundaries above this frame. The
// outermost main frame's frame tree has fenced frame depth 0, a topmost
Expand All @@ -640,6 +647,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
// originates from shared storage only (i.e. not from FLEDGE).
// TODO(crbug.com/40233168): Remove this check once we put permissions inside
// FencedFrameConfig.
#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
size_t GetFencedFrameDepth(size_t& shared_storage_fenced_frame_root_count);

// Traverse up from this node. Return all valid
Expand All @@ -659,6 +667,7 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
// frame within the config's fenced frame tree (or a same-origin descendant of
// a URN iframe).
std::optional<std::u16string> GetEmbedderSharedStorageContextIfAllowed();
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

// Accessor to BrowsingContextState for subframes only. Only main frame
// navigations can change BrowsingInstances and BrowsingContextStates,
Expand Down Expand Up @@ -953,11 +962,13 @@ class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
const FencedFrameStatus fenced_frame_status_ =
FencedFrameStatus::kNotNestedInFencedFrame;

#if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)
// If this is a fenced frame resulting from a urn:uuid navigation, this
// contains all the metadata specifying the resulting context.
// TODO(crbug.com/40202462): Move this into the FrameTree once ShadowDOM
// and urn iframes are gone.
std::optional<FencedFrameProperties> fenced_frame_properties_;
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

// The tracker of the task that restarts the BFCache navigation. It might be
// used to cancel the task.
Expand Down
Loading
Loading