0
Commit Graph

13 Commits

Author SHA1 Message Date
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
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
Dave Tapuska
44659ba272 Rewrite test interceptors GetAllFrames.
Since the test interceptors currently handle RenderFrameCreated from
other pages we can just iterate all the frame trees in the ctor using
ForEachRenderFrameHost.

BUG=1208438

Change-Id: Ib278d6ec0ffe7b5139a75eb94281fe3904782c34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3173156
Reviewed-by: Alexander Timin <altimin@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#925284}
2021-09-27 16:06:21 +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
Dave Tapuska
1d81114898 Remove frame_messages.h includes.
These includes aren't necessary. Remove them. Reduce frame_messages.h
to only the blink::Impression struct trait.

BUG=786836

Change-Id: Ic2cb0836849b078e9b1d7f6a050f996dded3fbaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2855936
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#879526}
2021-05-05 20:30:56 +00:00
Lukasz Anforowicz
1ecfe450c1 Adding ContentScriptTracker::DidFrameRunContentScriptFromExtension.
This CL extracts content-script matching code out of
`extensions::URLLoaderFactoryManager` and moves it into a new class -
`extensions::ContentScriptTracker`.  In particular, the old
DoContentScriptsMatchNavigatingFrame static method and its tests got
moved.

The new ContentScriptTracker exposes an ability to query
DidFrameRunContentScriptFromExtension.  This ability is important for
future CLs, that need to start validating a handful of mojo/IPC messages
that claim to come on behalf of a content script that used to be
injected by an extension with a given id.

Bug: 982361
Change-Id: Id9e4d87436eafe9164fb05f9af64f1d0cdc1a9b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2730029
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#867868}
2021-03-30 23:40:06 +00:00
arthursonzogni
73fe321d93 Mojoify DidCommitProvisionalLoadParams [reland]
Reland information:
---
Patchset 1 contains the original (reverted) patch. It has been reverted,
because it landed together with:
https://chromium-review.googlesource.com/c/chromium/src/+/2533280

[Initial code review]:
https://chromium-review.googlesource.com/c/chromium/src/+/2529096

[Revert]:
https://chromium-review.googlesource.com/c/chromium/src/+/2542857
---

Turn the IPC struct:
FrameHostMsg_DidCommitProvisionalLoad_Params

Into a mojo struct
mojom::DidCommitProvisionalLoadParams

This is mostly straigforward, except:

1. The functions have been updated to correctly specify whether
   ownership over this struct is passed or not. Use one of "const T&" /
   "T*", "TPtr*".

2. Mojo checks the required params are populated. This forced me to
   update several unittests to construct the required params. Like the
   referrer or the navigation_token.

3. blink::mojom::Referrer is used instead of the old content::Referrer
   This required adding (temporarily) the conversion between both when
   needed.

TBR=nasko@chromium.org

Fixed: 1145888
Bug: 1145888
Change-Id: I5e4a271b362db295947dea51e926114684328e16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2543347
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828161}
2020-11-17 13:24:07 +00:00
Findit
7ff0148dc2 Revert "Mojoify DidCommitProvisionalLoadParams"
This reverts commit 93cc91b2e4.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 828123 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzkzY2M5MWIyZTRlZGU0MTYwNTRlNTVkNGMyNmEzMjAyNjZkZTA3NjYM

Sample Failed Build: https://ci.chromium.org/b/8863396302867752096

Sample Failed Step: compile

Original change's description:
> Mojoify DidCommitProvisionalLoadParams
> 
> Turn the IPC struct:
> FrameHostMsg_DidCommitProvisionalLoad_Params
> 
> Into a mojo struct
> mojom::DidCommitProvisionalLoadParams
> 
> This is mostly straigforward, except:
> 
> 1. The functions have been updated to correctly specify whether
>    ownership over this struct is passed or not. Use one of "const T&" /
>    "T*", "TPtr*".
> 
> 2. Mojo checks the required params are populated. This forced me to
>    update several unittests to construct the required params. Like the
>    referrer or the navigation_token.
> 
> 3. blink::mojom::Referrer is used instead of the old content::Referrer
>    This required adding (temporarily) the conversion between both when
>    needed.
> 
> Fixed: 1145888
> Bug: 1145888
> Change-Id: Ib94cff3921d0212d8c1556062326d6cb6d0dcba4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2529096
> Reviewed-by: Nasko Oskov <nasko@chromium.org>
> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#828123}


Change-Id: If87cc3dce40bc743138b7225818db9073f4ca474
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1145888
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542857
Cr-Commit-Position: refs/heads/master@{#828126}
2020-11-17 09:23:55 +00:00
arthursonzogni
93cc91b2e4 Mojoify DidCommitProvisionalLoadParams
Turn the IPC struct:
FrameHostMsg_DidCommitProvisionalLoad_Params

Into a mojo struct
mojom::DidCommitProvisionalLoadParams

This is mostly straigforward, except:

1. The functions have been updated to correctly specify whether
   ownership over this struct is passed or not. Use one of "const T&" /
   "T*", "TPtr*".

2. Mojo checks the required params are populated. This forced me to
   update several unittests to construct the required params. Like the
   referrer or the navigation_token.

3. blink::mojom::Referrer is used instead of the old content::Referrer
   This required adding (temporarily) the conversion between both when
   needed.

Fixed: 1145888
Bug: 1145888
Change-Id: Ib94cff3921d0212d8c1556062326d6cb6d0dcba4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2529096
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828123}
2020-11-17 08:59:22 +00:00
Lukasz Anforowicz
d11540da28 Use origin of in-flight navigation when handling NetworkService crash.
RenderFrameHostImpl::UpdateSubresourceLoaderFactories method is called
after NetworkService process crashes and recreates/resends
URLLoaderFactory objects to the renderer process.  Before this CL,
the recreated factory was always based on the |last_committed_origin_|
(and |last_committed_client_security_state_|, etc.).  This resulted
in creating a factory with a wrong |request_initiator_origin_lock|
to a frame that was in the process of committing a navigation.

A similar problem (using |last_committed_origin_| rather than the target
origin of an in-flight/in-commit NavigationRequest) has already been
known (had to be addressed in https://crbug.com/1047436) but the known
scenario and the fix (e.g.
RFHI::GetExpectedMainWorldOriginForUrlLoaderFactory) focused on isolated
world factories.

In this CL, the previous fix is made more generic by splitting
GetExpectedMainWorldOriginForUrlLoaderFactory across
FindLatestNavigationRequestThatIsStillCommitting and
ExtractFactoryParamsFromNavigationRequestOrLastCommittedNavigation
methods.  While working on the CL, all callers of
RFHI::CreateURLLoaderFactoryParamsForMainWorld and
RFHI::CreateURLLoaderFactoriesForIsolatedWorlds have been inspected and
most of these callers have been switched to basing factory parameters
based on the in-flight NavigationRequest if one exists.  (all except
RFHI::CreateNetworkServiceDefaultFactory that is exposed via
//content/browser/public and we assume has an expectation of working
with the last committed origin).

Bug: 1056949
Change-Id: I3cadd28ec71d8a203117a314d084314e60babc03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2399184
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807668}
2020-09-16 21:23:19 +00:00
danakj
e34636e8f2 Point includes to content/browser/renderer_host instead of frame_host/ (3/x)
The code has moved, so update the includes.

R=avi@chromium.org

Bug: 1091083
Change-Id: I69fd4010fb9198fa10a937a030015dfc8f566b80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412484
Commit-Queue: danakj <danakj@chromium.org>
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@{#807197}
2020-09-15 22:15:00 +00:00
Arthur Hemery
2a0a28bee3 Navigation: Reintroducing DidCommitProvisionalLoadInterceptor.
This patch reintroduces DidCommitProvisionalLoadInterceptor
(removed in
https://chromium-review.googlesource.com/c/chromium/src/+/1455470),
renamed as DidCommitNavigationInterceptor, to work with the new
NavigationClient interface.

It does so by adding an interceptor to the RenderFrameHostImpl, called
directly after entering the callback.

Bug: 784904
Change-Id: I7cbba4e9220017625676c7679c8606ad425712e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1477028
Commit-Queue: Arthur Hemery <ahemery@chromium.org>
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638183}
2019-03-06 17:51:36 +00:00