0
Commit Graph

21 Commits

Author SHA1 Message Date
Arthur Sonzogni
c686e8f4fd Rename {absl => std}::optional in //content/
Automated patch, intended to be effectively a no-op.

Context:
https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer

As of https://crrev.com/1204351, absl::optional is now a type alias for
std::optional. We should migrate toward it.

Script:
```
function replace {
  echo "Replacing $1 by $2"
  git grep -l "$1" \
    | cut -f1 -d: \
    | grep \
      -e "^content" \
    | sort \
    | uniq \
    | grep \
      -e "\.h" \
      -e "\.cc" \
      -e "\.mm" \
      -e "\.py" \
    | xargs sed -i "s/$1/$2/g"
}
replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place" "std::in_place"
replace "absl::in_place_t" "std::in_place_t"
replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>"
git cl format
```

# Skipping unrelated "check_network_annotation" errors.
NOTRY=True

Bug: chromium:1500249
Change-Id: Icfd31a71d8faf63a2e8d5401127e7ee74cc1c413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185537
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1245739}
2024-01-11 08:36:37 +00:00
W. James MacLean
1cce29da97 Update BaseUrlInheritanceIframeTest to work with OOPSIFs enabled.
BaseUrlInheritanceIframeTest is  parameterized to run both with the
new behavior, and the legacy behavior.

Once enable-isolated-sandboxed-iframes is enabled by default it
will force on the new base url behavior with it, which will
cause the legacy-behavior version of this test to fail.

This CL updates the test so the legacy version of the test forces
off enable-isolated-sandboxed-iframes so it can run the legacy
behavior properly.

Bug: 510122
Change-Id: I1d3718bcbba8aaf39343dc5b312560ac618e00b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5008254
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: W. James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1220888}
2023-11-07 14:14:32 +00:00
Kevin McNee
433daf2461 Simplify some NavigationEntryRestoreContextImpl usage
Within content, other than this class' factory function, callers don't
need to dynamically allocate a NavigationEntryRestoreContextImpl. The
callers can have them on the stack.

We also move some of NavigationEntryRestoreContextImpl's implementation
out of the header file, remove an unused operator, and avoid a redundant
lookup.

Bug: 1211683
Change-Id: I6f90dcfc50ba50acf5fa9467015f6335d20d1ab5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4939480
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1217844}
2023-10-31 20:15:59 +00:00
Jun Kokatsu
dbf77c49ab Deprecate CSPEE same-origin blanket enforcement
Remove same-origin blanket enforcement from CSPEE. See intent thread[1]
for more details.

[1] https://groups.google.com/a/chromium.org/g/blink-dev/c/VtKJHVgQRzE/m/bTZeRD77AAAJ

Bug: 1263288
Change-Id: I18d46b33ea52fbe60dc000e6d9ed2623d01f9bb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4850620
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Jun Kokatsu <jkokatsu@google.com>
Cr-Commit-Position: refs/heads/main@{#1209684}
2023-10-13 21:30:35 +00:00
W. James MacLean
0f1eb51537 Remove url change for about:srcdoc document.write()
This CL removes the ability for either srcdoc iframes
to change another frame's url via document.write. That ability has
been shown to allow a mainframe to acquire a srcdoc url, which
causes problems in the codebase.

This CL also adds a test to make sure the document.write doesn't
give a srcdoc url to a mainframe, and modifies an existing test to
cover the about:blank url-writing case.

Bug: 1478463
Change-Id: I85895c1e16df6734c9e351ea798fd1800e0a4df7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4856149
Reviewed-by: Dominic Farolino <dom@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1205943}
2023-10-05 18:25:05 +00:00
W. James MacLean
5b18db7290 Add test confirming PageState base urls aren't empty.
ExplodedFrameState::initiator_base_url_string is absl::optional, when
the feature is off, and should never be empty when it's enabled, so
there's no need to store empty GURLs in session state. This CL
1) adds a comment in RecursivelyGenerateFrameState() to clarify that
   we're not storing an empty GURL, and
2) adds a test to confirm that we don't save PageState with an empty
   GURL in place of a nullopt.

Bug: 1356658
Change-Id: Idf8ee754dd51985f0a25ece6eb480b0ee71b9463
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4455088
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1150738}
2023-05-30 19:04:30 +00:00
W. James MacLean
f622f5c6af Replace FillNavigationParamsRequest base URL DwoC with a CHECK.
Issue 1430232 appears to have been resolved by the CL
https://chromium-review.googlesource.com/c/chromium/src/+/4418026, so
this CL removes the diagnostic DumpWithoutCrashing calls added to
investigate that issue, and replaces it with the original CHECK now that it should be safe.

Bug: 1430232
Change-Id: Ieb072f39205aff7c43a22a8536574b5df658624e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4455170
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1139889}
2023-05-05 01:29:17 +00:00
W. James MacLean
cce845ddc7 Add inherited base URL support for about:blank.
Implement about:blank support when the feature
NewBaseUrlInheritanceBehavior is enabled.

This CL changes Chromium behavior so that about:blank frames,
be they popups or iframes, inherit their base url from the
initiator. Prior to this CL, popups didn't inherit base url
at all, and iframes inherited from the parent frame (if it's
same-origin), so the new behavior means about:blank will
inherit base url more often and more accurately (e.g. it might
inherit the base url from a sibling initiator frame instead of
a parent).

A followup CL will prevent the base URL from being inherited in sandboxed cases, matching Chrome's current default behavior.

Note that use of the initiator's base url here is slightly
different than that of FireFox and Safari, both of which use
the opener's base url instead.

The main change here is in render_frame_impl.cc's
FillNavigationParamsRequest, to expand the cases that send
initiator_base_url to include about:blank. However, to handle
the initial empty document case this CL plumbs a base url
value to LocalFrame::init() as well.

Also, this CL renames instances of fallback_srcdoc_base_url
in blink code to be simply fallback_base_url.

Change-Id: I7682b0b1aafbe9d0cd835803d2cbfa0b594b41be
Bug: 1356658, 751329
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4035455
Reviewed-by: Charlie Reis <creis@chromium.org>
Auto-Submit: James Maclean <wjmaclean@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1121490}
2023-03-24 00:55:24 +00:00
Rakina Zata Amni
364eb5dd32 Make various content_browsertests expect same-SiteInstance RenderFrameHost etc swap
With RenderDocument, cross-document navigations will use new
RenderFrameHosts (and RenderViewHosts, RenderWidgetHosts, etc for
main frame navigations). This CL updates some tests in
content_browsertests that didn't expect those changes.

Bug: 936696
Change-Id: Ia43799aaae9f50b7ff9c3221982b622d76698d14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4349554
Reviewed-by: James Maclean <wjmaclean@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Auto-Submit: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1120489}
2023-03-22 13:19:00 +00:00
Scott Violet
9986199c3c content: makes content browsertests subclass test ContentBrowserClient
Some times tests need to replace the ContentBrowserClient. This
is often done by subclassing ContentBrowserClient and replacing
ContentBrowserClient during test execution. This is problematic
as certain things (such as RegisterBrowserInterfaceBindersForFrame)
are provided by ShellContentBrowserClient, and if not present
result in bad behavior (killing the renderer), which leads to flake.

To fix this problem this patch does the following:
. Moves ContentBrowserTestShellContentBrowserClient to its own
  header and renames it to
  ContentBrowserTestContentBrowserClient.
. makes SetBrowserClientForTesting() CHECK in content_browsertests.
. changes all browsertests to use
  ContentBrowserTestContentBrowserClient.
. Changes ShellContentBrowserClient so that it sets the browser
  client when called the second time (effectively what
  SetBrowserClientForTesting() does).

Bug: 1406282

Change-Id: Ieaa7cfa09a53e9618b963d6cc4b931226d2c799e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4222392
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1102490}
2023-02-08 01:20:12 +00:00
W. James MacLean
78e2f876c5 Hook up about:srcdoc to use initiator_base_url plumbing.
The changes in this CL are guarded behind the NewBaseUrlInheritanceBehavior feature.

This CL (mostly) re-implements
https://chromium-review.googlesource.com/c/chromium/src/+/3792049
using the initiator_base_url framework landed in
https://chromium-review.googlesource.com/c/chromium/src/+/4026883.
One notable change is that if a srcdoc reloads itself using
location.reload(), this CL uses the base url of the srcdoc
frame instead of the parent's, since the srcdoc frame is itself the
initiator of the reload.

This CL also removes the machinery used to track each frame's
baseurl, introduced in CL 3792049. Instead, the initiator base url
for about:blank and about:srcdoc frames is stored on their
RenderFrameHostImpls in case it's needed later.

Change-Id: Ia774332d08d94f85d8c570ab03ad311d8018456d
Bug: 1356658, 751329
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4032246
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096262}
2023-01-24 17:59:38 +00:00
W. James MacLean
d51c419cd9 Add helper function GetFrameBaseUrl to tests, and remove GetBaseUrl calls.
Refactor to simplify reviews on
https://chromium-review.googlesource.com/c/chromium/src/+/4032246.
Also, remove calls to RenderFrameHostImpl::GetBaseUrl() as this
will be removed shortly.

Bug: 1356658
Change-Id: I7d1eb6238962879054b8179275d3305812def5de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4163479
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1092601}
2023-01-13 20:59:53 +00:00
W. James MacLean
23e90a11b9 Plumbing initiator base url into NavigationRequest.
This is the first of a series of CLs to implement using the base
url of the initiator for about:srcdoc and about:blank frames.
See further details at
https://docs.google.com/document/d/1e7T1YR5aGDg-eGHKDNnKUWcz1Dr38t_O0-XJqsMeZcE/edit?usp=sharing&resourcekey=0-qCAYJPulnTdo9hV_dPCdhw

This CL implements snapshotting the initiator's base url (for frame
load requests) at the same time the initiator origin is captured,
and then plumbs it back to the start of NavigationRequest via
CommonParams. The plumbing in this CL is not guaranteed to be
exhaustive, so there may be additional plumbing added in the follow-on
CLs.

This CL has no behavioural changes.

Change-Id: I37759aba16d47e12300b6f11f3f6374ad3362261
Bug: 1356658, 751329
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4026883
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1085791}
2022-12-21 04:38:21 +00:00
W. James MacLean
3bce11ffb3 Add enterprise policy to disable feature NewBaseUrlInheritanceBehavior.
This CL adds an enterprise policy that can be used as a kill-switch
while the new base url inheritance behavior is rolled out.

Bug: 1356658
Change-Id: Iff1acd47bf1a47384924cf66e514368ff6315491
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4067503
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Julian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1079428}
2022-12-05 21:41:43 +00:00
W. James MacLean
7d286973e0 Move kIsolateSandboxedIframes flag to blink.
This CL moves (temporarily) the kIsolateSandboxedIframes feature into
Blink. This is necessary to facilitate linking its use to a new feature,
tentatively named kNewBaseUrlInheritanceBehavior, to be introduced to
Blink in
https://chromium-review.googlesource.com/c/chromium/src/+/3938111.

We want to ensure that use of kIsolateSandboxedIframes will also force
enabling of kNewBaseUrlInheritanceBehavior, but at present there is no
mechanism in base::Feature to enforce this type of linking between
features. Instead, the follow-on CL will introduce a helper function
that looks at the value of both flags whenever a decision based on
kNewBaseUrlInheritanceBehavior needs to be made.

It is hoped that kNewBaseUrlInheritanceBehavior will be relatively
short-lived, and when it is removed this CL will be reverted in order
to move kIsolateSandboxedIframes back to content/.

Bug: 1356658
Change-Id: Icb063e65eb9cdec56b486a7a679117f4a1fcbcb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3956476
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1059406}
2022-10-14 19:11:56 +00:00
W. James MacLean
b7d6092680 Plumb parent's BaseURL value to child renderer for srcdoc iframe.
This CL modifies the plumbing that sends 'srcdoc' attribute values
from the parent frame's renderer process to the child frame's
renderer process so that it also sends the parent's
Document::BaseURL() and makes it available in the child document's
FallbackURL(). The parent frames's RenderFrameHost maintains an
accurate view of each frame's base URL at all times, and this is
sent to a child frame if it navigates to srcdoc.

This is necessary so that srcdoc iframes that are sandboxed, which
put the child in a different renderer process, still have access to
the same BaseURL() as if it was in the same renderer process.

These changes presently only take effect when the
IsolateSandboxedIframes is enabled, in which case the base URL
behavior changes to proper snapshotting per Issue 1356658 (whether
it's out of process or not).

Bug: 1339824, 1343065, 1356658
Change-Id: I0d1d9ef05121bd603a3f60bcdc7181f65a37f77b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3792049
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1055296}
2022-10-05 15:23:26 +00:00
W. James MacLean
e769366d89 Fix site-origin mismatch for sandboxed srcdoc iframes in per-origin mode.
In per-origin mode for process-isolated sandboxed iframes, at present
a sandboxed srcdoc iframe will attempt to clone its parent's
SiteInstance, with the only difference being that the sandbox flag is
set. But the parent's SiteInstance will be using a site-based site-url,
and this will cause the child to attempt to load itself in a process
with a site-based, and not origin-based, site_url.

This CL revises the cloning process to take into account the parent's
origin (which the srcdoc frame will use), and creating a consistent
SiteInstance by recreating the SiteInfo via SiteInfo::Create. This will
use the same pathways for creation of the SiteInfo as if it had been
created for a navigation.

Bug: 1345491
Change-Id: I2870d01f3e916f28784b3d5adb749d9c58edacc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3854030
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047598}
2022-09-15 18:58:58 +00:00
Avi Drissman
4e1b7bc33d Update copyright headers in content/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I8c0f009d16350271f07d8e5e561085822cc9dd27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895935
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047456}
2022-09-15 14:03:50 +00:00
W. James MacLean
37dd4aade2 Add per-document mode to kIsolateSandboxedIframes
This CL adds a "per-document" isolation grouping for isolation of
sandboxed iframes using the kIsolatedSandboxedIframes flag. This CL
parameterizes the flag to add "per-document", and when this new
parameter is present it creates a unique document identifier on every
SiteInfo associated with a sandboxed iframe in order to force each
document into its own process. This grouping is expected to be the most
granular option for isolated sandboxed iframes.

Bug: 510122
Change-Id: I217bf5c57f8e9badaa84c0fab9261c432e766fcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3727308
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1029273}
2022-07-28 15:40:51 +00:00
W. James MacLean
122cdadf9d Enable OOPSIFs on Android when the site requires a dedicated process.
This CL enables process-isolation for sandboxed iframes on Android.
Since not all sites get site isolation on Android, only isolate OOPSIFs
if they would not have ended up in a DefaultSiteInstance.

Bug: 510122
Change-Id: I8244b53d6a35a306685f0ef9c4c50bb00660a5b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3730126
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1027917}
2022-07-25 20:03:15 +00:00
W. James MacLean
0ac79fd1cd Split OOPSIF content_browsertests into separate file.
site_per_process_browsertest.cc is large and unweildy. Improve this
situation (slightly) by splitting out the sandboxed iframe (OOPSIF)
browsertests into a separate file.

Bug: 510122
Change-Id: I8c912dcefce0a81b84b10a2ea514fa804523dd5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3778241
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026443}
2022-07-20 21:30:48 +00:00