Avoid type conversion in ForEachRenderFrameHost().
These are documented as invoking on an RFHI*, but were named like "RFH" and frequently passed RFH*. Rename and change signatures to all align. This avoids some problems with experimental Bind changes I was doing. Bug: 40176578 Change-Id: I8b8f5e943ce89226f9af471563aaf134bd0feeba Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6058761 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Peter Kasting <pkasting@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/main@{#1390724}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c3d684336e
commit
d2876a2bbd
content
browser
accessibility
android
back_forward_cache_internal_browsertest.ccdevtools
download
find_request_manager.ccnavigation_mhtml_browsertest.ccpreloading
process_internals
renderer_host
back_forward_cache_impl.ccnavigation_request.ccpage_impl.ccrender_frame_host_android.ccrender_frame_host_impl.ccrender_frame_host_impl.hrender_frame_host_impl_browsertest.ccrender_frame_host_manager.cc
web_contents
test
@ -1797,7 +1797,7 @@ void WebContentsAccessibilityAndroid::RequestAccessibilityTreeSnapshot(
|
||||
ProcessCompletedAccessibilityTreeSnapshot,
|
||||
GetWeakPtr(), env, std::move(movable_view_structure_root)),
|
||||
std::move(params));
|
||||
web_contents_->GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
web_contents_->GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[&combiner](RenderFrameHostImpl* rfhi) {
|
||||
combiner->RequestSnapshotOnRenderFrameHost(rfhi);
|
||||
});
|
||||
|
@ -249,7 +249,7 @@ void GinJavaBridgeDispatcherHost::AddNamedObject(
|
||||
|
||||
web_contents()
|
||||
->GetPrimaryMainFrame()
|
||||
->ForEachRenderFrameHostIncludingSpeculative(
|
||||
->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[&name, object_id, this](RenderFrameHostImpl* render_frame_host) {
|
||||
if (!render_frame_host->IsRenderFrameLive()) {
|
||||
return;
|
||||
@ -278,7 +278,7 @@ void GinJavaBridgeDispatcherHost::RemoveNamedObject(
|
||||
|
||||
web_contents()
|
||||
->GetPrimaryMainFrame()
|
||||
->ForEachRenderFrameHostIncludingSpeculative(
|
||||
->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[&copied_name, this](RenderFrameHostImpl* render_frame_host) {
|
||||
if (!render_frame_host->IsRenderFrameLive()) {
|
||||
return;
|
||||
|
@ -99,10 +99,11 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BackForwardCacheFlush) {
|
||||
delete_observer_rfh_b.WaitUntilDeleted();
|
||||
}
|
||||
|
||||
// Tests that |RenderFrameHost::ForEachRenderFrameHost| and
|
||||
// |WebContents::ForEachRenderFrameHost| behave correctly with bfcached
|
||||
// Tests that `RenderFrameHostImpl::ForEachRenderFrameHostImpl` and
|
||||
// `WebContentsImpl::ForEachRenderFrameHostImpl` behave correctly with bfcached
|
||||
// RenderFrameHosts.
|
||||
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, ForEachRenderFrameHost) {
|
||||
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
|
||||
ForEachRenderFrameHostImpl) {
|
||||
// There are sometimes unexpected messages from a renderer to the browser,
|
||||
// which caused test flakiness on macOS.
|
||||
// TODO(crbug.com/40800266): Fix the test flakiness.
|
||||
@ -164,12 +165,12 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, ForEachRenderFrameHost) {
|
||||
::testing::UnorderedElementsAre(rfh_a, rfh_b, rfh_c, rfh_d, rfh_e));
|
||||
|
||||
{
|
||||
// If we stop iteration in |WebContents::ForEachRenderFrameHost|, we stop
|
||||
// the entire iteration, not just iteration in the page being iterated at
|
||||
// that point. In this case, if we stop iteration in the primary page, we do
|
||||
// not continue to iterate in the bfcached page.
|
||||
// If we stop iteration in `WebContentsImpl::ForEachRenderFrameHostImpl`, we
|
||||
// stop the entire iteration, not just iteration in the page being iterated
|
||||
// at that point. In this case, if we stop iteration in the primary page, we
|
||||
// do not continue to iterate in the bfcached page.
|
||||
bool stopped = false;
|
||||
web_contents()->ForEachRenderFrameHostWithAction(
|
||||
web_contents()->ForEachRenderFrameHostImplWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
EXPECT_FALSE(stopped);
|
||||
stopped = true;
|
||||
@ -201,12 +202,12 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, ForEachRenderFrameHost) {
|
||||
EXPECT_EQ(rfh_e, rfh_e->GetOutermostMainFrameOrEmbedder());
|
||||
}
|
||||
|
||||
// Tests that |RenderFrameHostImpl::ForEachRenderFrameHostIncludingSpeculative|
|
||||
// and |WebContentsImpl::ForEachRenderFrameHostIncludingSpeculative|
|
||||
// behave correctly when a FrameTreeNode has both a speculative RFH and a
|
||||
// bfcached RFH.
|
||||
// Tests that
|
||||
// `RenderFrameHostImpl::ForEachRenderFrameHostImplIncludingSpeculative` and
|
||||
// `WebContentsImpl::ForEachRenderFrameHostImplIncludingSpeculative` behave
|
||||
// correctly when a FrameTreeNode has both a speculative RFH and a bfcached RFH.
|
||||
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
|
||||
ForEachRenderFrameHostWithSpeculative) {
|
||||
ForEachRenderFrameHostImplWithSpeculative) {
|
||||
IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
|
||||
ASSERT_TRUE(embedded_test_server()->Start());
|
||||
GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
|
||||
|
@ -295,7 +295,7 @@ void FrameAutoAttacher::UpdateFrames() {
|
||||
DevToolsAgentHost::List new_auction_worklet_hosts;
|
||||
DevToolsAgentHost::List new_shared_storage_worklet_hosts;
|
||||
if (render_frame_host_) {
|
||||
render_frame_host_->ForEachRenderFrameHostWithAction(
|
||||
render_frame_host_->ForEachRenderFrameHostImplWithAction(
|
||||
[root = render_frame_host_, &new_hosts](RenderFrameHostImpl* rfh) {
|
||||
if (rfh == root || !rfh->is_local_root())
|
||||
return RenderFrameHost::FrameIterationAction::kContinue;
|
||||
|
@ -1040,7 +1040,7 @@ void EmulationHandler::UpdateDeviceEmulationState() {
|
||||
// this is tricky since we'd have to track the DevTools message id with the
|
||||
// WidgetMsg and acknowledgment, as well as plump the acknowledgment back to
|
||||
// the EmulationHandler somehow. Mojo callbacks should make this much simpler.
|
||||
host_->ForEachRenderFrameHostIncludingSpeculative(
|
||||
host_->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[this](RenderFrameHostImpl* host) {
|
||||
// The main frame of nested subpages (ex. fenced frames) inside this
|
||||
// page are updated as well.
|
||||
|
@ -1467,7 +1467,7 @@ String BuildReportStatus(const net::ReportingReport::Status status) {
|
||||
|
||||
std::vector<GURL> ComputeReportingURLs(RenderFrameHostImpl* frame_host) {
|
||||
std::vector<GURL> urls;
|
||||
frame_host->ForEachRenderFrameHostWithAction(
|
||||
frame_host->ForEachRenderFrameHostImplWithAction(
|
||||
[frame_host, &urls](content::RenderFrameHostImpl* rfh) {
|
||||
if (rfh != frame_host && (rfh->is_local_root_subframe() ||
|
||||
&rfh->GetPage() != &frame_host->GetPage())) {
|
||||
|
@ -514,7 +514,7 @@ void PreloadHandler::SendCurrentPreloadStatus() {
|
||||
|
||||
std::vector<RenderFrameHostImpl*> documents_in_local_subtree;
|
||||
RenderFrameHostImpl* root = host_;
|
||||
host_->ForEachRenderFrameHostWithAction(
|
||||
host_->ForEachRenderFrameHostImplWithAction(
|
||||
[&documents_in_local_subtree, root](
|
||||
RenderFrameHostImpl* rfh) -> RenderFrameHost::FrameIterationAction {
|
||||
if (rfh != root &&
|
||||
|
@ -219,10 +219,10 @@ void RenderFrameDevToolsAgentHost::AddAllAgentHosts(
|
||||
DevToolsAgentHost::List* result) {
|
||||
for (WebContentsImpl* wc : WebContentsImpl::GetAllWebContents()) {
|
||||
// Inner web contents such as guestviews are already handled by
|
||||
// ForEachRenderFrameHost.
|
||||
// ForEachRenderFrameHostImpl.
|
||||
if (wc->GetOutermostWebContents() != wc)
|
||||
continue;
|
||||
wc->GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
wc->GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[result](RenderFrameHostImpl* render_frame_host) {
|
||||
FrameTreeNode* node = FrameTreeNode::From(render_frame_host);
|
||||
if (!ShouldCreateDevToolsForNode(node))
|
||||
@ -999,8 +999,8 @@ void RenderFrameDevToolsAgentHost::UpdateResourceLoaderFactories() {
|
||||
if (!frame_host_)
|
||||
return;
|
||||
|
||||
frame_host_->ForEachRenderFrameHostWithAction([this](
|
||||
RenderFrameHostImpl* rfh) {
|
||||
frame_host_->ForEachRenderFrameHostImplWithAction([this](RenderFrameHostImpl*
|
||||
rfh) {
|
||||
if (frame_host_ != rfh && (rfh->is_local_root_subframe() ||
|
||||
&frame_host_->GetPage() != &rfh->GetPage())) {
|
||||
return content::RenderFrameHost::FrameIterationAction::kSkipChildren;
|
||||
|
@ -1237,7 +1237,7 @@ void SavePackage::GetSavableResourceLinks() {
|
||||
wait_state_ = RESOURCES_LIST;
|
||||
|
||||
DCHECK_EQ(0, number_of_frames_pending_response_);
|
||||
page_->GetMainDocument().ForEachRenderFrameHost(
|
||||
page_->GetMainDocument().ForEachRenderFrameHostImpl(
|
||||
[this](RenderFrameHostImpl* rfh) {
|
||||
GetSavableResourceLinksForRenderFrameHost(rfh);
|
||||
});
|
||||
|
@ -370,7 +370,7 @@ void FindRequestManager::EmitFindRequest(int request_id,
|
||||
|
||||
void FindRequestManager::ForEachAddedFindInPageRenderFrameHost(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> func_ref) {
|
||||
contents_->GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
contents_->GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[this, func_ref](RenderFrameHostImpl* rfh) {
|
||||
if (!CheckFrame(rfh))
|
||||
return;
|
||||
@ -696,10 +696,10 @@ void FindRequestManager::FindInternal(const FindRequest& request) {
|
||||
Reset(request);
|
||||
|
||||
// Add and observe eligible RFHs in the WebContents. And, use
|
||||
// ForEachRenderFrameHost instead of ForEachAddedFindInPageRenderFrameHost
|
||||
// ForEachRenderFrameHostImpl instead of ForEachAddedFindInPageRenderFrameHost
|
||||
// because that calls CheckFrame() which will only be true if we've called
|
||||
// AddFrame() for the frame.
|
||||
contents_->GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
contents_->GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[this](RenderFrameHostImpl* rfh) {
|
||||
auto* wc = WebContents::FromRenderFrameHost(rfh);
|
||||
// Make sure each WebContents is only added once.
|
||||
|
@ -860,7 +860,7 @@ IN_PROC_BROWSER_TEST_F(NavigationMhtmlFencedFrameBrowserTest,
|
||||
// Ensure nothing was created for the fencedframe element. Only a single
|
||||
// RenderFrameHost, the `main_document`, should exist.
|
||||
int num_documents = 0;
|
||||
main_document->ForEachRenderFrameHost(
|
||||
main_document->ForEachRenderFrameHostImpl(
|
||||
[&](RenderFrameHostImpl* rfh) { num_documents++; });
|
||||
EXPECT_EQ(1, num_documents);
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ class PrerenderBrowserTest : public ContentBrowserTest,
|
||||
// The activated page should no longer be in the prerendering state.
|
||||
RenderFrameHostImpl* navigated_render_frame_host = current_frame_host();
|
||||
// The new page shouldn't be in the prerendering state.
|
||||
navigated_render_frame_host->ForEachRenderFrameHost(
|
||||
navigated_render_frame_host->ForEachRenderFrameHostImpl(
|
||||
[](RenderFrameHostImpl* rfhi) {
|
||||
// All the subframes should be transitioned to
|
||||
// LifecycleStateImpl::kActive state after activation.
|
||||
@ -5426,9 +5426,10 @@ IN_PROC_BROWSER_TEST_P(PrerenderTargetAgnosticBrowserTest, SuppressOpenURL) {
|
||||
EXPECT_EQ(nullptr, new_web_contents);
|
||||
}
|
||||
|
||||
// Tests that |RenderFrameHost::ForEachRenderFrameHost| and
|
||||
// |WebContents::ForEachRenderFrameHost| behave correctly when prerendering.
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, ForEachRenderFrameHost) {
|
||||
// Tests that `RenderFrameHostImpl::ForEachRenderFrameHostImpl` and
|
||||
// `WebContentsImpl::ForEachRenderFrameHostImpl` behave correctly when
|
||||
// prerendering.
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, ForEachRenderFrameHostImpl) {
|
||||
const GURL kInitialUrl = GetUrl("/empty.html");
|
||||
// All frames are same-origin due to prerendering restrictions for
|
||||
// cross-origin.
|
||||
@ -5939,7 +5940,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, MojoCapabilityControl_LoosenMode) {
|
||||
// 4. Collect all RenderFrameHosts in the frame tree.
|
||||
std::vector<RenderFrameHostImpl*> all_prerender_frames;
|
||||
size_t count_speculative = 0;
|
||||
prerendered_render_frame_host->ForEachRenderFrameHostIncludingSpeculative(
|
||||
prerendered_render_frame_host->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
all_prerender_frames.push_back(rfh);
|
||||
count_speculative +=
|
||||
@ -13093,7 +13094,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderFencedFrameBrowserTest,
|
||||
// Since we've deferred creating the fenced frame delegate, we should see no
|
||||
// child frames.
|
||||
size_t child_frame_count = 0;
|
||||
prerendered_rfh->ForEachRenderFrameHost([&](RenderFrameHostImpl* rfh) {
|
||||
prerendered_rfh->ForEachRenderFrameHostImpl([&](RenderFrameHostImpl* rfh) {
|
||||
if (rfh != prerendered_rfh)
|
||||
child_frame_count++;
|
||||
});
|
||||
|
@ -654,7 +654,7 @@ std::unique_ptr<StoredPage> PrerenderHost::Activate(
|
||||
frame_tree_->Shutdown();
|
||||
frame_tree_.reset();
|
||||
|
||||
page->render_frame_host()->ForEachRenderFrameHostIncludingSpeculative(
|
||||
page->render_frame_host()->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[this](RenderFrameHostImpl* rfh) {
|
||||
// The visibility state of the prerendering page has not been
|
||||
// updated by
|
||||
|
@ -114,7 +114,7 @@ using IsolatedOriginSource = ChildProcessSecurityPolicy::IsolatedOriginSource;
|
||||
|
||||
// Execute over all frames appending any frames encountered to the parent's
|
||||
// subframe data.
|
||||
frame->ForEachRenderFrameHostWithAction(
|
||||
frame->ForEachRenderFrameHostImplWithAction(
|
||||
[web_contents, outermost_frame = frame, type,
|
||||
&all_frame_info](RenderFrameHostImpl* rfh) {
|
||||
// We've already handled the outermost frame outside of this.
|
||||
@ -318,7 +318,7 @@ void ProcessInternalsHandlerImpl::GetAllWebContentsInfo(
|
||||
}
|
||||
|
||||
// Retrieve prerendering root frames.
|
||||
web_contents->ForEachRenderFrameHost(
|
||||
web_contents->ForEachRenderFrameHostImpl(
|
||||
[web_contents, &prerender_root_frames = info->prerender_root_frames](
|
||||
RenderFrameHostImpl* rfh) {
|
||||
CollectPrerenders(web_contents, rfh, prerender_root_frames);
|
||||
|
@ -1154,7 +1154,7 @@ BackForwardCacheImpl::NotRestoredReasonBuilder::NotRestoredReasonBuilder(
|
||||
// Populate the reasons and build the tree.
|
||||
std::map<RenderFrameHostImpl*, BackForwardCacheCanStoreTreeResult*>
|
||||
parent_map;
|
||||
root_rfh_->ForEachRenderFrameHost([&](RenderFrameHostImpl* rfh) {
|
||||
root_rfh_->ForEachRenderFrameHostImpl([&](RenderFrameHostImpl* rfh) {
|
||||
auto rfh_result = PopulateReasons(rfh);
|
||||
parent_map[rfh] = rfh_result.get();
|
||||
|
||||
@ -1632,7 +1632,7 @@ bool BackForwardCacheImpl::
|
||||
if (entry->render_frame_host()->is_evicted_from_back_forward_cache()) {
|
||||
continue;
|
||||
}
|
||||
entry->render_frame_host()->ForEachRenderFrameHostWithAction(
|
||||
entry->render_frame_host()->ForEachRenderFrameHostImplWithAction(
|
||||
[&found, site_instance_group_id](RenderFrameHostImpl* rfh) {
|
||||
if (rfh->GetSiteInstance()->group()->GetId() ==
|
||||
site_instance_group_id) {
|
||||
|
@ -6398,7 +6398,7 @@ void NavigationRequest::CommitPageActivation() {
|
||||
// since the page entered bfcache. We must update all frames, not just the
|
||||
// top frame, because it is possible (though unlikely) that an iframe's
|
||||
// entries have changed, too.
|
||||
activated_entry->render_frame_host()->ForEachRenderFrameHostWithAction(
|
||||
activated_entry->render_frame_host()->ForEachRenderFrameHostImplWithAction(
|
||||
[this, &activated_entry](RenderFrameHostImpl* rfh) {
|
||||
// |this| is given as a parameter to
|
||||
// GetNavigationApiHistoryEntryVectors() only for the frame being
|
||||
@ -6507,8 +6507,8 @@ void NavigationRequest::CommitPageActivation() {
|
||||
|
||||
// Update navigation API entries. A prerendered page has only a single
|
||||
// history entry, but now it has access to a full back/forward list.
|
||||
rfh->ForEachRenderFrameHostWithAction([this, &stored_page](
|
||||
RenderFrameHostImpl* rfh) {
|
||||
rfh->ForEachRenderFrameHostImplWithAction([this, &stored_page](
|
||||
RenderFrameHostImpl* rfh) {
|
||||
// Currently, prerender activation only happens for DIFFERENT_DOCUMENT
|
||||
// navigations. If that ever changes, `reason` calculation will need to be
|
||||
// updated (and new NavigationApiEntryRestoreReason values added).
|
||||
|
@ -253,7 +253,7 @@ void PageImpl::Activate(
|
||||
}
|
||||
|
||||
// Prepare each RenderFrameHostImpl in this Page for activation.
|
||||
main_document_->ForEachRenderFrameHostIncludingSpeculative(
|
||||
main_document_->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[](RenderFrameHostImpl* rfh) {
|
||||
rfh->RendererWillActivateForPrerenderingOrPreview();
|
||||
});
|
||||
@ -276,7 +276,7 @@ void PageImpl::MaybeDispatchLoadEventsOnPrerenderActivation() {
|
||||
main_document_->MainDocumentElementAvailable(uses_temporary_zoom_level());
|
||||
}
|
||||
|
||||
main_document_->ForEachRenderFrameHost(
|
||||
main_document_->ForEachRenderFrameHostImpl(
|
||||
&RenderFrameHostImpl::MaybeDispatchDOMContentLoadedOnPrerenderActivation);
|
||||
|
||||
if (is_on_load_completed_in_main_document()) {
|
||||
@ -287,7 +287,7 @@ void PageImpl::MaybeDispatchLoadEventsOnPrerenderActivation() {
|
||||
main_document_->OnFirstContentfulPaint();
|
||||
}
|
||||
|
||||
main_document_->ForEachRenderFrameHost(
|
||||
main_document_->ForEachRenderFrameHostImpl(
|
||||
&RenderFrameHostImpl::MaybeDispatchDidFinishLoadOnPrerenderActivation);
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ void PageImpl::DidActivateAllRenderViewsForPrerenderingOrPreview(
|
||||
"PageImpl::DidActivateAllRenderViewsForPrerendering");
|
||||
|
||||
// Tell each RenderFrameHostImpl in this Page that activation finished.
|
||||
main_document_->ForEachRenderFrameHostIncludingSpeculative(
|
||||
main_document_->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[this](RenderFrameHostImpl* rfh) {
|
||||
if (&rfh->GetPage() != this) {
|
||||
return;
|
||||
|
@ -145,9 +145,10 @@ void RenderFrameHostAndroid::GetCanonicalUrlForSharing(
|
||||
std::vector<ScopedJavaLocalRef<jobject>>
|
||||
RenderFrameHostAndroid::GetAllRenderFrameHosts(JNIEnv* env) const {
|
||||
std::vector<ScopedJavaLocalRef<jobject>> ret;
|
||||
render_frame_host_->ForEachRenderFrameHost([&ret](RenderFrameHostImpl* rfh) {
|
||||
ret.push_back(rfh->GetJavaRenderFrameHost());
|
||||
});
|
||||
render_frame_host_->ForEachRenderFrameHostImpl(
|
||||
[&ret](RenderFrameHostImpl* rfh) {
|
||||
ret.push_back(rfh->GetJavaRenderFrameHost());
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2688,37 +2688,39 @@ bool RenderFrameHostImpl::IsUntrustedNetworkDisabled() const {
|
||||
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHost*)> on_frame) {
|
||||
ForEachRenderFrameHostWithAction(
|
||||
ForEachRenderFrameHostImplWithAction(
|
||||
[on_frame](RenderFrameHostImpl* rfh) { return on_frame(rfh); });
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHost(
|
||||
base::FunctionRef<void(RenderFrameHost*)> on_frame) {
|
||||
ForEachRenderFrameHost(
|
||||
ForEachRenderFrameHostImpl(
|
||||
[on_frame](RenderFrameHostImpl* rfh) { on_frame(rfh); });
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostWithAction(
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostImplWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostImpl(on_frame, /*include_speculative=*/false);
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHost(
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostImpl(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostWithAction([on_frame](RenderFrameHostImpl* rfh) {
|
||||
ForEachRenderFrameHostImplWithAction([on_frame](RenderFrameHostImpl* rfh) {
|
||||
on_frame(rfh);
|
||||
return FrameIterationAction::kContinue;
|
||||
});
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame) {
|
||||
void RenderFrameHostImpl::
|
||||
ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)>
|
||||
on_frame) {
|
||||
ForEachRenderFrameHostImpl(on_frame, /*include_speculative=*/true);
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostIncludingSpeculative(
|
||||
void RenderFrameHostImpl::ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[on_frame](RenderFrameHostImpl* rfh) {
|
||||
on_frame(rfh);
|
||||
return FrameIterationAction::kContinue;
|
||||
@ -2755,7 +2757,7 @@ void RenderFrameHostImpl::ForEachRenderFrameHostImpl(
|
||||
// only if |this| is current in its FrameTree.
|
||||
// TODO(crbug.com/40203236): Avoid having a RenderFrameHost access its
|
||||
// FrameTreeNode's speculative RenderFrameHost by moving
|
||||
// ForEachRenderFrameHostIncludingSpeculative from RenderFrameHostImpl or
|
||||
// ForEachRenderFrameHostImplIncludingSpeculative from RenderFrameHostImpl or
|
||||
// possibly removing it entirely.
|
||||
if (include_speculative && frame_tree_node()->current_frame_host() == this) {
|
||||
RenderFrameHostImpl* speculative_frame_host =
|
||||
@ -5621,7 +5623,7 @@ void RenderFrameHostImpl::DidCommitPageActivation(
|
||||
//
|
||||
// Note that due to PrerenderCommitDeferringCondition, the main frame should
|
||||
// have no ongoing NavigationRequest at all, so it is not checked here.
|
||||
ForEachRenderFrameHost([](RenderFrameHostImpl* rfh) {
|
||||
ForEachRenderFrameHostImpl([](RenderFrameHostImpl* rfh) {
|
||||
// Interested only in subframes.
|
||||
if (rfh->is_main_frame())
|
||||
return;
|
||||
@ -11033,7 +11035,7 @@ bool RenderFrameHostImpl::CheckOrDispatchBeforeUnloadForSubtree(
|
||||
bool found_beforeunload = false;
|
||||
bool run_beforeunload_for_legacy = false;
|
||||
|
||||
ForEachRenderFrameHostWithAction(
|
||||
ForEachRenderFrameHostImplWithAction(
|
||||
[this, subframes_only, send_ipc, is_reload, &found_beforeunload,
|
||||
&run_beforeunload_for_legacy](
|
||||
RenderFrameHostImpl* rfh) -> FrameIterationAction {
|
||||
@ -11388,8 +11390,9 @@ bool RenderFrameHostImpl::is_initial_empty_document() const {
|
||||
uint32_t RenderFrameHostImpl::FindSuddenTerminationHandlers(bool same_origin) {
|
||||
uint32_t navigation_termination = 0;
|
||||
// Search this frame and subframes for sudden termination disablers
|
||||
ForEachRenderFrameHostWithAction([this, same_origin, &navigation_termination](
|
||||
RenderFrameHost* rfh) {
|
||||
ForEachRenderFrameHostImplWithAction([this, same_origin,
|
||||
&navigation_termination](
|
||||
RenderFrameHostImpl* rfh) {
|
||||
if (same_origin &&
|
||||
GetLastCommittedOrigin() != rfh->GetLastCommittedOrigin()) {
|
||||
return FrameIterationAction::kSkipChildren;
|
||||
@ -13821,13 +13824,14 @@ service_manager::InterfaceProvider* RenderFrameHostImpl::GetJavaInterfaces() {
|
||||
|
||||
void RenderFrameHostImpl::ForEachImmediateLocalRoot(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> func_ref) {
|
||||
ForEachRenderFrameHostWithAction([func_ref, this](RenderFrameHostImpl* rfh) {
|
||||
if (rfh->is_local_root() && rfh != this) {
|
||||
func_ref(rfh);
|
||||
return FrameIterationAction::kSkipChildren;
|
||||
}
|
||||
return FrameIterationAction::kContinue;
|
||||
});
|
||||
ForEachRenderFrameHostImplWithAction(
|
||||
[func_ref, this](RenderFrameHostImpl* rfh) {
|
||||
if (rfh->is_local_root() && rfh != this) {
|
||||
func_ref(rfh);
|
||||
return FrameIterationAction::kSkipChildren;
|
||||
}
|
||||
return FrameIterationAction::kContinue;
|
||||
});
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::SetVisibilityForChildViews(bool visible) {
|
||||
|
@ -2330,17 +2330,17 @@ class CONTENT_EXPORT RenderFrameHostImpl
|
||||
}
|
||||
|
||||
// These are the content internal equivalents of
|
||||
// |RenderFrameHost::ForEachRenderFrameHost| whose comment can be referred to
|
||||
// `RenderFrameHost::ForEachRenderFrameHost` whose comment can be referred to
|
||||
// for details. Content internals can also access speculative
|
||||
// RenderFrameHostImpls if necessary by using the
|
||||
// |ForEachRenderFrameHostIncludingSpeculative| variations.
|
||||
void ForEachRenderFrameHostWithAction(
|
||||
// `ForEachRenderFrameHostImplIncludingSpeculative` variations.
|
||||
void ForEachRenderFrameHostImplWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame);
|
||||
void ForEachRenderFrameHost(
|
||||
void ForEachRenderFrameHostImpl(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame);
|
||||
void ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
void ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame);
|
||||
void ForEachRenderFrameHostIncludingSpeculative(
|
||||
void ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame);
|
||||
|
||||
bool DocumentUsedWebOTP() override;
|
||||
|
@ -706,7 +706,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
EXPECT_TRUE(ExecJs(web_contents(), script));
|
||||
EXPECT_TRUE(WaitForLoadStop(web_contents()));
|
||||
// JavaScript onbeforeunload dialogs require a user gesture.
|
||||
web_contents()->GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
web_contents()->GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[](content::RenderFrameHostImpl* render_frame_host) {
|
||||
render_frame_host->ExecuteJavaScriptWithUserGestureForTests(
|
||||
std::u16string(), base::NullCallback(), ISOLATED_WORLD_ID_GLOBAL);
|
||||
@ -6121,9 +6121,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplSubframeReuseBrowserTest,
|
||||
EXPECT_FALSE(process->IsProcessShutdownDelayedForTesting());
|
||||
}
|
||||
|
||||
// Tests that RenderFrameHost::ForEachRenderFrameHost visits the correct frames
|
||||
// in the correct order.
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ForEachRenderFrameHost) {
|
||||
// Tests that RenderFrameHostImpl::ForEachRenderFrameHostImpl visits the correct
|
||||
// frames in the correct order.
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostImpl) {
|
||||
GURL url_a(embedded_test_server()->GetURL(
|
||||
"a.com", "/cross_site_iframe_factory.html?a(b(c),d)"));
|
||||
|
||||
@ -6146,7 +6147,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ForEachRenderFrameHost) {
|
||||
// Test that iteration stops when requested.
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_a->ForEachRenderFrameHostWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
rfh_a->ForEachRenderFrameHostImplWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return RenderFrameHost::FrameIterationAction::kStop;
|
||||
});
|
||||
@ -6154,7 +6155,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ForEachRenderFrameHost) {
|
||||
}
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_a->ForEachRenderFrameHostWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
rfh_a->ForEachRenderFrameHostImplWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return RenderFrameHost::FrameIterationAction::kSkipChildren;
|
||||
});
|
||||
@ -6166,7 +6167,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ForEachRenderFrameHost) {
|
||||
// |rfh_c| and |rfh_d|.
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_a->ForEachRenderFrameHostWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
rfh_a->ForEachRenderFrameHostImplWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return rfh == rfh_b ? RenderFrameHost::FrameIterationAction::kStop
|
||||
: RenderFrameHost::FrameIterationAction::kContinue;
|
||||
@ -6175,7 +6176,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ForEachRenderFrameHost) {
|
||||
}
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_a->ForEachRenderFrameHostWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
rfh_a->ForEachRenderFrameHostImplWithAction([&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return rfh == rfh_b ? RenderFrameHost::FrameIterationAction::kSkipChildren
|
||||
: RenderFrameHost::FrameIterationAction::kContinue;
|
||||
@ -6197,10 +6198,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ForEachRenderFrameHost) {
|
||||
EXPECT_EQ(rfh_a, rfh_d->GetOutermostMainFrameOrEmbedder());
|
||||
}
|
||||
|
||||
// Tests that RenderFrameHost::ForEachRenderFrameHost does not expose
|
||||
// Tests that RenderFrameHostImpl::ForEachRenderFrameHostImpl does not expose
|
||||
// speculative RFHs, unless content internal code requests them.
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostSpeculative) {
|
||||
ForEachRenderFrameHostImplSpeculative) {
|
||||
IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
|
||||
GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
|
||||
GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));
|
||||
@ -6222,7 +6223,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
// pending commit lifecycle state of |rfh_b|.
|
||||
base::RepeatingClosure test_expectations = base::BindRepeating(
|
||||
[](RenderFrameHostImpl* rfh_a, RenderFrameHostImpl* rfh_b) {
|
||||
// ForEachRenderFrameHost does not expose the speculative RFH.
|
||||
// ForEachRenderFrameHostImpl does not expose the speculative RFH.
|
||||
EXPECT_THAT(CollectAllRenderFrameHosts(rfh_a),
|
||||
testing::ElementsAre(rfh_a));
|
||||
|
||||
@ -6230,12 +6231,13 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
EXPECT_THAT(CollectAllRenderFrameHostsIncludingSpeculative(rfh_a),
|
||||
testing::UnorderedElementsAre(rfh_a, rfh_b));
|
||||
|
||||
// If ForEachRenderFrameHost is called on a speculative RFH directly, do
|
||||
// nothing.
|
||||
rfh_b->ForEachRenderFrameHostWithAction([](RenderFrameHostImpl* rfh) {
|
||||
ADD_FAILURE() << "Visited speculative RFH";
|
||||
return RenderFrameHost::FrameIterationAction::kStop;
|
||||
});
|
||||
// If ForEachRenderFrameHostImpl is called on a speculative RFH
|
||||
// directly, do nothing.
|
||||
rfh_b->ForEachRenderFrameHostImplWithAction(
|
||||
[](RenderFrameHostImpl* rfh) {
|
||||
ADD_FAILURE() << "Visited speculative RFH";
|
||||
return RenderFrameHost::FrameIterationAction::kStop;
|
||||
});
|
||||
|
||||
// If we request speculative RFHs and directly call this on a
|
||||
// speculative RFH, just visit the given speculative RFH.
|
||||
@ -6275,10 +6277,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ASSERT_TRUE(nav_manager.WaitForNavigationFinished());
|
||||
}
|
||||
|
||||
// Like ForEachRenderFrameHostSpeculative, but for a speculative RFH for a
|
||||
// Like ForEachRenderFrameHostImplSpeculative, but for a speculative RFH for a
|
||||
// subframe navigation.
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostSpeculativeWithSubframes) {
|
||||
ForEachRenderFrameHostImplSpeculativeWithSubframes) {
|
||||
IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
|
||||
GURL url_a(embedded_test_server()->GetURL(
|
||||
"a.com", "/cross_site_iframe_factory.html?a(b(c))"));
|
||||
@ -6301,7 +6303,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ASSERT_TRUE(rfh_d);
|
||||
EXPECT_EQ(LifecycleStateImpl::kSpeculative, rfh_d->lifecycle_state());
|
||||
|
||||
// ForEachRenderFrameHost does not expose the speculative RFH.
|
||||
// ForEachRenderFrameHostImpl does not expose the speculative RFH.
|
||||
EXPECT_THAT(CollectAllRenderFrameHosts(rfh_a),
|
||||
testing::ElementsAre(rfh_a, rfh_b, rfh_c));
|
||||
|
||||
@ -6314,9 +6316,9 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
EXPECT_THAT(CollectAllRenderFrameHostsIncludingSpeculative(rfh_b),
|
||||
testing::UnorderedElementsAre(rfh_b, rfh_d, rfh_c));
|
||||
|
||||
// If ForEachRenderFrameHost is called on a speculative RFH directly, do
|
||||
// If ForEachRenderFrameHostImpl is called on a speculative RFH directly, do
|
||||
// nothing.
|
||||
rfh_d->ForEachRenderFrameHostWithAction([](RenderFrameHostImpl* rfh) {
|
||||
rfh_d->ForEachRenderFrameHostImplWithAction([](RenderFrameHostImpl* rfh) {
|
||||
ADD_FAILURE() << "Visited speculative RFH";
|
||||
return RenderFrameHost::FrameIterationAction::kStop;
|
||||
});
|
||||
@ -6331,7 +6333,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
// We don't check the RFHs visited in the interest of not overtesting the
|
||||
// ordering of speculative RFHs.
|
||||
bool stopped = false;
|
||||
rfh_a->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh_a->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
EXPECT_FALSE(stopped);
|
||||
if (rfh->lifecycle_state() == LifecycleStateImpl::kSpeculative) {
|
||||
@ -6344,7 +6346,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
|
||||
{
|
||||
bool stopped = false;
|
||||
rfh_b->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh_b->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
EXPECT_FALSE(stopped);
|
||||
if (rfh->lifecycle_state() == LifecycleStateImpl::kSpeculative) {
|
||||
@ -6359,7 +6361,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
// speculative RFH skips the children but still includes the speculative RFH.
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_a->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh_a->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return (rfh == rfh_b)
|
||||
@ -6372,7 +6374,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_b->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh_b->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return (rfh == rfh_b)
|
||||
@ -6386,7 +6388,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
// here for completeness of testing.
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_a->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh_a->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return (rfh->lifecycle_state() == LifecycleStateImpl::kSpeculative)
|
||||
@ -6399,7 +6401,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
|
||||
{
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
rfh_b->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh_b->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
visited_frames.push_back(rfh);
|
||||
return (rfh->lifecycle_state() == LifecycleStateImpl::kSpeculative)
|
||||
@ -6412,7 +6414,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostPendingDeletion) {
|
||||
ForEachRenderFrameHostImplPendingDeletion) {
|
||||
GURL url_a(embedded_test_server()->GetURL(
|
||||
"a.com", "/cross_site_iframe_factory.html?a(b(c))"));
|
||||
GURL url_d(embedded_test_server()->GetURL("d.com", "/title1.html"));
|
||||
@ -6431,22 +6433,22 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
EXPECT_TRUE(NavigateToURL(shell(), url_d));
|
||||
RenderFrameHostImpl* rfh_d = root_frame_host();
|
||||
|
||||
// ForEachRenderFrameHost on the primary RFH does not visit the pending delete
|
||||
// RFHs.
|
||||
// ForEachRenderFrameHostImpl on the primary RFH does not visit the pending
|
||||
// delete RFHs.
|
||||
EXPECT_THAT(CollectAllRenderFrameHosts(rfh_d), testing::ElementsAre(rfh_d));
|
||||
|
||||
// ForEachRenderFrameHost on the pending delete RFHs only visits the pending
|
||||
// delete RFHs.
|
||||
// ForEachRenderFrameHostImpl on the pending delete RFHs only visits the
|
||||
// pendingdelete RFHs.
|
||||
EXPECT_THAT(CollectAllRenderFrameHosts(rfh_a),
|
||||
testing::ElementsAre(rfh_a, rfh_b, rfh_c));
|
||||
EXPECT_THAT(CollectAllRenderFrameHosts(rfh_b),
|
||||
testing::ElementsAre(rfh_b, rfh_c));
|
||||
}
|
||||
|
||||
// Tests that RenderFrameHost::ForEachRenderFrameHost visits the frames of an
|
||||
// inner WebContents.
|
||||
// Tests that RenderFrameHostImpl::ForEachRenderFrameHostImpl visits the frames
|
||||
// of an inner WebContents.
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostInnerContents) {
|
||||
ForEachRenderFrameHostImplInnerContents) {
|
||||
GURL url_a(embedded_test_server()->GetURL("a.com", "/page_with_iframe.html"));
|
||||
GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));
|
||||
|
||||
@ -6470,7 +6472,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostInnerContentsWithSubframes) {
|
||||
ForEachRenderFrameHostImplInnerContentsWithSubframes) {
|
||||
GURL url_a(embedded_test_server()->GetURL(
|
||||
"a.com", "/cross_site_iframe_factory.html?a(a(a),a)"));
|
||||
GURL url_b(embedded_test_server()->GetURL(
|
||||
@ -6498,7 +6500,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
|
||||
ForEachRenderFrameHostMultipleInnerContents) {
|
||||
ForEachRenderFrameHostImplMultipleInnerContents) {
|
||||
// After attaching inner contents, this will be A(B(C),D)
|
||||
GURL url_a(embedded_test_server()->GetURL(
|
||||
"a.com", "/cross_site_iframe_factory.html?a(a,a)"));
|
||||
|
@ -328,7 +328,7 @@ void ReuseDefaultProcessFromDifferentBrowsingInstanceIfPossible(
|
||||
DCHECK(!new_instance->RequiresDedicatedProcess());
|
||||
DCHECK(!new_instance->HasProcess());
|
||||
RenderFrameHostImpl* root = rfh->GetOutermostMainFrame();
|
||||
root->ForEachRenderFrameHostWithAction(
|
||||
root->ForEachRenderFrameHostImplWithAction(
|
||||
[site_instance = std::move(new_instance),
|
||||
root](RenderFrameHostImpl* rfhi) {
|
||||
if (rfhi->GetParent())
|
||||
@ -1020,21 +1020,23 @@ void RenderFrameHostManager::PrepareForCollectingPage(
|
||||
TRACE_EVENT("navigation", "RenderFrameHostManager::PrepareForCollectingPage");
|
||||
|
||||
// We insert RenderViewHosts for all frames.
|
||||
main_render_frame_host->ForEachRenderFrameHost([&](RenderFrameHostImpl* rfh) {
|
||||
render_view_hosts->insert(rfh->render_view_host()->GetSafeRef());
|
||||
if (rfh->is_main_frame()) {
|
||||
for (auto& it : rfh->browsing_context_state()->proxy_hosts()) {
|
||||
// This avoids including the proxy created when starting a
|
||||
// new cross-process, cross-BrowsingInstance navigation, as well as any
|
||||
// restored proxies which are also in a different BrowsingInstance.
|
||||
if (rfh->GetSiteInstance()->group()->IsRelatedSiteInstanceGroup(
|
||||
it.second->site_instance_group())) {
|
||||
render_view_hosts->insert(
|
||||
it.second->GetRenderViewHost()->GetSafeRef());
|
||||
main_render_frame_host->ForEachRenderFrameHostImpl(
|
||||
[&](RenderFrameHostImpl* rfh) {
|
||||
render_view_hosts->insert(rfh->render_view_host()->GetSafeRef());
|
||||
if (rfh->is_main_frame()) {
|
||||
for (auto& it : rfh->browsing_context_state()->proxy_hosts()) {
|
||||
// This avoids including the proxy created when starting a
|
||||
// new cross-process, cross-BrowsingInstance navigation, as well as
|
||||
// any restored proxies which are also in a different
|
||||
// BrowsingInstance.
|
||||
if (rfh->GetSiteInstance()->group()->IsRelatedSiteInstanceGroup(
|
||||
it.second->site_instance_group())) {
|
||||
render_view_hosts->insert(
|
||||
it.second->GetRenderViewHost()->GetSafeRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// When BrowsingContextState is decoupled from the FrameTreeNode and
|
||||
// RenderFrameHostManager (legacy mode is disabled), proxies and
|
||||
|
@ -374,7 +374,7 @@ ScopedJavaLocalRef<jobject> WebContentsAndroid::GetRenderFrameHostFromId(
|
||||
ScopedJavaLocalRef<jobjectArray> WebContentsAndroid::GetAllRenderFrameHosts(
|
||||
JNIEnv* env) const {
|
||||
std::vector<RenderFrameHost*> frames;
|
||||
web_contents_->ForEachRenderFrameHost(
|
||||
web_contents_->ForEachRenderFrameHostImpl(
|
||||
[&frames](RenderFrameHostImpl* rfh) { frames.push_back(rfh); });
|
||||
ScopedJavaLocalRef<jobjectArray> jframes =
|
||||
Java_WebContentsImpl_createRenderFrameHostArray(env, frames.size());
|
||||
|
@ -1801,37 +1801,37 @@ RenderFrameHostImpl* WebContentsImpl::UnsafeFindFrameByFrameTreeNodeId(
|
||||
|
||||
void WebContentsImpl::ForEachRenderFrameHostWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHost*)> on_frame) {
|
||||
ForEachRenderFrameHostWithAction(
|
||||
ForEachRenderFrameHostImplWithAction(
|
||||
[on_frame](RenderFrameHostImpl* rfh) { return on_frame(rfh); });
|
||||
}
|
||||
|
||||
void WebContentsImpl::ForEachRenderFrameHost(
|
||||
base::FunctionRef<void(RenderFrameHost*)> on_frame) {
|
||||
ForEachRenderFrameHost(
|
||||
ForEachRenderFrameHostImpl(
|
||||
[on_frame](RenderFrameHostImpl* rfh) { on_frame(rfh); });
|
||||
}
|
||||
|
||||
void WebContentsImpl::ForEachRenderFrameHostWithAction(
|
||||
void WebContentsImpl::ForEachRenderFrameHostImplWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostImpl(on_frame, /* include_speculative */ false);
|
||||
}
|
||||
|
||||
void WebContentsImpl::ForEachRenderFrameHost(
|
||||
void WebContentsImpl::ForEachRenderFrameHostImpl(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostWithAction([on_frame](RenderFrameHostImpl* rfh) {
|
||||
ForEachRenderFrameHostImplWithAction([on_frame](RenderFrameHostImpl* rfh) {
|
||||
on_frame(rfh);
|
||||
return FrameIterationAction::kContinue;
|
||||
});
|
||||
}
|
||||
|
||||
void WebContentsImpl::ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
void WebContentsImpl::ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostImpl(on_frame, /* include_speculative */ true);
|
||||
}
|
||||
|
||||
void WebContentsImpl::ForEachRenderFrameHostIncludingSpeculative(
|
||||
void WebContentsImpl::ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame) {
|
||||
ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[on_frame](RenderFrameHostImpl* rfh) {
|
||||
on_frame(rfh);
|
||||
return FrameIterationAction::kContinue;
|
||||
@ -1841,12 +1841,12 @@ void WebContentsImpl::ForEachRenderFrameHostIncludingSpeculative(
|
||||
void WebContentsImpl::ForEachRenderFrameHostImpl(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame,
|
||||
bool include_speculative) {
|
||||
// Since |RenderFrameHostImpl::ForEachRenderFrameHost| will reach the
|
||||
// Since `RenderFrameHostImpl::ForEachRenderFrameHostImpl` will reach the
|
||||
// RenderFrameHosts descending from a specified root, it is enough to start
|
||||
// iteration from each of the outermost main frames to reach everything in
|
||||
// this WebContents. However, if iteration stops early in
|
||||
// |RenderFrameHostImpl::ForEachRenderFrameHost|, we also need to stop early
|
||||
// by not iterating over additional outermost main frames.
|
||||
// `RenderFrameHostImpl::ForEachRenderFrameHostImpl`, we also need to stop
|
||||
// early by not iterating over additional outermost main frames.
|
||||
bool iteration_stopped = false;
|
||||
auto on_frame_with_termination =
|
||||
[on_frame, &iteration_stopped](RenderFrameHostImpl* rfh) {
|
||||
@ -1859,10 +1859,10 @@ void WebContentsImpl::ForEachRenderFrameHostImpl(
|
||||
|
||||
for (auto* rfh : GetOutermostMainFrames()) {
|
||||
if (include_speculative) {
|
||||
rfh->ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
rfh->ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
on_frame_with_termination);
|
||||
} else {
|
||||
rfh->ForEachRenderFrameHostWithAction(on_frame_with_termination);
|
||||
rfh->ForEachRenderFrameHostImplWithAction(on_frame_with_termination);
|
||||
}
|
||||
|
||||
if (iteration_stopped) {
|
||||
@ -2088,7 +2088,7 @@ void WebContentsImpl::SetAccessibilityMode(ui::AXMode mode) {
|
||||
// WebContents (via CreateScopedModeForWebContents), it is the responsibility
|
||||
// of the owner of the ScopedAccessibilityMode to choose whether or not to
|
||||
// create scopers for inner WebContents.
|
||||
ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[this](RenderFrameHostImpl* frame_host) {
|
||||
if (WebContentsImpl::FromRenderFrameHostImpl(frame_host) == this) {
|
||||
frame_host->UpdateAccessibilityMode();
|
||||
@ -2108,7 +2108,7 @@ void WebContentsImpl::ResetAccessibility() {
|
||||
// Reset accessibility for all frames in this tree and inner trees, including
|
||||
// speculative frame hosts and those in the back-forward cache. See comment in
|
||||
// `SetAccessibilityMode()` for more details.
|
||||
ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
[this](RenderFrameHostImpl* frame_host) {
|
||||
if (WebContentsImpl::FromRenderFrameHostImpl(frame_host) == this) {
|
||||
frame_host->AccessibilityReset();
|
||||
@ -2186,7 +2186,7 @@ void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback,
|
||||
|
||||
auto combiner = base::MakeRefCounted<AXTreeSnapshotCombiner>(
|
||||
std::move(callback), std::move(params));
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHostWithAction(
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHostImplWithAction(
|
||||
[this, &combiner, policy](RenderFrameHostImpl* rfh) {
|
||||
switch (policy) {
|
||||
case AXTreeSnapshotPolicy::kAll:
|
||||
@ -3948,12 +3948,13 @@ void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) {
|
||||
std::set<RenderWidgetHostViewBase*>
|
||||
WebContentsImpl::GetRenderWidgetHostViewsInWebContentsTree() {
|
||||
std::set<RenderWidgetHostViewBase*> result;
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHost([&result](
|
||||
RenderFrameHostImpl* rfh) {
|
||||
if (auto* view = static_cast<RenderWidgetHostViewBase*>(rfh->GetView())) {
|
||||
result.insert(view);
|
||||
}
|
||||
});
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[&result](RenderFrameHostImpl* rfh) {
|
||||
if (auto* view =
|
||||
static_cast<RenderWidgetHostViewBase*>(rfh->GetView())) {
|
||||
result.insert(view);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -5610,7 +5611,7 @@ void WebContentsImpl::SendScreenRects() {
|
||||
|
||||
DCHECK(!IsBeingDestroyed());
|
||||
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[](RenderFrameHostImpl* render_frame_host) {
|
||||
if (render_frame_host->is_local_root()) {
|
||||
render_frame_host->GetRenderWidgetHost()->SendScreenRects();
|
||||
@ -5622,7 +5623,7 @@ void WebContentsImpl::SendActiveState(bool active) {
|
||||
DCHECK(!IsBeingDestroyed());
|
||||
|
||||
// Replicate the active state to all LocalRoots.
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[active](RenderFrameHostImpl* render_frame_host) {
|
||||
if (render_frame_host->is_local_root()) {
|
||||
render_frame_host->GetRenderWidgetHost()->SetActive(active);
|
||||
@ -8963,7 +8964,7 @@ void WebContentsImpl::DidStopLoading() {
|
||||
SCOPED_UMA_HISTOGRAM_TIMER("WebContentsObserver.DidStopLoading");
|
||||
observers_.NotifyObservers(&WebContentsObserver::DidStopLoading);
|
||||
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHost(
|
||||
GetPrimaryMainFrame()->ForEachRenderFrameHostImpl(
|
||||
[](RenderFrameHostImpl* render_frame_host) {
|
||||
ui::BrowserAccessibilityManager* manager =
|
||||
render_frame_host->browser_accessibility_manager();
|
||||
|
@ -1473,17 +1473,17 @@ class CONTENT_EXPORT WebContentsImpl
|
||||
void SystemDragEnded(RenderWidgetHost* source_rwh);
|
||||
|
||||
// These are the content internal equivalents of
|
||||
// |WebContents::ForEachRenderFrameHost| whose comment can be referred to
|
||||
// `WebContents::ForEachRenderFrameHost` whose comment can be referred to
|
||||
// for details. Content internals can also access speculative
|
||||
// RenderFrameHostImpls if necessary by using the
|
||||
// |ForEachRenderFrameHostIncludingSpeculative| variations.
|
||||
void ForEachRenderFrameHostWithAction(
|
||||
// `ForEachRenderFrameHostImplIncludingSpeculative` variations.
|
||||
void ForEachRenderFrameHostImplWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame);
|
||||
void ForEachRenderFrameHost(
|
||||
void ForEachRenderFrameHostImpl(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame);
|
||||
void ForEachRenderFrameHostIncludingSpeculativeWithAction(
|
||||
void ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
|
||||
base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame);
|
||||
void ForEachRenderFrameHostIncludingSpeculative(
|
||||
void ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
base::FunctionRef<void(RenderFrameHostImpl*)> on_frame);
|
||||
|
||||
// Computes and returns the content specific preferences for this WebContents.
|
||||
@ -1646,7 +1646,7 @@ class CONTENT_EXPORT WebContentsImpl
|
||||
FRIEND_TEST_ALL_PREFIXES(
|
||||
PrerenderWithRenderDocumentBrowserTest,
|
||||
ModalDialogShouldNotBeDismissedAfterPrerenderSubframeNavigation);
|
||||
FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest, ForEachRenderFrameHost);
|
||||
FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest, ForEachRenderFrameHostImpl);
|
||||
FRIEND_TEST_ALL_PREFIXES(PluginContentOriginAllowlistTest,
|
||||
ClearAllowlistOnNavigate);
|
||||
FRIEND_TEST_ALL_PREFIXES(PluginContentOriginAllowlistTest,
|
||||
|
@ -219,7 +219,7 @@ RenderFrameHost* CreateSubframe(RenderFrameHost* parent,
|
||||
std::vector<RenderFrameHostImpl*> CollectAllRenderFrameHosts(
|
||||
RenderFrameHostImpl* starting_rfh) {
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
starting_rfh->ForEachRenderFrameHost(
|
||||
starting_rfh->ForEachRenderFrameHostImpl(
|
||||
[&](RenderFrameHostImpl* rfh) { visited_frames.push_back(rfh); });
|
||||
return visited_frames;
|
||||
}
|
||||
@ -228,7 +228,7 @@ std::vector<RenderFrameHostImpl*>
|
||||
CollectAllRenderFrameHostsIncludingSpeculative(
|
||||
RenderFrameHostImpl* starting_rfh) {
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
starting_rfh->ForEachRenderFrameHostIncludingSpeculative(
|
||||
starting_rfh->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[&](RenderFrameHostImpl* rfh) { visited_frames.push_back(rfh); });
|
||||
return visited_frames;
|
||||
}
|
||||
@ -236,7 +236,7 @@ CollectAllRenderFrameHostsIncludingSpeculative(
|
||||
std::vector<RenderFrameHostImpl*> CollectAllRenderFrameHosts(
|
||||
WebContentsImpl* web_contents) {
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
web_contents->ForEachRenderFrameHost(
|
||||
web_contents->ForEachRenderFrameHostImpl(
|
||||
[&](RenderFrameHostImpl* rfh) { visited_frames.push_back(rfh); });
|
||||
return visited_frames;
|
||||
}
|
||||
@ -244,7 +244,7 @@ std::vector<RenderFrameHostImpl*> CollectAllRenderFrameHosts(
|
||||
std::vector<RenderFrameHostImpl*>
|
||||
CollectAllRenderFrameHostsIncludingSpeculative(WebContentsImpl* web_contents) {
|
||||
std::vector<RenderFrameHostImpl*> visited_frames;
|
||||
web_contents->ForEachRenderFrameHostIncludingSpeculative(
|
||||
web_contents->ForEachRenderFrameHostImplIncludingSpeculative(
|
||||
[&](RenderFrameHostImpl* rfh) { visited_frames.push_back(rfh); });
|
||||
return visited_frames;
|
||||
}
|
||||
|
Reference in New Issue
Block a user