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}
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}
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}
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}
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}
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}
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}