0
Commit Graph

77 Commits

Author SHA1 Message Date
Rebekah Potter
6ea95f20df WebUI Mojo bindings: Remove unnecessary use_typescript_sources=true
This is now the default for WebUI bindings, so setting true is
unnecessary. In this CL updating all uses within content/, docs/ and
ui/webui/examples/

Bug: 1002798
Change-Id: If2ab305c5b56524e5f2f4b4313c58ea664f9ad4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5009906
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1222665}
2023-11-10 01:03:57 +00:00
Charlie Reis
10e4ad9244 Add BrowsingInstance ID for each frame to chrome://process-internals.
This makes it easier to see which navigations cause BrowsingInstance
swaps in practice.

Bug: 850087
Change-Id: I0d0ba3d03405681a5400d33a819c926ca270feb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4962879
Commit-Queue: Charlie Reis <creis@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1214557}
2023-10-25 00:40:49 +00:00
Andy Phan
99cef87a69 [OOPIF PDF] Add PDF status to chrome://process-internals
Add PDF status to chrome://process-internals to indicate if the
SiteInstance is for a PDF or not.

This helps clarify why the same-origin frame for the PDF content has a
different SiteInstance and process.

Bug: 1445746
Change-Id: I7f984d41e428862ea8ed592c5ec113acd922b3ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4792304
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1186130}
2023-08-21 23:23:49 +00:00
Sharon Yang
1f2754c363 Add SiteInstanceGroup ID to chrome://process-internals
This will make it easier to understand which SiteInstances share the same SiteInstanceGroup, as that becomes possible.

Bug: 1195535, 850087
Change-Id: Ia2f1cdd5d9cb63440efeb5ac4deddbc2ff18329a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4569129
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1154430}
2023-06-07 15:14:33 +00:00
dpapad
5c8201b1dc Auto-generate grd file for content/browser/resources/process/
This is in preparation of migrating to build_webui().

Bug: 1132403
Change-Id: I4eaeea384aed0c2d4802affff71dbaccb6510317
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4471951
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Cole Horvitz <colehorvitz@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1135614}
2023-04-25 23:05:39 +00:00
Charlie Reis
b2cf083c30 Add process count and limit to chrome://process-internals.
Introduces a RenderProcessHostImpl::GetProcessCount to make it possible
to show both the actual process count and the count used for the limit.

Also moves Site Isolation info to another tab on the page.

Bug: 850087
Change-Id: I43d3f0d622b94f429df576147df672109282cefd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292643
Commit-Queue: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1111335}
2023-03-01 01:57:28 +00:00
Rebekah Potter
6f1e93b542 Process internals: Migrate to TypeScript mojo bindings
Also fixing a minor issue in the TS enum template, where enums with
parents were named without including the parent's name in the type
(this type of enum was not used by any prior WebUI bindings).

Bug: 1002798
Change-Id: Idb8cfc394f6c599309219668622a4f19259660ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4195379
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1097627}
2023-01-26 22:09:14 +00:00
Avi Drissman
adac219925 Update header includes for /base/functional in /content
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: 1364441
Change-Id: I32ec425b9c0e52ec4b50047bf3290fecc5c905ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4148554
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091567}
2023-01-11 23:46:39 +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
Daniel Cheng
982f2b2e68 Use base::FunctionRef for the various ForEachRenderFrameHost helpers.
Using base::FunctionRef as the callable param for a visitor function
can significantly reduce the boilerplate required to use the visitor
function. It also avoids the heap allocation required to support
base::RepeatingCallback's strong ownership semantics.

The most common transformation in this CL is converting something
like:

  rfh->ForEachRenderFrameHost(base::BindRepeating(
      &MyClass::HandleRFH, base::Unretained(this)));

to simply using a lambda that captures `this`:

  rfh->ForEachRenderFrameHost([this] (content::RenderFrameHost* rfh) {
      HandleRFH(rfh);
  });

An astute reader will note that the latter is one line longer; however,
many of these callbacks currently bind other arguments as additional
input parameters or as out parameters. Using lambda captures
significantly reduces the boilerplate, improving readability, and makes
it much easier to avoid unnecessary copies.

Bug: 1303103
Change-Id: I3aeb74a0988dbddb645faef2239e9541c9adac52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3767487
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1039508}
2022-08-25 23:46:16 +00:00
Robert Sesek
976c70cf77 Convert //content WebUIs to register with RegisterWebUIControllerInterfaceBinder()
This also adds support for the WebUIController to optionally receive the
BindInterface() with the associated RenderFrameHost.

Change-Id: I8dffd7e1eb4321ac3bb10937e7b8421b8d134e44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3825966
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1034619}
2022-08-12 19:17:57 +00:00
W. James MacLean
c95d0c1cce Rename process-internals sandbox variable.
Rename variable to make it more informative.

Bug: 510122
Change-Id: I1f5a426f3483a22f8d0f68ef107fbe205275ccdc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3704620
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014051}
2022-06-14 18:00:22 +00:00
W. James MacLean
7dae2da57d Add SiteInstance isolated-sandbox status to process-internals.
When a SiteInstance is used for processr-isolating a sandboxed iframe,
reflect that status in chrome://process-internals.

Bug: 510122
Change-Id: Icbf5eb9aa66a29d378a48a57f7ebc1dcec387643
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3704316
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013677}
2022-06-13 22:01:54 +00:00
Dave Tapuska
327c06c9c7 Rename GetMainFrame to GetPrimaryMainFrame
Progressively rename some usages of GetMainFrame to GetPrimaryMainFrame.

This is an automated change via git grep & sed.

BUG=1250404

Change-Id: I5e8fda4f11104cf9fcde8a690a33dc6ab7c34f3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696741
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013636}
2022-06-13 20:31:51 +00:00
Giovanni Ortuño Urquidi
f8c1bd9fea webui: Migrate PrerendererInternals, ProcessInternals, Tracing, and QuotaInternals
Context:

Currently WebUI properties, e.g. CSPs, requesting schemes, host, mojo,
etc. are stored in WebUIControllers themselves or in separate lists
like IsWebUIAllowedToMakeNetworkRequests. The lifetime of a
WebUIController is bound to the frame, which makes it hard to use for
some use cases where the WebUIController hasn't been created yet. A
non-dynamically allocated class where clients could query a WebUI's
properties would be easier to use and audit.

WebUIConfig is a class that stores properties of WebUIs. For now the
properties are 1. the WebUI's origin, 2. if the WebUI is enabled,
and 3. GetURLDataSource() method for service worker initialization.
In the future this class could include information like CSPs, if we
should enable Mojo, if we should enable chrome.send(), if we should
allow network requests, URLDataSource, etc.

Bug: 1317510
Change-Id: Ic9d4481e12be16f120a65437c06c15f541ac0ee1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3657709
Reviewed-by: Stephen Nusko <nuskos@chromium.org>
Commit-Queue: Giovanni Ortuno Urquidi <ortuno@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1007223}
2022-05-25 04:12:05 +00:00
Alex Moshchuk
fb37a4fb54 Show guest status in chrome://process-internals for site-isolated guests
Prior to <webview> site isolation, guests looked like this on
chrome://process-internals:

SI:8, site:chrome-guest://edggnmnajhcbhlnpjnogkjpghaikidaa/?foo#ondiskfallback | url: https://www.google.com/?gws_rd=ssl

With <webview> site isolation, guests became indistinguishable from
regular frames:

SI:8, locked, site:https://google.com/ | url: https://www.google.com/?gws_rd=ssl

This CL restores the guest information that was previously conveyed
through the site URL, including whether the SiteInstance is for a
guest and a string representation of its StoragePartition:

SI:8, locked, site:https://google.com/, guest, partition:edggnmnajhcbhlnpjnogkjpghaikidaa/foo | url: https://www.google.com/?gws_rd=ssl

Bug: 1267977
Change-Id: I467ec38cf983127fade665d02ffc58fe43f0c1f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3643024
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1002914}
2022-05-12 23:19:51 +00:00
David Sanders
73ebb80cf0 Clean up includes and forward decls of render_frame_host_impl.h
Also adds an include which was being pulled in transitively, to fix the
build.

Bug: 242216
Change-Id: I06e87cadc368d651a36e6c646a1aecefdf6f1662
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3588684
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: David Sanders <dsanders11@ucsbalum.com>
Cr-Commit-Position: refs/heads/main@{#993510}
2022-04-19 00:53:12 +00:00
Jiewei Qian
cc639a6634 webui: Add ExtraMojoJsFeatures
This CL refactors previously added MojoJSFileSystemAccess Web IDL
feature to into a ContextEnabled feature, and add methods to WebUI
infrastructure to enable it.

This is more aligned with WebUI's design expectation that WebUI is a
per-frame concept (hence their feature should be ContextEnabled),
instead of a per-process concept (previously used RuntimeEnabled
feature).

WebUIs wishing to enable these extra features should call
EnableMojoJsBindings with the extra features they need.

Bug: 1288174
Change-Id: I94d7445ef62dfd5afb9c0ef204f3b57d96c892bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3546210
Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#987764}
2022-04-01 02:43:34 +00:00
Dave Tapuska
7818085c51 Adjust ProcessInternals to account for FencedFrames.
Previously the iteration was based on children of a RenderFrameHost.
This did not traverse FencedFrame trees so convert this to
ForEachRenderFrameHost. Avoid traversing into inner WebContents since
that is already covered in the GetAllWebContents.

BUG=1263574

Change-Id: Iab54fa243d49cdc8ecb4ded2d491880dd0b29860
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3511087
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Kevin McNee <mcnee@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#979297}
2022-03-09 17:44:10 +00:00
Juyoung Kim
aa699c84be Add WebUIDataSource::CreateAndAdd()
Almost all WebUIDataSource::Create() users do no try to take ownership
of the WebUIDataSource. The returned pointer always be passed to
WebUIDataSource::Add() and it eventually passes the pointer down to
URLDataManagerBackend. Inside WebUIDataSource::CreateAndAdd(), it calls
WebUIDataSource::Add() to internalize its ownership. It provides right
ownership semantics, and abstracts away the URLDataSourceImpl is
refcounted details.

Bug: 1206140
Change-Id: I89fd2e03b2a782b5c8ff00d1912d1adf78ef2218
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3406435
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#968119}
2022-02-08 01:55:29 +00:00
Sharon Yang
57481e554d Update calls to ChildProcessSecurityPolicy::GetProcessLock
As a followup to introducing RenderProcessHost::GetProcessLock, update
call sites that use ChildProcessSecurityPolicy.
There are also some sites that update SiteInstanceImpl::GetProcessLock
to RenderProcessHost::GetProcessLock, where it is more accurate to get
the ProcessLock for the process.

Bug: 1261963
Test: Updated browsertests
Change-Id: I27823e5c584cde9dcd03e661d4f6f272d483cbd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3307505
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#946768}
2021-12-01 00:05:22 +00:00
Keishi Hattori
0e45c020c4 Rewrite most Foo* field_ pointer fields to raw_ptr<Foo> field_.
DO NOT REVERT (unless absolutely necessary)! Report build breaks to keishi@(APAC)/glazunov@(EMEA)/sebmarchand@(NA) as soon as you see them. Fixes are expected to be trivial.

This commit was generated automatically, by running the following script: tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh on commit fe74bc434e

For more information, see MiraclePtr One Pager [1], the PSA at chromium-dev@ [2], and the raw_ptr documentation in //base/memory/raw_ptr.md.

FYI This CL does not enable MiraclePtr protection and we expect no behavior change from this.

[1] https://docs.google.com/document/d/1pnnOAIz_DMWDI4oIOFoMAqLnf_MZ2GsrJNb_dbQ3ZBg/edit?usp=sharing
[2] https://groups.google.com/a/chromium.org/g/chromium-dev/c/vAEeVifyf78/m/SkBUc6PhBAAJ

Binary-Size: Increase of around 500kb was approved for MiraclePtr
Include-Ci-Only-Tests: true
No-Tree-Checks: true
No-Presubmit: true
Bug: 1272324, 1073933
Change-Id: I05c86a83bbb4b3f4b017f361dd7f4e7437697f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3305132
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Owners-Override: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#945735}
2021-11-27 09:25:52 +00:00
Sharon Yang
a005ca1217 Move ProcessLock to a separate file
ProcessLock is a large enough class that it should be in its own file.

Test: CQ (no functionality changed)
Change-Id: Id706fc5c4fc1b5ba4835507519df7db3bb6cd1a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3271768
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#942265}
2021-11-16 20:09:42 +00:00
W. James MacLean
7f76c220f5 Refactor to allow non-origin_keyed OAC to live alongside origin-keyed.
This CL refactors the code that tracks OAC (OriginAgentCluster)
isolation opt-ins to allow for having both origin-keyed OAC processes
and non-origin-keyed OAC processes present at the same time.

The map in ChildProcessSecurityPolicyImpl that tracks OAC opt-ins is
|origin_isolation_by_browsing_instance_|. Prior to this CL it just
tracks a list of origins, with the assumption being that any origin
in the list is opted in for whatever OAC mechanism is currently being
used.

The two mechanisms are origin_keyed, in which each origin is assigned
its own process, and non-origin_keyed, in which each origin is logically
isolated in the renderer process, but may share a renderer process with
other origins. At present, only one of these mechanisms is active for
a given browser session.

In this CL we modify |origin_isolation_by_browsing_instance_| to track
which mechanism to use for each origin, thus allowing both mechanisms
to be active at once.

This CL also enhances the UrlInfo::OriginIsolationRequest flags to
allow us (in some future CL) to control which mechanism to register at
opt-in time.

Bug: 1259920
Change-Id: Id6a9c396f2cf94264aab171b80d72c7f4917a2f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3244802
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: W. James MacLean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#941698}
2021-11-15 16:27:49 +00:00
Peter Boström
1d6a095400 Remove unused "base/macros.h" in content/
Removes `#include "base/macros.h"` from files in content/ that do not
contain `ignore_result(`.

Bug: 1010217
No-Try: true
Change-Id: I887403408704241047e3bd66e953ff7df195368b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3274993
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#940781}
2021-11-11 16:07:03 +00:00
Dave Tapuska
e4ada09af7 Avoid an entire tree walk for determining the roots of prerender.
This fixes doing an entire tree walk, as well as changes
GetParent()->GetParentOrOuterDocument so it is correct for fenced
frames.

BUG=1215531

Change-Id: I0e0d830293875af1be7d578e417f6c7e0a3f76df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3251386
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936366}
2021-10-29 14:10:05 +00:00
Peter Boström
828b902994 Replace DISALLOW_COPY_AND_ASSIGN in content/
This replaces DISALLOW_COPY_AND_ASSIGN with explicit constructor deletes
where a local script is able to detect its insertion place (~Foo() is
public => insert before this line).

This is incomplete as not all classes have a public ~Foo() declared, so
not all DISALLOW_COPY_AND_ASSIGN occurrences are replaced.

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: Iea478401b7580682c7b9f195f7af9cbbdb6ce315
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3167292
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#923194}
2021-09-21 02:28:43 +00:00
Jun Kokatsu
935468edad Create a script for ease of static string assignments to dangerous sinks
After Trusted Types enforcement on WebUI was enabled, a static string
assignment to dangerous sinks had to go through custom Trusted Type
policy. While this practice ensures that we prevent DOM-based XSS, it
adds a lot more work for developer who just wants to assign a static
string to innerHTML (for example), which should be safe.

static_types.js provides an easy way to create Trusted Types, while ensuring
that the passed string is static by using Tagged template literals[1].
This script is inspired by Koto's rawhtml.js[2].

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
[2] https://gist.github.com/koto/de7ec42a57c12259cbe4fa8fc19c1d78

Bug: 1163549
Change-Id: I2de1f840078c6be2be81f7458ef34420f3aadbe4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3058809
Commit-Queue: Jun Kokatsu <Jun.Kokatsu@microsoft.com>
Reviewed-by: dpapad <dpapad@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/main@{#913281}
2021-08-19 05:07:49 +00:00
Yuzu Saijo
68390b998c [bfcache] Refactor BackForwardCacheImpl::Entry to be bfcache specific
This CL refactors BackForwardCacheImpl::Entry so that it is bfcache
specific. Now prerendering uses BackForwardCacheImpl::StoredPage.
BackForwardCacheImpl::Entry now owns StoredPage.

Bug: 1181263,1228611, 1183523
Change-Id: Ie51f79913177dcf2d144a734f292c0c7b3646121
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3034509
Commit-Queue: Yuzu Saijo <yuzus@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#905599}
2021-07-27 06:17:20 +00:00
Lukasz Anforowicz
1de0a221d4 Introduce and use SiteInstanceId (instead of int32_t).
Bug: 1229798
Change-Id: Ic76738567279b64f98b59f039c08c11354b6b45b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3039282
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Ben Wells <benwells@chromium.org>
Reviewed-by: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#905436}
2021-07-26 22:02:32 +00:00
Sharon Yang
e7371a17b9 Rename WebUIController::RenderFrameCreated
There are classes that extend both WebUIController and
WebContentsObserver, but both interfaces have a function called
RenderFrameCreated, which is confusing and risky as a result.

* Rename WebUIController::RenderFrameCreated to WebUIRenderFrameCreated
* Clean up macros

Bug: 1225704
Change-Id: I8d1b6333c3a2d937558ea7488a721a321aa2687e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2999042
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Owners-Override: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#897882}
2021-07-01 20:32:31 +00:00
Matt Falkenhagen
78d73cbe8a Prerender: Add prerendered pages to chrome://process-internals.
Bug: 1215531
Change-Id: I86844e62df95ff1f3f7ee49355bb32b90f51b3f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2945256
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#890472}
2021-06-08 22:09:18 +00:00
Lei Zhang
a10cfce1a8 Remove unneeded <string> includes from chromecast/ and content/.
This CL is mechanically generated as follows:

git ls-files chromecast content | grep '\.h$' | \
    xargs grep -l '^#include <string>' | \
    xargs grep -L -E 'std::(|w|u16|basic_)string' | \
    xargs grep -L std::char_traits > to_process.txt

cat to_process.txt | xargs sed -i "/^#include <string>$/d"
cat to_process.txt | xargs sed -i '/^$/N;/^\n$/D'

Bug: 1200833
Change-Id: I34b0b9815ec66bdb258e6cf7e592a4c31d7cac58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2910969
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Sean Topping <seantopping@chromium.org>
Commit-Queue: Sean Topping <seantopping@chromium.org>
Auto-Submit: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#885611}
2021-05-21 19:23:04 +00:00
Alex Moshchuk
6638688c23 [COOP Isolation] Persist isolated COOP sites across restarts.
This CL implements support for saving COOP-isolated sites to user
prefs.  This allows them to survive restarts.  Persistent isolation is
triggered by visiting a COOP site and then interacting with it (i.e.,
via user activation).  Persistence is used when
kSiteIsolationForCrossOriginOpenerPolicy is enabled (intended for
Android, since desktop already has full site isolation), and it may
also be turned off by a field trial param.

The implementation is similar to how we save/restore
password-triggered isolated sites, with additional restrictions on the
saved COOP site list.  Namely, we limit the list to at most 100
entries (controllable via a field trial param) and evict older sites
when this limit is exceeded.  To do the latter, we store a last-access
timestamp along with each isolated site.  A followup CL will further
restrict the stored isolated sites to not be loaded if they're more
than a week old.

A new user pref is added for web-triggered isolated origins and used
for storing COOP-isolated sites (and possibly other kinds of sites
that trigger site isolation with site-specified mechanisms
in the future).  This complements the user-triggered isolated origins
pref (used for password sites) and is managed in
//components/site_isolation, allowing this whole mechanism to also
work in weblayer.

As before, persistence is not supported in incognito, and a browser
test is added to verify this.

The saved COOP sites are cleared via the same clear-browsing-data
triggers as password-isolated sites (namely, either history or cookies
and other site settings).  The existing unit test we had for that is
updated to also employ the COOP pref.

For more details, see
https://docs.google.com/document/d/122niZuMrub8vu4PJRGQrU_bG02tPPcjqWpsj3GJ1Uq0/edit#

Bug: 1018656
Change-Id: Iea4fe0b41a2521a92ab267c44bf615ca420609cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2898148
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Clark DuVall <cduvall@chromium.org>
Reviewed-by: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#884196}
2021-05-18 22:51:29 +00:00
Anton Bikineev
f62d1bf48e content: Replace base::Optional and friends with absl counterparts
This replaces:
- base::Optional -> absl::optional
- include "base/optional.h"
  ->
  include "third_party/abseil-cpp/absl/types/optional.h"
- base::nullopt -> absl::nullopt
- base::make_optional -> absl::make_optional

Bug: 1202909
Change-Id: Ie9f37bcbf6115632a19f4d063387d07b3723926f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897246
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883270}
2021-05-15 17:56:07 +00:00
Alex Moshchuk
a9bb33ed0c Update chrome://process-internals for COOP and OAuth isolation.
This CL makes two tweaks to chrome://process-internals for the new
Android site isolation modes:

- add ability to show COOP and OAuth isolation in the list of site
isolation modes.

- display currently isolated COOP sites. Currently, these are active
for the remainder of the browser session and cleared after a restart.
Once we add persistence, we'll want to come back and update the
description here.

Bug: 1018656, 960888
Change-Id: Ie97df36b7d5b30fe90e73ca240bb900e0458b026
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2872254
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#879193}
2021-05-05 02:38:53 +00:00
Jan Wilken Dörrie
8aeb574da9 [LSC] Remove base::ASCIIToUTF16("...") in //content and //ui
This change removes calls to base::ASCIIToUTF16 in //content and //ui
with a single-line string literal and replaces them with a u"..."
literal instead. Files where this change would cause compilation errors
were not changed.

This is a mechanical change:

$ git grep -lw ASCIIToUTF16 content ui | xargs \
    sed -i 's/\(base::\)\?ASCIIToUTF16(\("\(\\.\|[^\\"]\)*"\))/u\2/g'
$ git cl format

Bug: 1189439
Change-Id: I0d5601dc15324c43012b8d26260405f1efdca07e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2780265
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#865766}
2021-03-23 19:27:02 +00:00
Jan Wilken Dörrie
aace0cfef2 [LSC] Replace base::string16 with std::u16string in //{chrome*,content}
This change replaces base::string16 with std::u16string in //chrome,
//chromecast, //chromeos and //content.

Reproduction steps:
$ git grep -lw 'base::string16' chrome* content | \
      xargs sed -i 's/\bbase::string16\b/std::u16string/g'
$ git cl format

Bug: 1184339
Change-Id: I8fae0ab25b5d9bf1cb416ae5f47d7f680fb8f3ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2752229
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#862152}
2021-03-11 22:01:58 +00:00
Dominic Farolino
43261c16fa Rename agent_scheduling_group() => GetAgentSchedulingGroup()
The style guide indicates that only inline methods should be named using
snake_case, and since an earlier CL made
RenderFrameHostImpl::agent_scheduling_group() virtual, the body was
moved to the implementation file, but I think per a strict reading of
the style guide, the method should have been renamed.

(This was originally caught by talp@ by an earlier nit, and I mistakenly
did not address it before landing the earlier CL).

R=kouhei@chromium.org, nasko@chromium.org, talp@chromium.org

Bug: N/A
Change-Id: I04c608c71325dfd9dd95adc5b728747724afb40e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2681117
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Tal Pressman <talp@google.com>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852983}
2021-02-11 03:53:22 +00:00
dpapad
8abde2cfca Add POLICY_BINDINGS_NONE in content::BindingsPolicy enum.
Previously the code was using "0" as a magic constant, like
SetBindings(0) or
GetBindings() == 0

which is somewhat cryptic. Adding an explicit enum value makes the code
more readable.

Fixed: 1158634
Change-Id: Ie4d95dd3fb834303be74a21c22751f38e6337e99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2651477
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849167}
2021-02-01 18:18:39 +00:00
Daniel Cheng
0d360f554b [WebUI] Use WebUIController::RenderFrameCreated() to request MojoJS.
ConversionInternalsUI and ProcessInternalsUI don't need to be
WebContentsObservers at all, since WebUIController already provides a
RenderFrameCreated() override that is scoped WebUI-specific
RenderFrameHosts.

Bug: 1148682, 1149125
Change-Id: Iebef544d7fb7c8938d273c84279ce7e8b19f90a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566889
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832563}
2020-12-01 23:11:42 +00:00
Ken Rockot
4acce46f02 Migrate Content WebUIs to Mojo JS modules
There are three WebUIs defined in Content which use Mojo:

- gpu
- process-internals
- conversion-internals

These are adapted here to use newer Mojo JS modules.

Bug: 1004256
Change-Id: If766eb81599d9311b79076011a8ac1d08f343927
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555806
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Auto-Submit: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#832130}
2020-12-01 01:06:00 +00:00
kouhei
6d7f365613 process-internals: Show agent_scheduling_group_id for frames
This CL extends the chrome://process-internals UI to display
AgentSchedulingGroupHost ID.

Bug: 1111231
Change-Id: I26656239d6e860d646402eb93ec8ee9c799fd7ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2546346
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Dominic Farolino <dom@chromium.org>
Reviewed-by: Tal Pressman <talp@chromium.org>
Commit-Queue: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829474}
2020-11-20 01:44:00 +00:00
Aaron Colwell
ab4e5a2267 Remove ProcessLock::is_empty().
Removing is_empty() method and updating callers to use the explicit
lock state methods is_invalid/allows_any_site/is_locked_to_site instead.

Bug: 1085275
Change-Id: Id08adaca960368de16943710c5a35c9a6fb5a350
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414764
Commit-Queue: Aaron Colwell <acolwell@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808626}
2020-09-19 01:07:52 +00:00
danakj
30f5b7dd00 Point includes to content/browser/renderer_host instead of frame_host/ (6/x)
The code has moved, so update the includes.

R=avi@chromium.org

Bug: 1091083
Change-Id: I2c9a5c20b78756fc0b460a85f00d8560f1883979
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412947
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: danakj <danakj@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807483}
2020-09-16 15:38:45 +00:00
Alex Moshchuk
16682adf6e Show lock URL and the origin-keyed bit in chrome://process-internals
After https://crrev.com/c/2304537, the site URL will no longer contain
the process lock URL in the hash, so the lock URL won't be visible on
chrome://process-internals.  This CL adds the plumbing to show the
lock URL independently from site URL, but only if the two URLs are
different.  This way, we'll be able to view the lock URL
in cases where it matters (e.g., for hosted apps), and it won't
pollute the UI in the common case where it matches the site URL.

For completeness, this CL also plumbs the is-origin-keyed bit, so that
all current parts of SiteInfo (foundation of a future
SecurityPrincipal abstraction) are shown.  The origin-keyed bit is
currently only shown when opt-in origin isolation is in effect.

Bug: 1105994, 1067389
Change-Id: Ife20bcefc57aecee96e24a436ae89902e0837d20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364816
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799787}
2020-08-19 20:53:55 +00:00
Jun Kokatsu
2e4a49088b Change report-only Trusted Types mitigation to Perfect types by default
This change makes Trusted Type policy enforcement to Perfect types
(i.e. `require-trusted-types-for 'script'; trusted-types;`) by
default for WebUI (while still keeping report-only).

This means WebUI will not be able to use unsafe APIs by default (e.g.
innerHTML, document.write, etc). However, I have removed Trusted
Types CSP from a pages where it does not support Trusted Types yet
(e.g. Polymer 3).

This change will not make any observable changes, as report-only CSP
would only log console error when it detects Trusted Types violation.

Bug: 41905
Change-Id: Ib9d6eae53b600123c1837d2cdc56269c14a8d00f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2234238
Commit-Queue: Jun Kokatsu <Jun.Kokatsu@microsoft.com>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: dpapad <dpapad@chromium.org>
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Reviewed-by: Tommy Steimel <steimel@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: enne <enne@chromium.org>
Reviewed-by: oysteine <oysteine@chromium.org>
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795173}
2020-08-05 20:52:16 +00:00
Lukasz Anforowicz
bb5ab432cd Verify presence of just "Process Internals" substring in page contents.
Before this CL, the test would look for "Process Model Internals"
substring in page contents.  This substring is present, but is populated
dynamically in the "Frame Trees" pane:
- WebContents: Process Model Internals, 1 frame.

To make the test less dependent on when the dynamic text is added, this
CL starts looking instead for "Process Internals" substring which is
statically present in
//content/browser/resources/process/process_internals.html

Additionally, after this CL the test inspects page contents via gMock,
rather than via innerHTML.search API.  Hopefully, the change in this CL
will make test failures easier to diagnose in the future (i.e. gMock
should display mismatched |page_contents|).  Before this CL, the test
failure would just say that |innerHTML.search| API returned -1.

Bug: 1107995
Change-Id: I83e5f45563a780b5dc8919e36ad71b2e171ac2ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317852
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791956}
2020-07-27 20:18:06 +00:00
W. James MacLean
e84fa11351 Refactor to use ProcessLock.
The second CL in implementing origin-/site-keying of SiteInstances.
https://crbug.com/1085275/#c2 lists the sequence of CLs and what each
will accomplish.

This CL is a refactor to introduce the ProcessLock class to replace
the GURLs returned by GetOriginLock() and related functions.

It also combines some argument lists that take both a SiteURL and a
LockURL and instead uses SiteInfo or ProcessLock. One notable example
is RenderProcessHostImpl::IsSuitableHost().

Bug: 1067389, 846155
Change-Id: I3c6f67f2bf6f1ce3ed2bc394dbd92827ebd8a50a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246923
Commit-Queue: James MacLean <wjmaclean@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Aaron Colwell <acolwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788226}
2020-07-14 17:25:54 +00:00
Harkiran Bolaria
176eacd1c8 Add bf cache frames to chrome://process-internals
Include all frames from the back-forward cache on chrome://process-internals

See screenshot at https://screenshot.googleplex.com/PWioJrimGWX.png

Bug: 1074349
Change-Id: I55cb218ae88a2f1a78a0d85dfc15471e7b0dc823
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2175457
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Harkiran Bolaria <hbolaria@google.com>
Cr-Commit-Position: refs/heads/master@{#767352}
2020-05-11 16:54:04 +00:00