0

Rename GetMainFrame to GetPrimaryMainFrame

Progressively rename some usages of GetMainFrame to GetPrimaryMainFrame.

This is an automated change via emacs xref integration via codesearch.

BUG=1250404

Change-Id: Ibb5ca2055776693b332e26d7b348b81d65d1900c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3692390
Owners-Override: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1011655}
This commit is contained in:
Dave Tapuska
2022-06-07 21:00:51 +00:00
committed by Chromium LUCI CQ
parent bb82f2779f
commit 88d7b2e743
184 changed files with 866 additions and 724 deletions
android_webview/browser
ash/webui/sample_system_web_app_ui
components
accuracy_tips
android_autofill
autofill
autofill_assistant
background_sync
blocked_content
browsing_topics
cdm
commerce
content_capture
content_settings
continuous_search
custom_handlers
digital_asset_links
dom_distiller
error_page
favicon
find_in_page
guest_view
javascript_dialogs
js_injection
metrics
no_state_prefetch
optimization_guide
page_info
page_load_metrics
paint_preview
password_manager
payments
pdf
performance_manager
permissions
renderer_context_menu
safe_browsing
security_interstitials
subresource_filter
translate
ukm
user_notes
webapps
zoom
extensions
fuchsia_web/webengine
headless/lib/browser
ui/views/controls/webview
weblayer/browser

@ -417,7 +417,7 @@ ScopedJavaLocalRef<jobject> AwContents::GetRenderProcess(
const JavaParamRef<jobject>& obj) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::RenderProcessHost* host =
web_contents_->GetMainFrame()->GetProcess();
web_contents_->GetPrimaryMainFrame()->GetProcess();
if (host->run_renderer_in_process()) {
return ScopedJavaLocalRef<jobject>();
}
@ -794,7 +794,7 @@ void AwContents::ClearCache(JNIEnv* env,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AwRenderProcess* aw_render_process =
AwRenderProcess::GetInstanceForRenderProcessHost(
web_contents_->GetMainFrame()->GetProcess());
web_contents_->GetPrimaryMainFrame()->GetProcess());
aw_render_process->ClearCache();
@ -1358,7 +1358,7 @@ void AwContents::InsertVisualStateCallback(
jlong request_id,
const JavaParamRef<jobject>& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
web_contents_->GetMainFrame()->InsertVisualStateCallback(
web_contents_->GetPrimaryMainFrame()->InsertVisualStateCallback(
base::BindOnce(&InvokeVisualStateCallback, java_ref_, request_id,
ScopedJavaGlobalRef<jobject>(env, callback)));
}
@ -1366,8 +1366,9 @@ void AwContents::InsertVisualStateCallback(
jint AwContents::GetEffectivePriority(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
switch (
web_contents_->GetMainFrame()->GetProcess()->GetEffectiveImportance()) {
switch (web_contents_->GetPrimaryMainFrame()
->GetProcess()
->GetEffectiveImportance()) {
case content::ChildProcessImportance::NORMAL:
return static_cast<jint>(RendererPriority::WAIVED);
case content::ChildProcessImportance::MODERATE:
@ -1480,7 +1481,7 @@ void AwContents::SetJsOnlineProperty(JNIEnv* env,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AwRenderProcess* aw_render_process =
AwRenderProcess::GetInstanceForRenderProcessHost(
web_contents_->GetMainFrame()->GetProcess());
web_contents_->GetPrimaryMainFrame()->GetProcess());
aw_render_process->SetJsOnlineProperty(network_up);
}
@ -1515,7 +1516,8 @@ void AwContents::GrantFileSchemeAccesstoChildProcess(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
content::ChildProcessSecurityPolicy::GetInstance()->GrantRequestScheme(
web_contents_->GetMainFrame()->GetProcess()->GetID(), url::kFileScheme);
web_contents_->GetPrimaryMainFrame()->GetProcess()->GetID(),
url::kFileScheme);
}
void AwContents::ResumeLoadingCreatedPopupWebContents(

@ -199,8 +199,8 @@ ClientMapEntryUpdater::ClientMapEntryUpdater(JNIEnv* env,
DCHECK(web_contents);
DCHECK(jdelegate);
if (web_contents->GetMainFrame())
RenderFrameCreated(web_contents->GetMainFrame());
if (web_contents->GetPrimaryMainFrame())
RenderFrameCreated(web_contents->GetPrimaryMainFrame());
}
void ClientMapEntryUpdater::RenderFrameCreated(RenderFrameHost* rfh) {

@ -63,7 +63,7 @@ void AwPrintManager::PdfWritingDone(int page_count) {
bool AwPrintManager::PrintNow() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* rfh = web_contents()->GetMainFrame();
auto* rfh = web_contents()->GetPrimaryMainFrame();
if (!rfh->IsRenderFrameLive())
return false;
GetPrintRenderFrame(rfh)->PrintRequestedPages();

@ -152,7 +152,7 @@ void AwRenderViewHostExt::UpdateHitTestData(
// Make sense from any frame of the current frame tree, because a focused
// node could be in either the mainframe or a subframe.
if (main_frame_host != web_contents()->GetMainFrame())
if (main_frame_host != web_contents()->GetPrimaryMainFrame())
return;
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@ -165,7 +165,7 @@ void AwRenderViewHostExt::ContentsSizeChanged(const gfx::Size& contents_size) {
frame_host_receivers_.GetCurrentTargetFrame();
// Only makes sense coming from the main frame of the current frame tree.
if (render_frame_host != web_contents()->GetMainFrame())
if (render_frame_host != web_contents()->GetPrimaryMainFrame())
return;
client_->OnWebLayoutContentsSizeChanged(contents_size);
@ -203,7 +203,7 @@ mojom::LocalMainFrame* AwRenderViewHostExt::GetLocalMainFrameRemote() {
// RenderFrameCreated/RenderFrameHostChanged events but the timings of when
// this class gets called vs others using this class might cause a TOU
// problem, so we validate it each time before use.
content::RenderFrameHost* main_frame = web_contents()->GetMainFrame();
content::RenderFrameHost* main_frame = web_contents()->GetPrimaryMainFrame();
content::GlobalRenderFrameHostId main_frame_id = main_frame->GetGlobalId();
if (main_frame_global_id_ == main_frame_id) {
return local_main_frame_remote_.get();

@ -58,7 +58,7 @@ void UntrustedSampleSystemWebAppUI::CreateParentPage(
mojo::PendingReceiver<mojom::sample_swa::ParentTrustedPage>
parent_trusted_page) {
// Find the parent frame's controller.
auto* chrome_frame = web_ui()->GetWebContents()->GetMainFrame();
auto* chrome_frame = web_ui()->GetWebContents()->GetPrimaryMainFrame();
if (!chrome_frame)
return;

@ -156,7 +156,8 @@ void AccuracyService::MaybeShowAccuracyTip(content::WebContents* web_contents) {
if (disable_ui_) {
return OnAccuracyTipClosed(
base::TimeTicks(), web_contents->GetMainFrame()->GetPageUkmSourceId(),
base::TimeTicks(),
web_contents->GetPrimaryMainFrame()->GetPageUkmSourceId(),
AccuracyTipInteraction::kDisabledByExperiment);
}
@ -171,9 +172,10 @@ void AccuracyService::MaybeShowAccuracyTip(content::WebContents* web_contents) {
delegate_->ShowAccuracyTip(
web_contents, AccuracyTipStatus::kShowAccuracyTip,
/*show_opt_out=*/show_opt_out,
base::BindOnce(&AccuracyService::OnAccuracyTipClosed,
weak_factory_.GetWeakPtr(), base::TimeTicks::Now(),
web_contents->GetMainFrame()->GetPageUkmSourceId()));
base::BindOnce(
&AccuracyService::OnAccuracyTipClosed, weak_factory_.GetWeakPtr(),
base::TimeTicks::Now(),
web_contents->GetPrimaryMainFrame()->GetPageUkmSourceId()));
for (Observer& observer : observers_)
observer.OnAccuracyTipShown();
}

@ -43,7 +43,7 @@ void AccuracyWebContentsObserver::DidFinishNavigation(
return;
}
if (web_contents()->GetMainFrame()->GetVisibilityState() !=
if (web_contents()->GetPrimaryMainFrame()->GetVisibilityState() !=
content::PageVisibilityState::kVisible) {
return;
}
@ -75,7 +75,7 @@ void AccuracyWebContentsObserver::OnAccuracyStatusObtained(
UMA_HISTOGRAM_ENUMERATION("Privacy.AccuracyTip.PageStatus", result);
ukm::builders::AccuracyTipStatus(
web_contents()->GetMainFrame()->GetPageUkmSourceId())
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId())
.SetStatus(static_cast<int>(result))
.Record(ukm::UkmRecorder::Get());

@ -39,7 +39,7 @@ AutofillManager* ToMainFrameAutofillManager(
content::WebContents::FromJavaWebContents(jweb_contents);
CHECK(web_contents);
AutofillManager* autofill_manager =
GetAutofillManager(web_contents, web_contents->GetMainFrame());
GetAutofillManager(web_contents, web_contents->GetPrimaryMainFrame());
CHECK(autofill_manager);
return autofill_manager;
}

@ -126,7 +126,7 @@ class ContentAutofillDriverFactoryTest
agent_ = std::make_unique<MockAutofillAgent>();
blink::AssociatedInterfaceProvider* remote_interfaces =
web_contents()->GetMainFrame()->GetRemoteAssociatedInterfaces();
web_contents()->GetPrimaryMainFrame()->GetRemoteAssociatedInterfaces();
remote_interfaces->OverrideBinderForTesting(
mojom::AutofillAgent::Name_,
base::BindRepeating(&MockAutofillAgent::BindPendingReceiver,

@ -341,11 +341,11 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness,
test_autofill_client_ = std::make_unique<MockAutofillClient>();
router_ = std::make_unique<ContentAutofillRouter>();
driver_ = std::make_unique<TestContentAutofillDriver>(
web_contents()->GetMainFrame(), router_.get(),
web_contents()->GetPrimaryMainFrame(), router_.get(),
test_autofill_client_.get());
blink::AssociatedInterfaceProvider* remote_interfaces =
web_contents()->GetMainFrame()->GetRemoteAssociatedInterfaces();
web_contents()->GetPrimaryMainFrame()->GetRemoteAssociatedInterfaces();
remote_interfaces->OverrideBinderForTesting(
mojom::AutofillAgent::Name_,
base::BindRepeating(&FakeAutofillAgent::BindPendingReceiver,
@ -430,17 +430,19 @@ TEST_P(ContentAutofillDriverTest, SetFrameAndFormMetaDataOfForm) {
EXPECT_EQ(
form.host_frame,
LocalFrameToken(web_contents()->GetMainFrame()->GetFrameToken().value()));
LocalFrameToken(
web_contents()->GetPrimaryMainFrame()->GetFrameToken().value()));
EXPECT_EQ(form.url, GURL("https://hostname/path"));
EXPECT_EQ(form.full_url, GURL());
EXPECT_EQ(form.main_frame_origin,
web_contents()->GetMainFrame()->GetLastCommittedOrigin());
web_contents()->GetPrimaryMainFrame()->GetLastCommittedOrigin());
EXPECT_EQ(form.main_frame_origin,
url::Origin::CreateFromNormalizedTuple("https", "hostname", 443));
ASSERT_EQ(form.fields.size(), 1u);
EXPECT_EQ(
form.fields.front().host_frame,
LocalFrameToken(web_contents()->GetMainFrame()->GetFrameToken().value()));
LocalFrameToken(
web_contents()->GetPrimaryMainFrame()->GetFrameToken().value()));
EXPECT_EQ(form2.host_frame, form.host_frame);
EXPECT_EQ(form2.url, form.url);
@ -517,7 +519,8 @@ TEST_P(ContentAutofillDriverTest, SetFrameAndFormMetaDataOfField) {
EXPECT_NE(signature_without_meta_data, CalculateFormSignature(form));
EXPECT_EQ(
field.host_frame,
LocalFrameToken(web_contents()->GetMainFrame()->GetFrameToken().value()));
LocalFrameToken(
web_contents()->GetPrimaryMainFrame()->GetFrameToken().value()));
EXPECT_EQ(field.host_form_id, form.unique_renderer_id);
EXPECT_EQ(field.host_form_signature, CalculateFormSignature(form));

@ -218,7 +218,7 @@ TEST_F(ActionDelegateUtilTest, PerformWithPasswordManagerValue) {
auto element = std::make_unique<ElementFinderResult>();
content::WebContentsTester::For(web_contents_.get())
->NavigateAndCommit(GURL("https://www.example.com"));
element->SetRenderFrameHost(web_contents_->GetMainFrame());
element->SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
GURL("https://www.example.com"), "username");
@ -241,7 +241,7 @@ TEST_F(ActionDelegateUtilTest, PerformWithPasswordManagerValue) {
TEST_F(ActionDelegateUtilTest, PerformWithFailingPasswordManagerValue) {
auto element = std::make_unique<ElementFinderResult>();
element->SetRenderFrameHost(web_contents_->GetMainFrame());
element->SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
GURL("https://www.example.com"), "username");

@ -698,8 +698,9 @@ void CollectUserDataAction::UpdateMetrics(
DCHECK(user_data);
if (!shown_to_user_) {
shown_to_user_ = true;
metrics_data_.source_id =
delegate_->GetWebContents()->GetMainFrame()->GetPageUkmSourceId();
metrics_data_.source_id = delegate_->GetWebContents()
->GetPrimaryMainFrame()
->GetPageUkmSourceId();
metrics_data_.user_data_source = user_data_source;
FillInitialDataStateForMetrics(user_data->available_contacts_,
user_data->available_addresses_,

@ -153,7 +153,7 @@ class CollectUserDataActionTest : public testing::Test {
content::WebContentsTester::For(web_contents_.get())
->SetLastCommittedURL(GURL(kFakeUrl));
ukm::InitializeSourceUrlRecorderForWebContents(web_contents_.get());
source_id_ = web_contents_->GetMainFrame()->GetPageUkmSourceId();
source_id_ = web_contents_->GetPrimaryMainFrame()->GetPageUkmSourceId();
ON_CALL(mock_action_delegate_, GetPersonalDataManager)
.WillByDefault(Return(&mock_personal_data_manager_));

@ -705,7 +705,7 @@ TEST_F(GetElementStatusActionTest, SucceedsWithPasswordManagerValue) {
.WillOnce(WithArgs<1>([this](auto&& callback) {
std::unique_ptr<ElementFinderResult> element =
std::make_unique<ElementFinderResult>();
element->SetRenderFrameHost(web_contents_->GetMainFrame());
element->SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
std::move(callback).Run(OkClientStatus(), std::move(element));
}));
EXPECT_CALL(mock_website_login_manager_, GetPasswordForLogin(_, _))

@ -120,7 +120,7 @@ TEST_F(SendKeystrokeEventsActionTest, PasswordTextValueReturnLastTimeUsed) {
content::WebContentsTester::For(web_contents_.get())
->NavigateAndCommit(GURL(kUrl));
element.SetObjectId("id");
element.SetRenderFrameHost(web_contents_->GetMainFrame());
element.SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
mock_action_delegate_.GetElementStore()->AddElement("e",
element.dom_object());
@ -161,7 +161,7 @@ TEST_F(SendKeystrokeEventsActionTest,
content::WebContentsTester::For(web_contents_.get())
->NavigateAndCommit(GURL(kUrl));
element.SetObjectId("id");
element.SetRenderFrameHost(web_contents_->GetMainFrame());
element.SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
mock_action_delegate_.GetElementStore()->AddElement("e",
element.dom_object());

@ -216,7 +216,7 @@ class ControllerTest : public testing::Test {
void SimulateNavigateToUrl(const GURL& url) {
SetLastCommittedUrl(url);
content::NavigationSimulator::NavigateAndCommitFromDocument(
url, web_contents()->GetMainFrame());
url, web_contents()->GetPrimaryMainFrame());
content::WebContentsTester::For(web_contents())->TestSetIsLoading(false);
controller_->DidFinishLoad(nullptr, GURL(""));
}
@ -784,7 +784,7 @@ TEST_F(ControllerTest, SuccessfulNavigation) {
NavigationStateChangeListener listener(controller_.get());
controller_->AddNavigationListener(&listener);
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://initialurl.com"), web_contents()->GetMainFrame());
GURL("http://initialurl.com"), web_contents()->GetPrimaryMainFrame());
controller_->RemoveNavigationListener(&listener);
EXPECT_FALSE(controller_->IsNavigatingToNewDocument());
@ -802,7 +802,7 @@ TEST_F(ControllerTest, FailedNavigation) {
controller_->AddNavigationListener(&listener);
content::NavigationSimulator::NavigateAndFailFromDocument(
GURL("http://initialurl.com"), net::ERR_CONNECTION_TIMED_OUT,
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
controller_->RemoveNavigationListener(&listener);
EXPECT_FALSE(controller_->IsNavigatingToNewDocument());
@ -821,7 +821,8 @@ TEST_F(ControllerTest, NavigationWithRedirects) {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
GURL("http://original.example.com/"), web_contents()->GetMainFrame());
GURL("http://original.example.com/"),
web_contents()->GetPrimaryMainFrame());
simulator->SetTransition(ui::PAGE_TRANSITION_LINK);
simulator->Start();
EXPECT_TRUE(controller_->IsNavigatingToNewDocument());
@ -850,9 +851,9 @@ TEST_F(ControllerTest, EventuallySuccessfulNavigation) {
controller_->AddNavigationListener(&listener);
content::NavigationSimulator::NavigateAndFailFromDocument(
GURL("http://initialurl.com"), net::ERR_CONNECTION_TIMED_OUT,
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://initialurl.com"), web_contents()->GetMainFrame());
GURL("http://initialurl.com"), web_contents()->GetPrimaryMainFrame());
controller_->RemoveNavigationListener(&listener);
EXPECT_FALSE(controller_->IsNavigatingToNewDocument());
@ -874,15 +875,15 @@ TEST_F(ControllerTest, RemoveListener) {
NavigationStateChangeListener listener(controller_.get());
controller_->AddNavigationListener(&listener);
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://initialurl.com"), web_contents()->GetMainFrame());
GURL("http://initialurl.com"), web_contents()->GetPrimaryMainFrame());
listener.events.clear();
controller_->RemoveNavigationListener(&listener);
content::NavigationSimulator::NavigateAndFailFromDocument(
GURL("http://initialurl.com"), net::ERR_CONNECTION_TIMED_OUT,
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://initialurl.com"), web_contents()->GetMainFrame());
GURL("http://initialurl.com"), web_contents()->GetPrimaryMainFrame());
EXPECT_THAT(listener.events, IsEmpty());
}
@ -976,7 +977,8 @@ TEST_F(ControllerTest, WaitForNavigationActionStartWithinTimeout) {
EXPECT_THAT(processed_actions_capture, SizeIs(0));
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
GURL("http://a.example.com/path"), web_contents()->GetMainFrame());
GURL("http://a.example.com/path"),
web_contents()->GetPrimaryMainFrame());
simulator->SetTransition(ui::PAGE_TRANSITION_LINK);
simulator->Start();
task_environment()->FastForwardBy(base::Seconds(1));
@ -1728,7 +1730,7 @@ TEST_F(ControllerTest, UnexpectedNavigationDuringPromptAction) {
EXPECT_CALL(mock_client_, Shutdown(_)).Times(0);
EXPECT_CALL(mock_client_, RecordDropOut(_)).Times(0);
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://a.example.com/page"), web_contents()->GetMainFrame());
GURL("http://a.example.com/page"), web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(AutofillAssistantState::PROMPT, controller_->GetState());
// Expected browser initiated navigation is allowed.
@ -1776,7 +1778,7 @@ TEST_F(ControllerTest, UnexpectedNavigationInRunningState) {
EXPECT_CALL(mock_client_, Shutdown(_)).Times(0);
EXPECT_CALL(mock_client_, RecordDropOut(_)).Times(0);
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://a.example.com/page"), web_contents()->GetMainFrame());
GURL("http://a.example.com/page"), web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(AutofillAssistantState::RUNNING, controller_->GetState());
// Expected browser initiated navigation while in RUNNING state:
@ -2098,7 +2100,8 @@ TEST_F(ControllerTest, EndPromptWithOnEndNavigation) {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
GURL("http://a.example.com/path"), web_contents()->GetMainFrame());
GURL("http://a.example.com/path"),
web_contents()->GetPrimaryMainFrame());
simulator->SetTransition(ui::PAGE_TRANSITION_LINK);
simulator->Start();
task_environment()->FastForwardBy(base::Seconds(1));
@ -2223,7 +2226,7 @@ TEST_F(ControllerPrerenderTest, SuccessfulNavigation) {
controller_->AddNavigationListener(&listener);
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://initialurl.com"), web_contents()->GetMainFrame());
GURL("http://initialurl.com"), web_contents()->GetPrimaryMainFrame());
EXPECT_THAT(
listener.events,
@ -2281,7 +2284,7 @@ TEST_F(ControllerFencedFrameTest, DoNotNavigateInFencedFrame) {
controller_->AddNavigationListener(&listener);
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://initialurl.com"), web_contents()->GetMainFrame());
GURL("http://initialurl.com"), web_contents()->GetPrimaryMainFrame());
EXPECT_THAT(
listener.events,
@ -2292,10 +2295,10 @@ TEST_F(ControllerFencedFrameTest, DoNotNavigateInFencedFrame) {
listener.events.clear();
// Create a fenced frame.
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->InitializeRenderFrameIfNeeded();
content::RenderFrameHost* fenced_frame_rfh =
CreateFencedFrame(web_contents()->GetMainFrame());
CreateFencedFrame(web_contents()->GetPrimaryMainFrame());
GURL kFencedFrameUrl("https://fencedframe.com");
std::unique_ptr<content::NavigationSimulator> navigation_simulator =
content::NavigationSimulator::CreateRendererInitiated(kFencedFrameUrl,

@ -38,7 +38,7 @@ void FullCardRequester::GetFullCard(
}
autofill::ContentAutofillDriver* driver =
factory->DriverForFrame(web_contents->GetMainFrame());
factory->DriverForFrame(web_contents->GetPrimaryMainFrame());
if (!driver) {
OnFullCardRequestFailed(FullCardRequest::FailureType::GENERIC_FAILURE);
return;

@ -179,7 +179,7 @@ Starter::Starter(content::WebContents* web_contents,
: content::WebContentsObserver(web_contents),
content::WebContentsUserData<Starter>(*web_contents),
current_ukm_source_id_(
web_contents->GetMainFrame()->GetPageUkmSourceId()),
web_contents->GetPrimaryMainFrame()->GetPageUkmSourceId()),
cached_failed_trigger_script_fetches_(
GetOrCreateFailedTriggerScriptFetchesCache()),
user_denylisted_domains_(kMaxUserDenylistedCacheSize),
@ -425,7 +425,7 @@ void Starter::Init() {
fetch_trigger_scripts_on_navigation_) {
MaybeStartImplicitlyForUrl(
web_contents()->GetLastCommittedURL(),
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
}
}
@ -513,7 +513,7 @@ void Starter::Start(std::unique_ptr<TriggerContext> trigger_context) {
if (IsTriggerScriptContext(*pending_trigger_context_) &&
!url_utils::IsSamePublicSuffixDomain(
web_contents()->GetMainFrame()->GetLastCommittedURL(),
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
startup_url.value_or(GURL()))) {
waiting_for_deeplink_navigation_ = true;
return;

@ -182,20 +182,20 @@ class StarterTest : public testing::Test {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
web_contents()->GetLastCommittedURL(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
simulator->Start();
for (const auto& url : urls) {
simulator->Redirect(url);
}
simulator->Commit();
navigation_ids_.emplace_back(
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
}
void SimulateNavigateToUrl(const GURL& url) {
content::WebContentsTester::For(web_contents())->NavigateAndCommit(url);
navigation_ids_.emplace_back(
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
}
// Each request sender is only good for one trigger script. This call will
@ -1345,13 +1345,13 @@ TEST_F(StarterTest, RedirectFailsDuringPendingTriggerScriptStart) {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
web_contents()->GetLastCommittedURL(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
simulator->Start();
simulator->Redirect(GURL("https://redirect.com/to/www/example/com"));
simulator->Fail(net::ERR_BLOCKED_BY_CLIENT);
simulator->CommitErrorPage();
navigation_ids_.emplace_back(
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
// Note that this impression is recorded for the last URL that a navigation-
// start event occurred for. We never reached the target domain, so this is
@ -1391,7 +1391,7 @@ TEST_F(StarterTest, StartTriggerScriptDuringRedirectRecordsUkmForTargetUrl) {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
web_contents()->GetLastCommittedURL(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
simulator->Start();
simulator->Redirect(GURL("https://redirect.com/to/www/example/com"));
starter_->Start(std::make_unique<TriggerContext>(
@ -1399,7 +1399,7 @@ TEST_F(StarterTest, StartTriggerScriptDuringRedirectRecordsUkmForTargetUrl) {
simulator->Redirect(GURL(kExampleDeeplink));
simulator->Commit();
navigation_ids_.emplace_back(
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
EXPECT_THAT(GetUkmTriggerScriptStarted(ukm_recorder_),
ElementsAreArray(ToHumanReadableMetrics(
@ -1426,7 +1426,7 @@ TEST_F(StarterTest, RegularStartupDoesNotWaitForNavigationToFinish) {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
web_contents()->GetLastCommittedURL(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
simulator->Start();
simulator->Redirect(GURL("https://redirect.com/to/www/example/com"));
@ -2293,10 +2293,10 @@ TEST_F(StarterFencedFrameTest, NoImplicitTriggeringForFencedFrames) {
TriggerContext::Options()));
// Create a fenced frame and navigate to the example deeplink. The navigation
// should not start because it is not in the primary main frame.
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->InitializeRenderFrameIfNeeded();
content::RenderFrameHost* fenced_frame_rfh =
CreateFencedFrame(web_contents()->GetMainFrame());
CreateFencedFrame(web_contents()->GetPrimaryMainFrame());
std::unique_ptr<content::NavigationSimulator> navigation_simulator =
content::NavigationSimulator::CreateRendererInitiated(
GURL(kExampleDeeplink), fenced_frame_rfh);

@ -36,7 +36,7 @@ void SuppressKeyboardRAII::RenderFrameCreated(
}
void SuppressKeyboardRAII::SuppressKeyboard(bool suppress) {
web_contents()->GetMainFrame()->ForEachRenderFrameHost(
web_contents()->GetPrimaryMainFrame()->ForEachRenderFrameHost(
base::BindRepeating(&SuppressKeyboardForFrame, suppress));
}

@ -626,7 +626,8 @@ TriggerScriptCoordinator::GetTriggerUiTypeForVisibleScript() const {
}
GURL TriggerScriptCoordinator::GetCurrentURL() const {
GURL current_url = web_contents()->GetMainFrame()->GetLastCommittedURL();
GURL current_url =
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL();
if (current_url.is_empty()) {
return deeplink_url_;
}

@ -105,7 +105,7 @@ class TriggerScriptCoordinatorTest : public testing::Test {
std::move(mock_web_controller), std::move(mock_request_sender),
GURL(kFakeServerUrl), std::move(mock_static_trigger_conditions),
std::move(mock_dynamic_trigger_conditions), &ukm_recorder_,
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
}
void TearDown() override { coordinator_.reset(); }
@ -127,10 +127,10 @@ class TriggerScriptCoordinatorTest : public testing::Test {
void SimulateNavigateToUrl(const GURL& url) {
content::WebContentsTester::For(web_contents())->SetLastCommittedURL(url);
content::NavigationSimulator::NavigateAndCommitFromDocument(
url, web_contents()->GetMainFrame());
url, web_contents()->GetPrimaryMainFrame());
content::WebContentsTester::For(web_contents())->TestSetIsLoading(false);
navigation_ids_.emplace_back(
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
}
protected:
@ -1360,7 +1360,7 @@ TEST_F(TriggerScriptCoordinatorTest, UiTimeoutWhileShown) {
EXPECT_CALL(*mock_ui_delegate_, ShowTriggerScript).Times(1);
content::NavigationSimulator::Reload(web_contents());
navigation_ids_.emplace_back(
web_contents()->GetMainFrame()->GetPageUkmSourceId());
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId());
EXPECT_CALL(*mock_ui_delegate_, HideTriggerScript).Times(0);
task_environment()->FastForwardBy(base::Seconds(1));

@ -1263,7 +1263,7 @@ TEST_F(UserDataUtilTextValueTest, GetUsername) {
GURL("https://www.example.com"), "username");
ElementFinderResult element;
element.SetRenderFrameHost(web_contents_->GetMainFrame());
element.SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
PasswordManagerValue password_manager_value;
password_manager_value.set_credential_type(PasswordManagerValue::USERNAME);
@ -1281,7 +1281,7 @@ TEST_F(UserDataUtilTextValueTest, GetStoredPassword) {
GURL("https://www.example.com"), "username");
ElementFinderResult element;
element.SetRenderFrameHost(web_contents_->GetMainFrame());
element.SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
PasswordManagerValue password_manager_value;
password_manager_value.set_credential_type(PasswordManagerValue::PASSWORD);
@ -1303,7 +1303,7 @@ TEST_F(UserDataUtilTextValueTest, GetStoredPasswordFails) {
ElementFinderResult element;
content::WebContentsTester::For(web_contents_.get())
->NavigateAndCommit(GURL("https://www.example.com"));
element.SetRenderFrameHost(web_contents_->GetMainFrame());
element.SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
PasswordManagerValue password_manager_value;
password_manager_value.set_credential_type(PasswordManagerValue::PASSWORD);
@ -1419,7 +1419,7 @@ TEST_F(UserDataUtilTextValueTest, TextValuePasswordManagerValue) {
ElementFinderResult element;
content::WebContentsTester::For(web_contents_.get())
->NavigateAndCommit(GURL("https://www.example.com"));
element.SetRenderFrameHost(web_contents_->GetMainFrame());
element.SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
TextValue text_value;
text_value.mutable_password_manager_value()->set_credential_type(

@ -108,7 +108,7 @@ void CssElementFinder::Start(const ElementFinderResult& start_element,
current_frame_ = start_element.render_frame_host();
if (current_frame_ == nullptr) {
current_frame_ = web_contents_->GetMainFrame();
current_frame_ = web_contents_->GetPrimaryMainFrame();
}
current_frame_id_ = start_element.node_frame_id();
frame_stack_ = start_element.frame_stack();

@ -50,19 +50,21 @@ content::RenderFrameHost* FindCorrespondingRenderFrameHost(
const std::string& frame_id,
content::WebContents* web_contents) {
if (frame_id.empty()) {
return web_contents->GetMainFrame();
return web_contents->GetPrimaryMainFrame();
}
content::RenderFrameHost* result = nullptr;
web_contents->GetMainFrame()->ForEachRenderFrameHost(base::BindRepeating(
[](const std::string& frame_id, content::RenderFrameHost** result,
content::RenderFrameHost* render_frame_host) {
if (render_frame_host->GetDevToolsFrameToken().ToString() == frame_id) {
*result = render_frame_host;
return content::RenderFrameHost::FrameIterationAction::kStop;
}
return content::RenderFrameHost::FrameIterationAction::kContinue;
},
frame_id, &result));
web_contents->GetPrimaryMainFrame()->ForEachRenderFrameHost(
base::BindRepeating(
[](const std::string& frame_id, content::RenderFrameHost** result,
content::RenderFrameHost* render_frame_host) {
if (render_frame_host->GetDevToolsFrameToken().ToString() ==
frame_id) {
*result = render_frame_host;
return content::RenderFrameHost::FrameIterationAction::kStop;
}
return content::RenderFrameHost::FrameIterationAction::kContinue;
},
frame_id, &result));
return result;
}

@ -34,8 +34,9 @@ class ElementStoreTest : public testing::Test {
const std::string& object_id) {
auto element = std::make_unique<ElementFinderResult>();
element->SetObjectId(object_id);
element->SetNodeFrameId(
web_contents_->GetMainFrame()->GetDevToolsFrameToken().ToString());
element->SetNodeFrameId(web_contents_->GetPrimaryMainFrame()
->GetDevToolsFrameToken()
.ToString());
return element;
}
@ -93,7 +94,7 @@ TEST_F(ElementStoreTest, GetElementFromStoreWithNoFrameId) {
ElementFinderResult result;
EXPECT_EQ(ACTION_APPLIED,
element_store_->GetElement("1", &result).proto_status());
EXPECT_EQ(web_contents_->GetMainFrame(), result.render_frame_host());
EXPECT_EQ(web_contents_->GetPrimaryMainFrame(), result.render_frame_host());
}
TEST_F(ElementStoreTest, AddElementToStoreOverwrites) {

@ -27,7 +27,7 @@ ClientStatus FakeElementStore::GetElement(
out_element->SetNodeFrameId(it->second.object_data.node_frame_id);
out_element->SetFrameStack(it->second.frame_stack);
if (web_contents_ != nullptr) {
out_element->SetRenderFrameHost(web_contents_->GetMainFrame());
out_element->SetRenderFrameHost(web_contents_->GetPrimaryMainFrame());
}
return OkClientStatus();
}

@ -24,7 +24,7 @@ void MockAutofillAssistantAgent::BindPendingReceiver(
void MockAutofillAssistantAgent::RegisterForAllFrames(
content::WebContents* web_contents,
MockAutofillAssistantAgent* agent) {
web_contents->GetMainFrame()->ForEachRenderFrameHost(
web_contents->GetPrimaryMainFrame()->ForEachRenderFrameHost(
base::BindLambdaForTesting([agent](content::RenderFrameHost* host) {
host->GetRemoteAssociatedInterfaces()->OverrideBinderForTesting(
mojom::AutofillAssistantAgent::Name_,

@ -102,7 +102,7 @@ void SemanticElementFinder::Start(const ElementFinderResult& start_element,
auto* start_frame = start_element.render_frame_host();
if (!start_frame) {
start_frame = web_contents_->GetMainFrame();
start_frame = web_contents_->GetPrimaryMainFrame();
}
RunAnnotateDomModel(start_frame);
}

@ -560,11 +560,11 @@ class WebControllerBrowserTest : public autofill_assistant::BaseBrowserTest,
void CheckFindElementResult(const ElementFinderResult& result,
bool is_main_frame) {
if (is_main_frame) {
EXPECT_EQ(shell()->web_contents()->GetMainFrame(),
EXPECT_EQ(shell()->web_contents()->GetPrimaryMainFrame(),
result.render_frame_host());
EXPECT_EQ(result.frame_stack().size(), 0u);
} else {
EXPECT_NE(shell()->web_contents()->GetMainFrame(),
EXPECT_NE(shell()->web_contents()->GetPrimaryMainFrame(),
result.render_frame_host());
EXPECT_GE(result.frame_stack().size(), 1u);
}
@ -2702,7 +2702,7 @@ IN_PROC_BROWSER_TEST_F(WebControllerBrowserTest,
// This makes the devtools action fail.
ElementFinderResult element;
element.SetNodeFrameId("doesnotexist");
element.SetRenderFrameHost(web_contents()->GetMainFrame());
element.SetRenderFrameHost(web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(ELEMENT_POSITION_NOT_FOUND,
WaitUntilElementIsStable(element, 10, base::Milliseconds(100))

@ -465,7 +465,8 @@ absl::optional<std::string> WebsiteLoginManagerImpl::GeneratePassword(
// TODO(crbug.com/1043132): Add support for non-main frames. If another
// frame has a different origin than the main frame, passwords-related
// features may not work.
auto* driver = factory->GetDriverForFrame(web_contents_->GetMainFrame());
auto* driver =
factory->GetDriverForFrame(web_contents_->GetPrimaryMainFrame());
if (!driver) {
return absl::nullopt;
}

@ -48,8 +48,8 @@ class ContentAutofillAssistantDriverTest : public testing::Test {
&browser_context_, nullptr);
// Constructor of ContentAutofillAssistantDriver is private, cannot use
// std::make_unique.
driver_ = base::WrapUnique(
new ContentAutofillAssistantDriver(web_contents_->GetMainFrame()));
driver_ = base::WrapUnique(new ContentAutofillAssistantDriver(
web_contents_->GetPrimaryMainFrame()));
driver_->SetAnnotateDomModelService(annotate_dom_model_service_.get());
}

@ -43,8 +43,8 @@ class BackgroundSyncPermissionContextTest
base::RunLoop run_loop;
const permissions::PermissionRequestID id(
web_contents()->GetMainFrame()->GetProcess()->GetID(),
web_contents()->GetMainFrame()->GetRoutingID(),
web_contents()->GetPrimaryMainFrame()->GetProcess()->GetID(),
web_contents()->GetPrimaryMainFrame()->GetRoutingID(),
permissions::PermissionRequestID::RequestLocalId());
permission_context->RequestPermission(
id, url, /* user_gesture= */ false,

@ -76,7 +76,7 @@ void PopupBlockerTabHelper::DidFinishNavigation(
void PopupBlockerTabHelper::HidePopupNotification() {
auto* pscs = content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
if (pscs)
pscs->ClearPopupsBlocked();
}
@ -96,7 +96,7 @@ void PopupBlockerTabHelper::AddBlockedPopup(
auto* content_settings =
content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
if (content_settings) {
content_settings->OnContentBlocked(ContentSettingsType::POPUPS);
}

@ -159,7 +159,7 @@ TEST_F(PopupBlockerTabHelperTest, DoesNotShowPopupWithInvalidID) {
TEST_F(PopupBlockerTabHelperTest, SetsContentSettingsPopupState) {
auto* content_settings =
content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_FALSE(content_settings->IsContentBlocked(ContentSettingsType::POPUPS));
TestPopupNavigationDelegate::ResultHolder result;
@ -186,12 +186,12 @@ TEST_F(PopupBlockerTabHelperTest, ClearsContentSettingsPopupStateOnNavigation) {
std::make_unique<TestPopupNavigationDelegate>(GURL(kUrl1), &result),
blink::mojom::WindowFeatures(), PopupBlockType::kNoGesture);
EXPECT_TRUE(content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
->IsContentBlocked(ContentSettingsType::POPUPS));
NavigateAndCommit(GURL(kUrl2));
EXPECT_FALSE(content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
->IsContentBlocked(ContentSettingsType::POPUPS));
}
@ -202,24 +202,24 @@ TEST_F(PopupBlockerTabHelperTest,
std::make_unique<TestPopupNavigationDelegate>(GURL(kUrl1), &result),
blink::mojom::WindowFeatures(), PopupBlockType::kNoGesture);
EXPECT_TRUE(content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
->IsContentBlocked(ContentSettingsType::POPUPS));
// Navigating a non-primary main frame shoudn't clear the popups.
content::MockNavigationHandle handle(GURL(kUrl2),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
handle.set_has_committed(true);
handle.set_is_in_primary_main_frame(false);
helper()->DidFinishNavigation(&handle);
EXPECT_TRUE(content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
->IsContentBlocked(ContentSettingsType::POPUPS));
// Navigating the primary main frame should clear the popups.
handle.set_is_in_primary_main_frame(true);
helper()->DidFinishNavigation(&handle);
EXPECT_FALSE(content_settings::PageSpecificContentSettings::GetForFrame(
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
->IsContentBlocked(ContentSettingsType::POPUPS));
}

@ -102,7 +102,7 @@ void PopupOpenerTabHelper::MaybeLogPagePopupContentSettings() {
return;
const ukm::SourceId source_id =
web_contents()->GetMainFrame()->GetPageUkmSourceId();
web_contents()->GetPrimaryMainFrame()->GetPageUkmSourceId();
// Do not record duplicate Popup.Page events for popups opened in succession
// from the same opener.

@ -50,7 +50,7 @@ PopupTracker::PopupTracker(content::WebContents* contents,
visibility_tracker_(
base::DefaultTickClock::GetInstance(),
contents->GetVisibility() != content::Visibility::HIDDEN),
opener_source_id_(opener->GetMainFrame()->GetPageUkmSourceId()),
opener_source_id_(opener->GetPrimaryMainFrame()->GetPageUkmSourceId()),
window_open_disposition_(disposition) {
if (auto* popup_opener = PopupOpenerTabHelper::FromWebContents(opener))
popup_opener->OnOpenedPopup(this);

@ -192,7 +192,7 @@ TEST_F(SafeBrowsingTriggeredPopupBlockerTest,
for (const auto& test_case : kTestCases) {
std::unique_ptr<content::NavigationSimulator> simulator =
content::NavigationSimulator::CreateRendererInitiated(
test_case.initial_url, web_contents()->GetMainFrame());
test_case.initial_url, web_contents()->GetPrimaryMainFrame());
simulator->Start();
simulator->Redirect(test_case.redirect_url);
simulator->Commit();

@ -111,12 +111,12 @@ class BrowsingTopicsPageLoadDataTrackerTest
BrowsingTopicsPageLoadDataTracker* GetBrowsingTopicsPageLoadDataTracker() {
return BrowsingTopicsPageLoadDataTracker::GetOrCreateForPage(
web_contents()->GetMainFrame()->GetPage());
web_contents()->GetPrimaryMainFrame()->GetPage());
}
content::BrowsingTopicsSiteDataManager* topics_site_data_manager() {
return web_contents()
->GetMainFrame()
->GetPrimaryMainFrame()
->GetProcess()
->GetStoragePartition()
->GetBrowsingTopicsSiteDataManager();

@ -225,7 +225,7 @@ class BrowsingTopicsServiceImplTest
content::BrowsingTopicsSiteDataManager* topics_site_data_manager() {
return web_contents()
->GetMainFrame()
->GetPrimaryMainFrame()
->GetProcess()
->GetStoragePartition()
->GetBrowsingTopicsSiteDataManager();
@ -561,7 +561,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(
GURL("https://www.bar.com")),
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
.empty());
auto entries = ukm_recorder.GetEntriesByName(
ukm::builders::BrowsingTopics_DocumentBrowsingTopicsApiResult::
@ -589,7 +589,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(
GURL("https://www.bar.com")),
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
.empty());
EXPECT_FALSE(browsing_topics_service_
->GetTopicsForSiteForDisplay(
@ -802,7 +802,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(
GURL("https://www.bar.com")),
web_contents()->GetMainFrame())
web_contents()->GetPrimaryMainFrame())
.empty());
auto entries = ukm_recorder.GetEntriesByName(
@ -838,7 +838,7 @@ TEST_F(BrowsingTopicsServiceImplTest, GetBrowsingTopicsForJsApi_OneEpoch) {
std::vector<blink::mojom::EpochTopicPtr> result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_TRUE(result.empty());
@ -857,7 +857,7 @@ TEST_F(BrowsingTopicsServiceImplTest, GetBrowsingTopicsForJsApi_OneEpoch) {
result = browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(result.size(), 1u);
EXPECT_EQ(result[0]->topic, 2);
@ -891,7 +891,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
std::vector<blink::mojom::EpochTopicPtr> result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_TRUE(result.empty());
@ -927,7 +927,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
std::vector<blink::mojom::EpochTopicPtr> result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_TRUE(result.empty());
@ -939,7 +939,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
result = browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_TRUE(result.empty());
}
@ -988,7 +988,7 @@ TEST_F(BrowsingTopicsServiceImplTest, GetBrowsingTopicsForJsApi_FourEpochs) {
std::vector<blink::mojom::EpochTopicPtr> result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(result.size(), 3u);
std::set<int> result_set;
@ -1002,7 +1002,7 @@ TEST_F(BrowsingTopicsServiceImplTest, GetBrowsingTopicsForJsApi_FourEpochs) {
result = browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(result.size(), 3u);
result_set.clear();
@ -1057,7 +1057,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
std::vector<blink::mojom::EpochTopicPtr> result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(result.size(), 2u);
std::set<int> result_set;
@ -1070,7 +1070,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
result = browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(result.size(), 2u);
result_set.clear();
@ -1133,7 +1133,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
std::vector<blink::mojom::EpochTopicPtr> result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(result.size(), 2u);
std::set<int> result_set;
@ -1170,7 +1170,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
NavigateToPage(GURL("https://www.foo.com"));
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
std::vector<ApiUsageContext> api_usage_contexts =
content::GetBrowsingTopicsApiUsage(topics_site_data_manager());
@ -1210,7 +1210,7 @@ TEST_F(BrowsingTopicsServiceImplTest, ApiResultUkm_ZeroAndOneTopic) {
// any metrics.
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
entries = ukm_recorder.GetEntriesByName(
ukm::builders::BrowsingTopics_DocumentBrowsingTopicsApiResult::
@ -1232,7 +1232,7 @@ TEST_F(BrowsingTopicsServiceImplTest, ApiResultUkm_ZeroAndOneTopic) {
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
entries = ukm_recorder.GetEntriesByName(
ukm::builders::BrowsingTopics_DocumentBrowsingTopicsApiResult::
@ -1315,7 +1315,7 @@ TEST_F(BrowsingTopicsServiceImplTest,
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://www.bar.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
auto entries = ukm_recorder.GetEntriesByName(
ukm::builders::BrowsingTopics_DocumentBrowsingTopicsApiResult::
@ -1399,7 +1399,7 @@ TEST_F(BrowsingTopicsServiceImplTest, GetTopicsForSiteForDisplay) {
// Current time is before the epoch switch time.
std::vector<privacy_sandbox::CanonicalTopic> result =
browsing_topics_service_->GetTopicsForSiteForDisplay(
web_contents()->GetMainFrame()->GetLastCommittedOrigin());
web_contents()->GetPrimaryMainFrame()->GetLastCommittedOrigin());
EXPECT_EQ(result.size(), 2u);
EXPECT_EQ(result[0].topic_id(), Topic(2));
@ -1744,7 +1744,7 @@ TEST_F(BrowsingTopicsServiceImplTest, ClearTopicsDataForOrigin) {
std::vector<blink::mojom::EpochTopicPtr> api_call_result =
browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://b.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(api_call_result.size(), 1u);
EXPECT_EQ(api_call_result[0]->topic, 3);
@ -1772,7 +1772,7 @@ TEST_F(BrowsingTopicsServiceImplTest, ClearTopicsDataForOrigin) {
// the same context domain was seen in the page before.
api_call_result = browsing_topics_service_->GetBrowsingTopicsForJsApi(
/*context_origin=*/url::Origin::Create(GURL("https://b.com")),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
// Since the domain "b.com" is removed. The candidate topic won't be returned.
EXPECT_TRUE(api_call_result.empty());

@ -131,7 +131,7 @@ class MediaDrmStorageImplTest : public content::RenderViewHostTestHarness {
}
content::RenderFrameHost* SimulateNavigation(const GURL& url) {
content::RenderFrameHost* rfh = web_contents()->GetMainFrame();
content::RenderFrameHost* rfh = web_contents()->GetPrimaryMainFrame();
content::RenderFrameHostTester::For(rfh)->InitializeRenderFrameIfNeeded();
auto navigation_simulator =

@ -31,12 +31,12 @@ bool WebContentsWrapper::IsOffTheRecord() {
void WebContentsWrapper::RunJavascript(
const std::u16string& script,
base::OnceCallback<void(const base::Value)> callback) {
if (!web_contents_ && web_contents_->GetMainFrame()) {
if (!web_contents_ && web_contents_->GetPrimaryMainFrame()) {
std::move(callback).Run(base::Value());
return;
}
web_contents_->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(
web_contents_->GetPrimaryMainFrame()->ExecuteJavaScriptInIsolatedWorld(
script, std::move(callback), js_world_id_);
}

@ -69,8 +69,8 @@ static void JNI_ContentCaptureTestSupport_SimulateDidUpdateFaviconURL(
ToType(*icon.FindKey("type")->GetIfString()), sizes));
}
CHECK(!favicon_urls.empty());
provider->NotifyFaviconURLUpdatedForTesting(web_contents->GetMainFrame(),
favicon_urls);
provider->NotifyFaviconURLUpdatedForTesting(
web_contents->GetPrimaryMainFrame(), favicon_urls);
}
} // namespace content_capture

@ -23,7 +23,7 @@ class ContentCaptureBrowserTest : public content::ContentBrowserTest {
// Navigate to the initial page.
const GURL main_frame_url = embedded_test_server()->GetURL(kMainFrameUrl);
ASSERT_TRUE(NavigateToURL(web_contents(), main_frame_url));
main_frame_ = web_contents()->GetMainFrame();
main_frame_ = web_contents()->GetPrimaryMainFrame();
EXPECT_NE(nullptr, main_frame_);
// Create a provider and add a consumer.

@ -45,7 +45,7 @@ class ContentCaptureReceiverTest : public content::RenderViewHostTestHarness,
// This needed to keep the WebContentsObserverConsistencyChecker checks
// happy for when AppendChild is called.
NavigateAndCommit(GURL(kMainFrameUrl));
main_frame_ = web_contents()->GetMainFrame();
main_frame_ = web_contents()->GetPrimaryMainFrame();
EXPECT_TRUE(main_frame_);
main_frame_sender_ = std::make_unique<FakeContentCaptureSender>();
@ -57,7 +57,7 @@ class ContentCaptureReceiverTest : public content::RenderViewHostTestHarness,
void NavigateMainFrame(const GURL& url) {
consumer()->Reset();
NavigateAndCommit(url);
main_frame_ = web_contents()->GetMainFrame();
main_frame_ = web_contents()->GetPrimaryMainFrame();
}
void NavigateMainFrameSameDocument() {
@ -302,7 +302,7 @@ TEST_P(ContentCaptureReceiverTest, ChildFrameDidCaptureContent) {
// This test is for issue crbug.com/995121 .
TEST_P(ContentCaptureReceiverTest, RenderFrameHostGone) {
auto* receiver = provider()->ContentCaptureReceiverForFrameForTesting(
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
// No good way to simulate crbug.com/995121, just set rfh_ to nullptr in
// ContentCaptureReceiver, so content::WebContents::FromRenderFrameHost()
// won't return WebContents.
@ -316,7 +316,7 @@ TEST_P(ContentCaptureReceiverTest, RenderFrameHostGone) {
TEST_P(ContentCaptureReceiverTest, TitleUpdateTaskDelay) {
auto* receiver = provider()->ContentCaptureReceiverForFrameForTesting(
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
auto task_runner = base::MakeRefCounted<base::TestMockTimeTaskRunner>();
// Uses TestMockTimeTaskRunner to check the task state.
receiver->title_update_task_runner_ = task_runner;
@ -550,7 +550,7 @@ class ContentCaptureReceiverMultipleFrameTest
// This needed to keep the WebContentsObserverConsistencyChecker checks
// happy for when AppendChild is called.
NavigateAndCommit(GURL("about:blank"));
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("child");
helper_.CreateProviderAndConsumer(web_contents());

@ -144,8 +144,8 @@ void OnscreenContentProvider::ReadyToCommitNavigation(
void OnscreenContentProvider::TitleWasSet(content::NavigationEntry* entry) {
// Set the title to the mainframe.
if (auto* receiver =
ContentCaptureReceiverForFrame(web_contents()->GetMainFrame())) {
if (auto* receiver = ContentCaptureReceiverForFrame(
web_contents()->GetPrimaryMainFrame())) {
// To match what the user sees, intentionally get the title from WebContents
// instead of NavigationEntry, though they might be same.
receiver->SetTitle(web_contents()->GetTitle());
@ -290,8 +290,8 @@ bool OnscreenContentProvider::BuildContentCaptureSessionLastSeen(
bool OnscreenContentProvider::BuildContentCaptureSessionForMainFrame(
ContentCaptureSession* session) {
if (auto* receiver =
ContentCaptureReceiverForFrame(web_contents()->GetMainFrame())) {
if (auto* receiver = ContentCaptureReceiverForFrame(
web_contents()->GetPrimaryMainFrame())) {
session->push_back(receiver->GetContentCaptureFrame());
return true;
}

@ -116,7 +116,8 @@ class PageSpecificContentSettingsTest
TEST_F(PageSpecificContentSettingsTest, BlockedContent) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
// Check that after initializing, nothing is blocked.
#if !BUILDFLAG(IS_ANDROID)
@ -140,14 +141,14 @@ TEST_F(PageSpecificContentSettingsTest, BlockedContent) {
origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */));
ASSERT_TRUE(cookie1);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kChange,
origin,
origin,
{*cookie1},
false});
content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
content_settings = PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
#if !BUILDFLAG(IS_ANDROID)
content_settings->OnContentBlocked(ContentSettingsType::IMAGES);
#endif
@ -176,7 +177,7 @@ TEST_F(PageSpecificContentSettingsTest, BlockedContent) {
content_settings->IsContentBlocked(ContentSettingsType::MEDIASTREAM_MIC));
EXPECT_TRUE(content_settings->IsContentBlocked(
ContentSettingsType::MEDIASTREAM_CAMERA));
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kChange,
origin,
origin,
@ -188,7 +189,7 @@ TEST_F(PageSpecificContentSettingsTest, BlockedContent) {
origin, "C=D", base::Time::Now(), absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */));
ASSERT_TRUE(cookie2);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kChange,
origin,
origin,
@ -206,25 +207,25 @@ TEST_F(PageSpecificContentSettingsTest, BlockedContent) {
GetHandle()->OnServiceWorkerAccessed(
simulator->GetNavigationHandle(), GURL("http://google.com"),
content::AllowServiceWorkerResult::FromPolicy(true, false));
content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
content_settings = PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
EXPECT_FALSE(
content_settings->IsContentBlocked(ContentSettingsType::JAVASCRIPT));
simulator->Commit();
content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
content_settings = PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
// Block a javascript when page starts to start ServiceWorker.
GetHandle()->OnServiceWorkerAccessed(
web_contents()->GetMainFrame(), GURL("http://google.com"),
web_contents()->GetPrimaryMainFrame(), GURL("http://google.com"),
content::AllowServiceWorkerResult::FromPolicy(true, false));
EXPECT_TRUE(
content_settings->IsContentBlocked(ContentSettingsType::JAVASCRIPT));
// Reset blocked content settings.
NavigateAndCommit(GURL("http://google.com"));
content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
content_settings = PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
#if !BUILDFLAG(IS_ANDROID)
EXPECT_FALSE(content_settings->IsContentBlocked(ContentSettingsType::IMAGES));
#endif
@ -242,7 +243,8 @@ TEST_F(PageSpecificContentSettingsTest, BlockedContent) {
TEST_F(PageSpecificContentSettingsTest, BlockedFileSystems) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
// Access a file system.
content_settings->OnStorageAccessed(StorageType::FILE_SYSTEM,
@ -259,7 +261,8 @@ TEST_F(PageSpecificContentSettingsTest, BlockedFileSystems) {
TEST_F(PageSpecificContentSettingsTest, AllowedContent) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
// Test default settings.
ASSERT_FALSE(content_settings->IsContentAllowed(ContentSettingsType::IMAGES));
@ -278,7 +281,7 @@ TEST_F(PageSpecificContentSettingsTest, AllowedContent) {
origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */));
ASSERT_TRUE(cookie1);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kChange,
origin,
origin,
@ -293,7 +296,7 @@ TEST_F(PageSpecificContentSettingsTest, AllowedContent) {
origin, "C=D", base::Time::Now(), absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */));
ASSERT_TRUE(cookie2);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kChange,
origin,
origin,
@ -306,14 +309,15 @@ TEST_F(PageSpecificContentSettingsTest, AllowedContent) {
TEST_F(PageSpecificContentSettingsTest, EmptyCookieList) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
ASSERT_FALSE(
content_settings->IsContentAllowed(ContentSettingsType::COOKIES));
ASSERT_FALSE(
content_settings->IsContentBlocked(ContentSettingsType::COOKIES));
GetHandle()->OnCookiesAccessed(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kRead, GURL("http://google.com"),
GURL("http://google.com"), net::CookieList(), true});
ASSERT_FALSE(
@ -325,7 +329,8 @@ TEST_F(PageSpecificContentSettingsTest, EmptyCookieList) {
TEST_F(PageSpecificContentSettingsTest, SiteDataObserver) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
MockSiteDataObserver mock_observer(web_contents());
EXPECT_CALL(mock_observer, OnSiteDataAccessed()).Times(6);
@ -335,7 +340,7 @@ TEST_F(PageSpecificContentSettingsTest, SiteDataObserver) {
origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */));
ASSERT_TRUE(cookie);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kChange,
origin,
origin,
@ -352,7 +357,7 @@ TEST_F(PageSpecificContentSettingsTest, SiteDataObserver) {
cookie_list.push_back(*other_cookie);
GetHandle()->OnCookiesAccessed(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kRead, GURL("http://google.com"),
GURL("http://google.com"), cookie_list, blocked_by_policy});
content_settings->OnStorageAccessed(
@ -368,13 +373,14 @@ TEST_F(PageSpecificContentSettingsTest, SiteDataObserver) {
TEST_F(PageSpecificContentSettingsTest, LocalSharedObjectsContainer) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
bool blocked_by_policy = false;
auto cookie = net::CanonicalCookie::Create(
GURL("http://google.com"), "k=v", base::Time::Now(),
absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kRead,
GURL("http://google.com"),
GURL("http://google.com"),
@ -423,7 +429,8 @@ TEST_F(PageSpecificContentSettingsTest, LocalSharedObjectsContainer) {
TEST_F(PageSpecificContentSettingsTest, LocalSharedObjectsContainerCookie) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
bool blocked_by_policy = false;
auto cookie1 = net::CanonicalCookie::Create(
GURL("http://google.com"), "k1=v", base::Time::Now(),
@ -441,7 +448,7 @@ TEST_F(PageSpecificContentSettingsTest, LocalSharedObjectsContainerCookie) {
GURL("http://www.google.com"), "k4=v; Domain=.www.google.com",
base::Time::Now(), absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kRead,
GURL("http://www.google.com"),
GURL("http://www.google.com"),
@ -452,7 +459,7 @@ TEST_F(PageSpecificContentSettingsTest, LocalSharedObjectsContainerCookie) {
GURL("https://www.google.com"), "k5=v", base::Time::Now(),
absl::nullopt /* server_time */,
absl::nullopt /* cookie_partition_key */);
GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(),
GetHandle()->OnCookiesAccessed(web_contents()->GetPrimaryMainFrame(),
{content::CookieAccessDetails::Type::kRead,
GURL("https://www.google.com"),
GURL("https://www.google.com"),
@ -470,7 +477,8 @@ TEST_F(PageSpecificContentSettingsTest,
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* content_settings =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
// First trigger OnContentBlocked.
EXPECT_FALSE(content_settings->IsContentBlocked(
@ -567,11 +575,11 @@ TEST_F(PageSpecificContentSettingsWithPrerenderTest, SiteDataAccessed) {
EXPECT_CALL(mock_observer, OnSiteDataAccessed()).Times(1);
std::unique_ptr<content::NavigationSimulator> navigation =
content::NavigationSimulator::CreateRendererInitiated(
prerender_url, web_contents()->GetMainFrame());
prerender_url, web_contents()->GetPrimaryMainFrame());
// TODO(https://crbug.com/1181763): Investigate how default referrer value
// is set and update here accordingly.
navigation->SetReferrer(blink::mojom::Referrer::New(
web_contents()->GetMainFrame()->GetLastCommittedURL(),
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
network::mojom::ReferrerPolicy::kStrictOriginWhenCrossOrigin));
navigation->Commit();
}
@ -624,9 +632,9 @@ TEST_F(PageSpecificContentSettingsWithPrerenderTest,
.Times(1);
std::unique_ptr<content::NavigationSimulator> navigation =
content::NavigationSimulator::CreateRendererInitiated(
prerender_url, web_contents()->GetMainFrame());
prerender_url, web_contents()->GetPrimaryMainFrame());
navigation->SetReferrer(blink::mojom::Referrer::New(
web_contents()->GetMainFrame()->GetLastCommittedURL(),
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
network::mojom::ReferrerPolicy::kStrictOriginWhenCrossOrigin));
navigation->Commit();
}
@ -648,7 +656,7 @@ TEST_F(PageSpecificContentSettingsWithPrerenderTest,
EXPECT_CALL(*mock_delegate, UpdateLocationBar()).Times(1);
std::unique_ptr<content::NavigationSimulator> navigation =
content::NavigationSimulator::CreateRendererInitiated(
prerender_url, web_contents()->GetMainFrame());
prerender_url, web_contents()->GetPrimaryMainFrame());
navigation->Commit();
}
@ -673,19 +681,19 @@ TEST_F(PageSpecificContentSettingsWithPrerenderTest, ContentAllowedAndBlocked) {
.Times(1);
std::unique_ptr<content::NavigationSimulator> navigation =
content::NavigationSimulator::CreateRendererInitiated(
prerender_url, web_contents()->GetMainFrame());
prerender_url, web_contents()->GetPrimaryMainFrame());
// TODO(https://crbug.com/1181763): Investigate how default referrer value is
// set and update here accordingly.
navigation->SetReferrer(blink::mojom::Referrer::New(
web_contents()->GetMainFrame()->GetLastCommittedURL(),
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
network::mojom::ReferrerPolicy::kStrictOriginWhenCrossOrigin));
navigation->Commit();
}
TEST_F(PageSpecificContentSettingsTest, Topics) {
NavigateAndCommit(GURL("http://google.com"));
PageSpecificContentSettings* pscs =
PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame());
PageSpecificContentSettings* pscs = PageSpecificContentSettings::GetForFrame(
web_contents()->GetPrimaryMainFrame());
EXPECT_FALSE(pscs->HasAccessedTopics());
EXPECT_THAT(pscs->GetAccessedTopics(), testing::IsEmpty());
@ -709,7 +717,8 @@ class PageSpecificContentSettingsWithFencedFrameTest
content::RenderFrameHost* CreateFencedFrame(const GURL& url) {
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(
web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
std::unique_ptr<content::NavigationSimulator> navigation_simulator =
content::NavigationSimulator::CreateRendererInitiated(

@ -34,8 +34,8 @@ void SearchResultExtractorClient::RequestData(
content::WebContents* web_contents,
const std::vector<mojom::ResultType>& result_types,
RequestDataCallback callback) {
if (!web_contents || !web_contents->GetMainFrame() ||
!web_contents->GetMainFrame()->GetRemoteAssociatedInterfaces()) {
if (!web_contents || !web_contents->GetPrimaryMainFrame() ||
!web_contents->GetPrimaryMainFrame()->GetRemoteAssociatedInterfaces()) {
std::move(callback).Run(SearchResultExtractorClientStatus::kWebContentsGone,
mojom::CategoryResults::New());
return;
@ -50,8 +50,9 @@ void SearchResultExtractorClient::RequestData(
}
mojo::AssociatedRemote<mojom::SearchResultExtractor> extractor;
web_contents->GetMainFrame()->GetRemoteAssociatedInterfaces()->GetInterface(
extractor.BindNewEndpointAndPassReceiver());
web_contents->GetPrimaryMainFrame()
->GetRemoteAssociatedInterfaces()
->GetInterface(extractor.BindNewEndpointAndPassReceiver());
mojom::SearchResultExtractor* extractor_ptr = extractor.get();
extractor_ptr->ExtractCurrentSearchResults(

@ -74,7 +74,7 @@ class SearchResultExtractorClientRenderViewHostTest
// interface.
void OverrideInterface(FakeSearchResultExtractor* extractor) {
web_contents()
->GetMainFrame()
->GetPrimaryMainFrame()
->GetRemoteAssociatedInterfaces()
->OverrideBinderForTesting(
mojom::SearchResultExtractor::Name_,

@ -157,7 +157,7 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, FencedFrame) {
// Create a FencedFrame.
content::RenderFrameHost* fenced_frame_host =
fenced_frame_test_helper().CreateFencedFrame(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
embedded_test_server()->GetURL("/fenced_frames/title1.html"));
ASSERT_TRUE(fenced_frame_host);

@ -107,7 +107,7 @@ bool StatementHasMatchingFingerprint(const base::Value& statement,
void AddMessageToConsole(content::WebContents* web_contents,
const std::string& message) {
if (web_contents) {
web_contents->GetMainFrame()->AddMessageToConsole(
web_contents->GetPrimaryMainFrame()->AddMessageToConsole(
blink::mojom::ConsoleMessageLevel::kWarning, message);
return;
}

@ -38,7 +38,7 @@ void OnExtractFeaturesJsResult(const DistillablePageDetector* detector,
void IsDistillablePageForDetector(content::WebContents* web_contents,
const DistillablePageDetector* detector,
base::OnceCallback<void(bool)> callback) {
content::RenderFrameHost* main_frame = web_contents->GetMainFrame();
content::RenderFrameHost* main_frame = web_contents->GetPrimaryMainFrame();
if (!main_frame) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), false));

@ -110,7 +110,7 @@ void DomDistillerViewerSource::RequestViewerHandle::SendJavaScript(
} else {
DCHECK(buffer_.empty());
if (web_contents()) {
RunIsolatedJavaScript(web_contents()->GetMainFrame(), buffer);
RunIsolatedJavaScript(web_contents()->GetPrimaryMainFrame(), buffer);
}
}
}
@ -186,7 +186,7 @@ void DomDistillerViewerSource::RequestViewerHandle::DOMContentLoaded(
// No SendJavaScript() calls allowed before |buffer_| is run and cleared.
waiting_for_page_ready_ = false;
if (!buffer_.empty()) {
RunIsolatedJavaScript(web_contents()->GetMainFrame(), buffer_);
RunIsolatedJavaScript(web_contents()->GetPrimaryMainFrame(), buffer_);
buffer_.clear();
}
// No need to Cancel() here.

@ -149,7 +149,7 @@ IN_PROC_BROWSER_TEST_F(DomDistillerJsTest, MAYBE_RunJsTests) {
// QuitClosure multiple times.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), TestTimeouts::action_max_timeout());
web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
web_contents->GetPrimaryMainFrame()->ExecuteJavaScriptForTests(
base::UTF8ToUTF16(kRunJsTestsJs),
base::BindOnce(&DomDistillerJsTest::OnJsTestExecutionDone,
base::Unretained(this)));

@ -291,7 +291,7 @@ void NetErrorAutoReloader::ReloadMainFrame() {
++num_reloads_for_current_error_;
is_auto_reload_in_progress_ = true;
web_contents()->GetMainFrame()->Reload();
web_contents()->GetPrimaryMainFrame()->Reload();
}
std::unique_ptr<content::NavigationThrottle>

@ -562,7 +562,7 @@ IN_PROC_BROWSER_TEST_F(NetErrorAutoReloaderFencedFrameBrowserTest,
const GURL fenced_frame_url = embedded_test_server()->GetURL("/title2.html");
content::RenderFrameHost* fenced_frame_host =
fenced_frame_test_helper().CreateFencedFrame(
shell()->web_contents()->GetMainFrame(), fenced_frame_url,
shell()->web_contents()->GetPrimaryMainFrame(), fenced_frame_url,
net::ERR_BLOCKED_BY_RESPONSE);
// The fenced frame navigation failed since it doesn't have the

@ -39,7 +39,7 @@ void TestFetchFaviconForPage(
ContentFaviconDriver::FromWebContents(web_contents);
content::WebContentsTester::For(web_contents)->NavigateAndCommit(page_url);
static_cast<content::WebContentsObserver*>(favicon_driver)
->DidUpdateFaviconURL(web_contents->GetMainFrame(), candidates);
->DidUpdateFaviconURL(web_contents->GetPrimaryMainFrame(), candidates);
base::RunLoop().RunUntilIdle();
}
@ -116,13 +116,14 @@ TEST_F(ContentFaviconDriverTest, IgnoreManifestURLBeforeOnLoad) {
navigation->SetKeepLoading(true);
navigation->Commit();
GURL manifest_url = kFakeManifestURL;
auto* rfh_tester =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame());
auto* rfh_tester = content::RenderFrameHostTester::For(
web_contents()->GetPrimaryMainFrame());
rfh_tester->SimulateManifestURLUpdate(manifest_url);
static_cast<content::WebContentsObserver*>(favicon_driver)
->DidUpdateWebManifestURL(web_contents()->GetMainFrame(), manifest_url);
EXPECT_EQ(GURL(),
favicon_driver->GetManifestURL(web_contents()->GetMainFrame()));
->DidUpdateWebManifestURL(web_contents()->GetPrimaryMainFrame(),
manifest_url);
EXPECT_EQ(GURL(), favicon_driver->GetManifestURL(
web_contents()->GetPrimaryMainFrame()));
}
// Ensures that we use a manifest URL if it arrives after the onload handler
@ -136,13 +137,14 @@ TEST_F(ContentFaviconDriverTest, UseManifestURLAFterOnLoad) {
navigation->Commit();
navigation->StopLoading();
GURL manifest_url = kFakeManifestURL;
auto* rfh_tester =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame());
auto* rfh_tester = content::RenderFrameHostTester::For(
web_contents()->GetPrimaryMainFrame());
rfh_tester->SimulateManifestURLUpdate(manifest_url);
static_cast<content::WebContentsObserver*>(favicon_driver)
->DidUpdateWebManifestURL(web_contents()->GetMainFrame(), manifest_url);
EXPECT_EQ(kFakeManifestURL,
favicon_driver->GetManifestURL(web_contents()->GetMainFrame()));
->DidUpdateWebManifestURL(web_contents()->GetPrimaryMainFrame(),
manifest_url);
EXPECT_EQ(kFakeManifestURL, favicon_driver->GetManifestURL(
web_contents()->GetPrimaryMainFrame()));
}
// Test that no download is initiated when
@ -159,7 +161,8 @@ TEST_F(ContentFaviconDriverTest, ShouldNotCauseImageDownload) {
favicon_urls.push_back(blink::mojom::FaviconURL::New(
kIconURL, blink::mojom::FaviconIconType::kFavicon, kEmptyIconSizes));
static_cast<content::WebContentsObserver*>(favicon_driver)
->DidUpdateFaviconURL(web_contents()->GetMainFrame(), favicon_urls);
->DidUpdateFaviconURL(web_contents()->GetPrimaryMainFrame(),
favicon_urls);
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(web_contents_tester()->HasPendingDownloadImage(kIconURL));
@ -223,7 +226,7 @@ TEST_F(ContentFaviconDriverTestNoFaviconService,
// Trigger downloading a manifest.
static_cast<content::WebContentsObserver*>(driver)->DidUpdateWebManifestURL(
web_contents()->GetMainFrame(), GURL("http://bad.manifest.com"));
web_contents()->GetPrimaryMainFrame(), GURL("http://bad.manifest.com"));
// The request for the manifest is still pending, delete the WebContents,
// which should trigger notifying the callback for the manifest and *not*

@ -127,8 +127,9 @@ void FindTabHelper::StopFinding(SelectionAction selection_action) {
}
void FindTabHelper::ActivateFindInPageResultForAccessibility() {
GetWebContents().GetMainFrame()->ActivateFindInPageResultForAccessibility(
current_find_request_id_);
GetWebContents()
.GetPrimaryMainFrame()
->ActivateFindInPageResultForAccessibility(current_find_request_id_);
}
std::u16string FindTabHelper::GetInitialSearchText() {

@ -416,7 +416,10 @@ WebContents* GuestViewBase::GetOwnerWebContents() {
}
const GURL& GuestViewBase::GetOwnerSiteURL() const {
return owner_web_contents()->GetMainFrame()->GetSiteInstance()->GetSiteURL();
return owner_web_contents()
->GetPrimaryMainFrame()
->GetSiteInstance()
->GetSiteURL();
}
bool GuestViewBase::ShouldDestroyOnDetach() const {
@ -554,7 +557,7 @@ double GuestViewBase::PhysicalPixelsToLogicalPixels(int physical_pixels) const {
void GuestViewBase::DidStopLoading() {
content::RenderViewHost* rvh =
web_contents()->GetMainFrame()->GetRenderViewHost();
web_contents()->GetPrimaryMainFrame()->GetRenderViewHost();
if (IsPreferredSizeModeEnabled())
rvh->EnablePreferredSizeMode();

@ -520,7 +520,7 @@ bool GuestViewManager::CanEmbedderAccessInstanceID(
guest_view->CanBeEmbeddedInsideCrossProcessFrames()
? guest_view->GetOwnerSiteInstance()->GetProcess()->GetID()
: guest_view->owner_web_contents()
->GetMainFrame()
->GetPrimaryMainFrame()
->GetProcess()
->GetID();

@ -85,8 +85,9 @@ std::u16string AppModalDialogManager::GetTitle(
return base::UTF8ToUTF16(name);
// Otherwise, return the formatted URL.
return GetTitleImpl(web_contents->GetMainFrame()->GetLastCommittedOrigin(),
alerting_frame_origin);
return GetTitleImpl(
web_contents->GetPrimaryMainFrame()->GetLastCommittedOrigin(),
alerting_frame_origin);
}
namespace {

@ -69,12 +69,12 @@ DialogOriginRelationship GetDialogOriginRelationship(
content::WebContents* web_contents,
content::RenderFrameHost* alerting_frame) {
url::Origin main_frame_origin =
web_contents->GetMainFrame()->GetLastCommittedOrigin();
web_contents->GetPrimaryMainFrame()->GetLastCommittedOrigin();
if (!main_frame_origin.GetURL().SchemeIsHTTPOrHTTPS())
return DialogOriginRelationship::NON_HTTP_MAIN_FRAME;
if (alerting_frame == web_contents->GetMainFrame())
if (alerting_frame == web_contents->GetPrimaryMainFrame())
return DialogOriginRelationship::HTTP_MAIN_FRAME;
url::Origin alerting_frame_origin = alerting_frame->GetLastCommittedOrigin();
@ -377,8 +377,9 @@ void TabModalDialogManager::LogDialogDismissalCause(DismissalCause cause) {
// WebContents that had the alert call in it. For 99.9999% of cases they're
// the same, but for instances like the <webview> tag in extensions and PDF
// files that alert they may differ.
ukm::SourceId source_id =
WebContentsObserver::web_contents()->GetMainFrame()->GetPageUkmSourceId();
ukm::SourceId source_id = WebContentsObserver::web_contents()
->GetPrimaryMainFrame()
->GetPageUkmSourceId();
if (source_id != ukm::kInvalidSourceId) {
ukm::builders::AbusiveExperienceHeuristic_JavaScriptDialog(source_id)
.SetDismissalCause(static_cast<int64_t>(cause))

@ -115,7 +115,7 @@ JsCommunicationHost::AddDocumentStartJavaScript(
scripts_.emplace_back(script, origin_matcher, next_script_id_++);
ForEachRenderFrameHostWithinSameWebContents(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
base::BindRepeating(
&JsCommunicationHost::NotifyFrameForAddDocumentStartJavaScript,
base::Unretained(this), &*scripts_.rbegin()));
@ -128,7 +128,7 @@ bool JsCommunicationHost::RemoveDocumentStartJavaScript(int script_id) {
if (it->script_id_ == script_id) {
scripts_.erase(it);
ForEachRenderFrameHostWithinSameWebContents(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
base::BindRepeating(
&JsCommunicationHost::NotifyFrameForRemoveDocumentStartJavaScript,
base::Unretained(this), script_id));
@ -158,7 +158,7 @@ std::u16string JsCommunicationHost::AddWebMessageHostFactory(
js_object_name, origin_matcher, std::move(factory)));
ForEachRenderFrameHostWithinSameWebContents(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
base::BindRepeating(
&JsCommunicationHost::NotifyFrameForWebMessageListener,
base::Unretained(this)));
@ -172,7 +172,7 @@ void JsCommunicationHost::RemoveWebMessageHostFactory(
if ((*iterator)->name == js_object_name) {
js_objects_.erase(iterator);
ForEachRenderFrameHostWithinSameWebContents(
web_contents()->GetMainFrame(),
web_contents()->GetPrimaryMainFrame(),
base::BindRepeating(
&JsCommunicationHost::NotifyFrameForWebMessageListener,
base::Unretained(this)));

@ -112,7 +112,7 @@ void JsToBrowserMessaging::PostMessage(
if (!host_) {
const std::string origin_string = GetOriginString(source_origin);
const bool is_main_frame =
web_contents->GetMainFrame() == render_frame_host_;
web_contents->GetPrimaryMainFrame() == render_frame_host_;
host_ = connection_factory_->CreateHost(origin_string, is_main_frame,
reply_proxy_.get());
@ -127,7 +127,8 @@ void JsToBrowserMessaging::PostMessage(
// PostMessage() has been received.
#if DCHECK_IS_ON()
DCHECK_EQ(GetOriginString(source_origin), origin_string_);
DCHECK_EQ(is_main_frame_, web_contents->GetMainFrame() == render_frame_host_);
DCHECK_EQ(is_main_frame_,
web_contents->GetPrimaryMainFrame() == render_frame_host_);
#endif
std::unique_ptr<WebMessage> web_message = std::make_unique<WebMessage>();
web_message->message = message;

@ -74,18 +74,18 @@ class SubprocessMetricsProviderBrowserTest
base::PersistentHistogramAllocator* GetMainFrameAllocator() {
return get_allocators_by_id().Lookup(
shell()->web_contents()->GetMainFrame()->GetProcess()->GetID());
shell()->web_contents()->GetPrimaryMainFrame()->GetProcess()->GetID());
}
void SimulateRenderProcessExit() {
provider_->RenderProcessExited(
shell()->web_contents()->GetMainFrame()->GetProcess(),
shell()->web_contents()->GetPrimaryMainFrame()->GetProcess(),
content::ChildProcessTerminationInfo());
}
void SimulateRenderProcessHostDestroyed() {
provider_->RenderProcessHostDestroyed(
shell()->web_contents()->GetMainFrame()->GetProcess());
shell()->web_contents()->GetPrimaryMainFrame()->GetProcess());
}
protected:
@ -153,7 +153,7 @@ IN_PROC_BROWSER_TEST_F(SubprocessMetricsProviderBrowserTest,
<< " The histogram in the context is " << render_process_histogram;
auto* main_frame_process_host =
shell()->web_contents()->GetMainFrame()->GetProcess();
shell()->web_contents()->GetPrimaryMainFrame()->GetProcess();
SimulateRenderProcessHostDestroyed();
// Verify the observer removed.
EXPECT_FALSE(
@ -200,7 +200,7 @@ IN_PROC_BROWSER_TEST_F(SubprocessMetricsProviderBrowserTest,
<< " The histogram in the context is " << render_process_histogram;
auto* main_frame_process_host =
shell()->web_contents()->GetMainFrame()->GetProcess();
shell()->web_contents()->GetPrimaryMainFrame()->GetProcess();
SimulateRenderProcessHostDestroyed();
// Verify the observer removed.
EXPECT_FALSE(

@ -210,7 +210,7 @@ void NoStatePrefetchContents::StartPrerendering(
// TODO(davidben): This logic assumes each prerender has at most one
// process. https://crbug.com/440544
no_state_prefetch_manager()->AddPrerenderProcessHost(
GetMainFrame()->GetProcess());
GetPrimaryMainFrame()->GetProcess());
NotifyPrefetchStart();
@ -437,7 +437,7 @@ void NoStatePrefetchContents::Destroy(FinalStatus final_status) {
void NoStatePrefetchContents::DestroyWhenUsingTooManyResources() {
if (process_pid_ == base::kNullProcessId) {
RenderFrameHost* rfh = GetMainFrame();
RenderFrameHost* rfh = GetPrimaryMainFrame();
if (!rfh)
return;
@ -484,9 +484,9 @@ void NoStatePrefetchContents::DidGetMemoryUsage(
}
}
RenderFrameHost* NoStatePrefetchContents::GetMainFrame() {
RenderFrameHost* NoStatePrefetchContents::GetPrimaryMainFrame() {
return no_state_prefetch_contents_
? no_state_prefetch_contents_->GetMainFrame()
? no_state_prefetch_contents_->GetPrimaryMainFrame()
: nullptr;
}

@ -124,7 +124,7 @@ class NoStatePrefetchContents : public content::WebContentsObserver,
// it if not.
void DestroyWhenUsingTooManyResources();
content::RenderFrameHost* GetMainFrame();
content::RenderFrameHost* GetPrimaryMainFrame();
NoStatePrefetchManager* no_state_prefetch_manager() {
return no_state_prefetch_manager_;

@ -205,7 +205,8 @@ class TestPageTextObserver : public PageTextObserver {
}
void CallDidFinishLoad() {
PageTextObserver::DidFinishLoad(web_contents()->GetMainFrame(), GURL());
PageTextObserver::DidFinishLoad(web_contents()->GetPrimaryMainFrame(),
GURL());
}
private:
@ -273,7 +274,7 @@ TEST_F(PageTextObserverTest, ConsumerNotCalledSubframe) {
content::NavigationSimulator::NavigateAndCommitFromDocument(
GURL("http://subframe.com"),
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
EXPECT_FALSE(consumer.was_called());
@ -1112,7 +1113,7 @@ TEST_F(PageTextObserverWithPrerenderTest,
// Activate the prerendered page.
content::NavigationSimulator::NavigateAndCommitFromDocument(
prerender_url, web_contents()->GetMainFrame());
prerender_url, web_contents()->GetPrimaryMainFrame());
EXPECT_EQ(prerender_frame->GetLifecycleState(),
content::RenderFrameHost::LifecycleState::kActive);
EXPECT_TRUE(consumer.was_called());

@ -419,7 +419,7 @@ void PageInfo::RecordPageInfoAction(PageInfoAction action) {
if (web_contents_) {
ukm::builders::PageInfoBubble(
web_contents_->GetMainFrame()->GetPageUkmSourceId())
web_contents_->GetPrimaryMainFrame()->GetPageUkmSourceId())
.SetActionTaken(action)
.Record(ukm::UkmRecorder::Get());
}
@ -1288,7 +1288,7 @@ PageInfo::GetPageSpecificContentSettings() const {
// anything?
DCHECK(web_contents_);
return content_settings::PageSpecificContentSettings::GetForFrame(
web_contents_->GetMainFrame());
web_contents_->GetPrimaryMainFrame());
}
bool PageInfo::HasContentSettingChangedViaPageInfo(ContentSettingsType type) {

@ -249,7 +249,8 @@ MetricsWebContentsObserver::MetricsWebContentsObserver(
if (embedder_interface_->IsNoStatePrefetch(web_contents))
in_foreground_ = false;
RegisterInputEventObserver(web_contents->GetMainFrame()->GetRenderViewHost());
RegisterInputEventObserver(
web_contents->GetPrimaryMainFrame()->GetRenderViewHost());
}
void MetricsWebContentsObserver::WillStartNavigationRequestImpl(

@ -112,7 +112,7 @@ class MetricsWebContentsObserverTest
}
void SimulateTimingUpdate(const mojom::PageLoadTiming& timing) {
SimulateTimingUpdate(timing, web_contents()->GetMainFrame());
SimulateTimingUpdate(timing, web_contents()->GetPrimaryMainFrame());
}
void SimulateCpuTimingUpdate(const mojom::CpuTiming& timing,
@ -1294,14 +1294,14 @@ TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_MainFrame) {
auto navigation_simulator =
content::NavigationSimulator::CreateRendererInitiated(
main_resource_url, web_contents()->GetMainFrame());
main_resource_url, web_contents()->GetPrimaryMainFrame());
navigation_simulator->Start();
navigation_simulator->Commit();
const auto request_id = navigation_simulator->GetGlobalRequestID();
observer()->ResourceLoadComplete(
web_contents()->GetMainFrame(), request_id,
web_contents()->GetPrimaryMainFrame(), request_id,
*CreateResourceLoadInfo(main_resource_url,
network::mojom::RequestDestination::kFrame));
EXPECT_EQ(1u, loaded_resources().size());
@ -1313,7 +1313,7 @@ TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_MainFrame) {
// Deliver a second main frame resource. This one should be ignored, since the
// specified |request_id| is no longer associated with any tracked page loads.
observer()->ResourceLoadComplete(
web_contents()->GetMainFrame(), request_id,
web_contents()->GetPrimaryMainFrame(), request_id,
*CreateResourceLoadInfo(main_resource_url,
network::mojom::RequestDestination::kFrame));
EXPECT_EQ(1u, loaded_resources().size());
@ -1326,7 +1326,7 @@ TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_Subresource) {
web_contents(), GURL(kDefaultTestUrl));
GURL loaded_resource_url("http://www.other.com/");
observer()->ResourceLoadComplete(
web_contents()->GetMainFrame(), content::GlobalRequestID(),
web_contents()->GetPrimaryMainFrame(), content::GlobalRequestID(),
*CreateResourceLoadInfo(loaded_resource_url,
network::mojom::RequestDestination::kScript));
@ -1340,7 +1340,7 @@ TEST_F(MetricsWebContentsObserverTest,
content::NavigationSimulator::NavigateAndCommitFromBrowser(
web_contents(), GURL(kDefaultTestUrl));
content::RenderFrameHost* old_rfh = web_contents()->GetMainFrame();
content::RenderFrameHost* old_rfh = web_contents()->GetPrimaryMainFrame();
content::LeaveInPendingDeletionState(old_rfh);
content::NavigationSimulator::NavigateAndCommitFromBrowser(
@ -1361,7 +1361,7 @@ TEST_F(MetricsWebContentsObserverTest,
web_contents(), GURL(kDefaultTestUrl));
GURL loaded_resource_url("data:text/html,Hello world");
observer()->ResourceLoadComplete(
web_contents()->GetMainFrame(), content::GlobalRequestID(),
web_contents()->GetPrimaryMainFrame(), content::GlobalRequestID(),
*CreateResourceLoadInfo(loaded_resource_url,
network::mojom::RequestDestination::kScript));

@ -613,7 +613,8 @@ void AdsPageLoadMetricsObserver::OnMainFrameIntersectionRectChanged(
content::RenderFrameHost* render_frame_host,
const gfx::Rect& main_frame_intersection_rect) {
int frame_tree_node_id = render_frame_host->GetFrameTreeNodeId();
if (render_frame_host == GetDelegate().GetWebContents()->GetMainFrame()) {
if (render_frame_host ==
GetDelegate().GetWebContents()->GetPrimaryMainFrame()) {
page_ad_density_tracker_.UpdateMainFrameRect(main_frame_intersection_rect);
return;
}
@ -661,7 +662,7 @@ void AdsPageLoadMetricsObserver::CheckForAdDensityViolation() {
// violations after the first are ignored. Ad frame violations are
// attributed to the main frame url.
throttle_manager->OnAdsViolationTriggered(
GetDelegate().GetWebContents()->GetMainFrame(),
GetDelegate().GetWebContents()->GetPrimaryMainFrame(),
subresource_filter::mojom::AdsViolation::
kMobileAdDensityByHeightAbove30);
}
@ -1211,7 +1212,7 @@ void AdsPageLoadMetricsObserver::MaybeTriggerStrictHeavyAdIntervention() {
// violations after the first are ignored. Ad frame violations are
// attributed to the main frame url.
throttle_manager->OnAdsViolationTriggered(
GetDelegate().GetWebContents()->GetMainFrame(),
GetDelegate().GetWebContents()->GetPrimaryMainFrame(),
subresource_filter::mojom::AdsViolation::
kHeavyAdsInterventionAtHostLimit);
}

@ -482,7 +482,7 @@ class AdsPageLoadMetricsObserverTest
// Returns the final RenderFrameHost after navigation commits.
RenderFrameHost* NavigateMainFrame(const std::string& url) {
return NavigateFrame(url, web_contents()->GetMainFrame());
return NavigateFrame(url, web_contents()->GetPrimaryMainFrame());
}
void OnCpuTimingUpdate(RenderFrameHost* render_frame_host,
@ -1245,8 +1245,8 @@ TEST_P(AdsPageLoadMetricsObserverTest, UntaggingAdFrame) {
TEST_P(AdsPageLoadMetricsObserverTest, MainFrameResource) {
// Start main-frame navigation
auto navigation_simulator =
CreateNavigationSimulator(kNonAdUrl, web_contents()->GetMainFrame());
auto navigation_simulator = CreateNavigationSimulator(
kNonAdUrl, web_contents()->GetPrimaryMainFrame());
navigation_simulator->Start();
navigation_simulator->Commit();
@ -1290,8 +1290,8 @@ TEST_P(AdsPageLoadMetricsObserverTest, MainFrameResource) {
TEST_P(AdsPageLoadMetricsObserverTest, NoBytesLoaded_NoHistogramsRecorded) {
// Start main-frame navigation
auto navigation_simulator =
CreateNavigationSimulator(kNonAdUrl, web_contents()->GetMainFrame());
auto navigation_simulator = CreateNavigationSimulator(
kNonAdUrl, web_contents()->GetPrimaryMainFrame());
navigation_simulator->Start();
navigation_simulator->Commit();

@ -133,7 +133,7 @@ TEST_F(BackForwardCachePageLoadMetricsObserverTest,
navigation_handle_.set_is_served_from_bfcache(true);
tester()->SimulateMetadataUpdate(NonAmpMetadata(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
observer_->OnRestoreFromBackForwardCache(timing_, &navigation_handle_);
AssertHistoryNavigationRecordedAmpNavigation(false);
@ -145,7 +145,7 @@ TEST_F(BackForwardCachePageLoadMetricsObserverTest,
navigation_handle_.set_is_served_from_bfcache(true);
tester()->SimulateMetadataUpdate(AmpMetadata(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
observer_->OnRestoreFromBackForwardCache(timing_, &navigation_handle_);
AssertHistoryNavigationRecordedAmpNavigation(true);
@ -157,7 +157,7 @@ TEST_F(BackForwardCachePageLoadMetricsObserverTest,
navigation_handle_.set_is_served_from_bfcache(false);
tester()->SimulateMetadataUpdate(NonAmpMetadata(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
// Since there was no call to observer_->OnRestoreFromBackForwardCache, there
// should be no HistoryNavigation UKM entry.

@ -678,9 +678,11 @@ TEST_F(UmaPageLoadMetricsObserverTest, BytesAndResourcesCounted) {
TEST_F(UmaPageLoadMetricsObserverTest, CpuUsageCounted) {
NavigateAndCommit(GURL(kDefaultTestUrl));
OnCpuTimingUpdate(web_contents()->GetMainFrame(), base::Milliseconds(750));
OnCpuTimingUpdate(web_contents()->GetPrimaryMainFrame(),
base::Milliseconds(750));
web_contents()->WasHidden(); // Set the web contents as backgrounded.
OnCpuTimingUpdate(web_contents()->GetMainFrame(), base::Milliseconds(250));
OnCpuTimingUpdate(web_contents()->GetPrimaryMainFrame(),
base::Milliseconds(250));
NavigateAndCommit(GURL(kDefaultTestUrl2));
tester()->histogram_tester().ExpectUniqueSample(
@ -784,7 +786,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -827,7 +829,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -864,7 +866,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -910,7 +912,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -955,7 +957,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -996,7 +998,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -1044,7 +1046,7 @@ TEST_F(
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -1399,7 +1401,7 @@ TEST_F(UmaPageLoadMetricsObserverTest, SingleSubFrame_MaxMemoryBytesRecorded) {
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL("https://google.com/subframe.html"),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Notify that memory measurements are available for each frame.
@ -1430,12 +1432,12 @@ TEST_F(UmaPageLoadMetricsObserverTest, MultiSubFrames_MaxMemoryBytesRecorded) {
RenderFrameHost* subframe1 =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL("https://google.com/subframe.html"),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe1"));
RenderFrameHost* subframe2 =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL("https://google.com/subframe2.html"),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe2"));
RenderFrameHost* subframe3 =
NavigationSimulator::NavigateAndCommitFromDocument(
@ -1502,7 +1504,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -1545,7 +1547,7 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSubframeTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe"));
// Simulate timing updates in the main frame and the subframe.
@ -1599,12 +1601,12 @@ TEST_F(UmaPageLoadMetricsObserverTest,
RenderFrameHost* first_party_subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kSameSiteSubFrameTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe1"));
RenderFrameHost* cross_site_subframe =
NavigationSimulator::NavigateAndCommitFromDocument(
GURL(kCrossSiteSubFrameTestUrl),
RenderFrameHostTester::For(web_contents()->GetMainFrame())
RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendChild("subframe2"));
// Simulate timing updates in the main frame and the subframe.

@ -82,7 +82,7 @@ TEST_F(FencedFramesPageLoadMetricsObserverTest, Foreground) {
NavigateAndCommit(GURL(kTestUrl));
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
ASSERT_TRUE(fenced_frame_root->IsFencedFrameRoot());
@ -129,7 +129,7 @@ TEST_F(FencedFramesPageLoadMetricsObserverTest, Background) {
web_contents()->WasHidden();
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
ASSERT_TRUE(fenced_frame_root->IsFencedFrameRoot());

@ -125,7 +125,7 @@ void PageLoadMetricsObserverTester::NavigateToUntrackedUrl() {
void PageLoadMetricsObserverTester::SimulateTimingUpdate(
const mojom::PageLoadTiming& timing) {
SimulateTimingUpdate(timing, web_contents()->GetMainFrame());
SimulateTimingUpdate(timing, web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateTimingUpdate(
@ -139,7 +139,7 @@ void PageLoadMetricsObserverTester::SimulateTimingUpdate(
void PageLoadMetricsObserverTester::SimulateCpuTimingUpdate(
const mojom::CpuTiming& cpu_timing) {
SimulateCpuTimingUpdate(cpu_timing, web_contents()->GetMainFrame());
SimulateCpuTimingUpdate(cpu_timing, web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateCpuTimingUpdate(
@ -155,7 +155,8 @@ void PageLoadMetricsObserverTester::SimulateCpuTimingUpdate(
void PageLoadMetricsObserverTester::SimulateInputTimingUpdate(
const mojom::InputTiming& input_timing) {
SimulateInputTimingUpdate(input_timing, web_contents()->GetMainFrame());
SimulateInputTimingUpdate(input_timing,
web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateMobileFriendlinessUpdate(
@ -186,7 +187,7 @@ void PageLoadMetricsObserverTester::SimulateTimingAndMetadataUpdate(
SimulatePageLoadTimingUpdate(
timing, metadata, /* new_features= */ {}, mojom::FrameRenderDataUpdate(),
mojom::CpuTiming(), mojom::InputTiming(), blink::MobileFriendliness(),
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateMetadataUpdate(
@ -205,12 +206,12 @@ void PageLoadMetricsObserverTester::SimulateFeaturesUpdate(
SimulatePageLoadTimingUpdate(
mojom::PageLoadTiming(), mojom::FrameMetadata(), new_features,
mojom::FrameRenderDataUpdate(), mojom::CpuTiming(), mojom::InputTiming(),
blink::MobileFriendliness(), web_contents()->GetMainFrame());
blink::MobileFriendliness(), web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateRenderDataUpdate(
const mojom::FrameRenderDataUpdate& render_data) {
SimulateRenderDataUpdate(render_data, web_contents()->GetMainFrame());
SimulateRenderDataUpdate(render_data, web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateRenderDataUpdate(
@ -247,7 +248,8 @@ void PageLoadMetricsObserverTester::SimulatePageLoadTimingUpdate(
void PageLoadMetricsObserverTester::SimulateResourceDataUseUpdate(
const std::vector<mojom::ResourceDataUpdatePtr>& resources) {
SimulateResourceDataUseUpdate(resources, web_contents()->GetMainFrame());
SimulateResourceDataUseUpdate(resources,
web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateResourceDataUseUpdate(
@ -294,7 +296,7 @@ void PageLoadMetricsObserverTester::SimulateLoadedResource(
resource_load_info.load_timing_info.request_start = base::TimeTicks::Now();
metrics_web_contents_observer_->ResourceLoadComplete(
web_contents()->GetMainFrame(), request_id, resource_load_info);
web_contents()->GetPrimaryMainFrame(), request_id, resource_load_info);
}
void PageLoadMetricsObserverTester::SimulateFrameReceivedUserActivation(
@ -313,7 +315,7 @@ void PageLoadMetricsObserverTester::SimulateAppEnterBackground() {
}
void PageLoadMetricsObserverTester::SimulateMediaPlayed() {
SimulateMediaPlayed(web_contents()->GetMainFrame());
SimulateMediaPlayed(web_contents()->GetPrimaryMainFrame());
}
void PageLoadMetricsObserverTester::SimulateMediaPlayed(
@ -327,7 +329,8 @@ void PageLoadMetricsObserverTester::SimulateMediaPlayed(
void PageLoadMetricsObserverTester::SimulateCookieAccess(
const content::CookieAccessDetails& details) {
metrics_web_contents_observer_->OnCookiesAccessed(
metrics_web_contents_observer_->web_contents()->GetMainFrame(), details);
metrics_web_contents_observer_->web_contents()->GetPrimaryMainFrame(),
details);
}
void PageLoadMetricsObserverTester::SimulateStorageAccess(
@ -336,8 +339,8 @@ void PageLoadMetricsObserverTester::SimulateStorageAccess(
bool blocked_by_policy,
StorageType storage_type) {
metrics_web_contents_observer_->OnStorageAccessed(
metrics_web_contents_observer_->web_contents()->GetMainFrame(), url,
first_party_url, blocked_by_policy, storage_type);
metrics_web_contents_observer_->web_contents()->GetPrimaryMainFrame(),
url, first_party_url, blocked_by_policy, storage_type);
}
void PageLoadMetricsObserverTester::SimulateMobileFriendlinessUpdate(
@ -345,7 +348,7 @@ void PageLoadMetricsObserverTester::SimulateMobileFriendlinessUpdate(
SimulatePageLoadTimingUpdate(
mojom::PageLoadTiming(), mojom::FrameMetadata(), /* new_features= */ {},
mojom::FrameRenderDataUpdate(), mojom::CpuTiming(), mojom::InputTiming(),
mobile_friendliness, web_contents()->GetMainFrame());
mobile_friendliness, web_contents()->GetPrimaryMainFrame());
}
const PageLoadMetricsObserverDelegate&

@ -88,7 +88,8 @@ class UseCounterPageLoadMetricsObserverTest
if (WithFencedFrames()) {
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(
web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
ASSERT_TRUE(fenced_frame_root->IsFencedFrameRoot());

@ -110,7 +110,7 @@ TEST_F(PageLoadMetricsForwardObserverTest, Basic) {
// Add a fenced frame.
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
{
auto simulator = content::NavigationSimulator::CreateRendererInitiated(

@ -151,7 +151,7 @@ class PageLoadMetricsMemoryTrackerTest
// Returns the final RenderFrameHost after navigation commits.
content::RenderFrameHost* NavigateMainFrame(const std::string& url) {
return NavigateFrame(url, web_contents()->GetMainFrame());
return NavigateFrame(url, web_contents()->GetPrimaryMainFrame());
}
// Returns the final RenderFrameHost after navigation commits.

@ -168,7 +168,7 @@ TEST_F(PageLoadTrackerTest, EventForwarding) {
// Add a fenced frame.
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
{
const char kFencedFramesUrl[] = "https://a.test/fenced_frames";
@ -246,7 +246,7 @@ TEST_F(PageLoadTrackerTest, FencedFramesPageType) {
// Add a fenced frame.
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
{
auto simulator = content::NavigationSimulator::CreateRendererInitiated(
@ -318,7 +318,7 @@ TEST_F(PageLoadTrackerTest, StopObservingOnFencedFrames) {
// Add a fenced frame.
content::RenderFrameHost* fenced_frame_root =
content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
content::RenderFrameHostTester::For(web_contents()->GetPrimaryMainFrame())
->AppendFencedFrame();
auto simulator = content::NavigationSimulator::CreateRendererInitiated(
GURL(kFencedFramesUrl), fenced_frame_root);

@ -38,7 +38,7 @@ void PaintPreviewBaseService::CapturePaintPreview(CaptureParams capture_params,
content::WebContents* web_contents = capture_params.web_contents;
content::RenderFrameHost* render_frame_host =
capture_params.render_frame_host ? capture_params.render_frame_host
: web_contents->GetMainFrame();
: web_contents->GetPrimaryMainFrame();
if (policy_ && !policy_->SupportedForContents(web_contents)) {
std::move(callback).Run(CaptureStatus::kContentUnsupported, {});
return;
@ -57,7 +57,7 @@ void PaintPreviewBaseService::CapturePaintPreview(CaptureParams capture_params,
}
params.inner.clip_rect = capture_params.clip_rect;
params.inner.is_main_frame =
(render_frame_host == web_contents->GetMainFrame());
(render_frame_host == web_contents->GetPrimaryMainFrame());
params.inner.capture_links = capture_params.capture_links;
params.inner.max_capture_size = capture_params.max_per_capture_size;
params.inner.max_decoded_image_size_bytes =

@ -137,7 +137,7 @@ class PaintPreviewClientRenderViewHostTest
void OverrideInterface(MockPaintPreviewRecorder* service) {
blink::AssociatedInterfaceProvider* remote_interfaces =
web_contents()->GetMainFrame()->GetRemoteAssociatedInterfaces();
web_contents()->GetPrimaryMainFrame()->GetRemoteAssociatedInterfaces();
remote_interfaces->OverrideBinderForTesting(
mojom::PaintPreviewRecorder::Name_,
base::BindRepeating(&MockPaintPreviewRecorder::BindRequest,

@ -199,7 +199,7 @@ class ContentPasswordManagerDriverTest
.WillByDefault(Return(&log_manager_));
blink::AssociatedInterfaceProvider* remote_interfaces =
web_contents()->GetMainFrame()->GetRemoteAssociatedInterfaces();
web_contents()->GetPrimaryMainFrame()->GetRemoteAssociatedInterfaces();
remote_interfaces->OverrideBinderForTesting(
autofill::mojom::PasswordAutofillAgent::Name_,
base::BindRepeating(&FakePasswordAutofillAgent::BindPendingReceiver,
@ -286,13 +286,14 @@ TEST_F(ContentPasswordManagerDriverTest, SetFrameAndFormMetaDataOfForm) {
autofill::FormData form;
autofill::FormData form2 = GetFormWithFrameAndFormMetaData(main_rfh(), form);
EXPECT_EQ(form2.host_frame,
autofill::LocalFrameToken(
web_contents()->GetMainFrame()->GetFrameToken().value()));
EXPECT_EQ(
form2.host_frame,
autofill::LocalFrameToken(
web_contents()->GetPrimaryMainFrame()->GetFrameToken().value()));
EXPECT_EQ(form2.url, GURL("https://hostname/path"));
EXPECT_EQ(form2.full_url, GURL("https://hostname/path?query#hash"));
EXPECT_EQ(form2.main_frame_origin,
web_contents()->GetMainFrame()->GetLastCommittedOrigin());
web_contents()->GetPrimaryMainFrame()->GetLastCommittedOrigin());
EXPECT_EQ(form2.main_frame_origin,
url::Origin::CreateFromNormalizedTuple("https", "hostname", 443));
}
@ -321,7 +322,7 @@ class ContentPasswordManagerDriverURLTest
expected_form.main_frame_origin =
url::Origin::CreateFromNormalizedTuple("https", "hostname", 443);
expected_form.host_frame = autofill::LocalFrameToken(
web_contents()->GetMainFrame()->GetFrameToken().value());
web_contents()->GetPrimaryMainFrame()->GetFrameToken().value());
return expected_form;
}
@ -428,7 +429,7 @@ TEST_F(ContentPasswordManagerDriverFencedFramesTest,
EXPECT_EQ(form_in_fenced_frame.main_frame_origin,
fenced_frame_root->GetLastCommittedOrigin());
EXPECT_NE(form_in_fenced_frame.main_frame_origin,
web_contents()->GetMainFrame()->GetLastCommittedOrigin());
web_contents()->GetPrimaryMainFrame()->GetLastCommittedOrigin());
EXPECT_EQ(form_in_fenced_frame.main_frame_origin,
url::Origin::CreateFromNormalizedTuple("https", "hostname", 443));
}

@ -197,7 +197,8 @@ static jlong JNI_JourneyLogger_InitJourneyLoggerAndroid(
content::WebContents::FromJavaWebContents(jweb_contents);
DCHECK(web_contents); // Verified in Java before invoking this function.
return reinterpret_cast<jlong>(new JourneyLoggerAndroid(
jis_incognito, web_contents->GetMainFrame()->GetPageUkmSourceId()));
jis_incognito,
web_contents->GetPrimaryMainFrame()->GetPageUkmSourceId()));
}
} // namespace payments

@ -183,7 +183,7 @@ TEST_F(AndroidPaymentAppFactoryTest, FindAppsThatDoNotHaveReadyToPayService) {
.WillRepeatedly(testing::Return("com.example.app"));
EXPECT_CALL(delegate_, GetInitiatorRenderFrameHost())
.WillRepeatedly(
testing::Return(delegate_.GetWebContents()->GetMainFrame()));
testing::Return(delegate_.GetWebContents()->GetPrimaryMainFrame()));
EXPECT_CALL(delegate_, OnDoneCreatingPaymentApps());
EXPECT_CALL(delegate_, OnPaymentAppCreationError(testing::_, testing::_))
@ -226,7 +226,7 @@ TEST_F(AndroidPaymentAppFactoryTest,
.WillRepeatedly(testing::Return("com.example.app"));
EXPECT_CALL(delegate_, GetInitiatorRenderFrameHost())
.WillRepeatedly(
testing::Return(delegate_.GetWebContents()->GetMainFrame()));
testing::Return(delegate_.GetWebContents()->GetPrimaryMainFrame()));
EXPECT_CALL(delegate_, OnDoneCreatingPaymentApps());
EXPECT_CALL(delegate_, OnPaymentAppCreationError(testing::_, testing::_))
@ -266,7 +266,7 @@ TEST_F(AndroidPaymentAppFactoryTest,
.WillRepeatedly(testing::Return("com.twa.app"));
EXPECT_CALL(delegate_, GetInitiatorRenderFrameHost())
.WillRepeatedly(
testing::Return(delegate_.GetWebContents()->GetMainFrame()));
testing::Return(delegate_.GetWebContents()->GetPrimaryMainFrame()));
EXPECT_CALL(delegate_, OnDoneCreatingPaymentApps());
EXPECT_CALL(delegate_, OnPaymentAppCreationError(testing::_, testing::_))
@ -302,7 +302,7 @@ TEST_F(AndroidPaymentAppFactoryTest, IgnoreAppsThatAreNotReadyToPay) {
.WillRepeatedly(testing::Return("com.example.app"));
EXPECT_CALL(delegate_, GetInitiatorRenderFrameHost())
.WillRepeatedly(
testing::Return(delegate_.GetWebContents()->GetMainFrame()));
testing::Return(delegate_.GetWebContents()->GetPrimaryMainFrame()));
EXPECT_CALL(delegate_, OnDoneCreatingPaymentApps());
EXPECT_CALL(delegate_, OnPaymentAppCreationError(testing::_, testing::_))
.Times(0);
@ -333,7 +333,7 @@ TEST_F(AndroidPaymentAppFactoryTest, FindTheCorrectTwaAppInTwaMode) {
.WillRepeatedly(testing::Return("com.correct-twa.app"));
EXPECT_CALL(delegate_, GetInitiatorRenderFrameHost())
.WillRepeatedly(
testing::Return(delegate_.GetWebContents()->GetMainFrame()));
testing::Return(delegate_.GetWebContents()->GetPrimaryMainFrame()));
EXPECT_CALL(delegate_, OnDoneCreatingPaymentApps());
EXPECT_CALL(delegate_, OnPaymentAppCreationError(testing::_, testing::_))
@ -480,7 +480,7 @@ TEST_F(AndroidPaymentAppFactoryTest,
.WillRepeatedly(testing::Return("com.twa.app"));
EXPECT_CALL(delegate_, GetInitiatorRenderFrameHost())
.WillRepeatedly(
testing::Return(delegate_.GetWebContents()->GetMainFrame()));
testing::Return(delegate_.GetWebContents()->GetPrimaryMainFrame()));
EXPECT_CALL(delegate_, OnDoneCreatingPaymentApps());
EXPECT_CALL(delegate_, OnPaymentAppCreationError(testing::_, testing::_))
.Times(0);

@ -54,7 +54,7 @@ class AndroidPaymentAppTest : public testing::Test,
GURL("https://top-level-origin.com"),
GURL("https://payment-request-origin.com"), "payment-request-id",
std::move(description), communication,
web_contents->GetMainFrame()->GetGlobalId());
web_contents->GetPrimaryMainFrame()->GetGlobalId());
}
AndroidPaymentAppTest()

@ -18,8 +18,8 @@ DeveloperConsoleLogger::~DeveloperConsoleLogger() = default;
void DeveloperConsoleLogger::Warn(const std::string& warning_message) const {
if (!enabled_)
return;
if (web_contents_ && web_contents_->GetMainFrame()) {
web_contents_->GetMainFrame()->AddMessageToConsole(
if (web_contents_ && web_contents_->GetPrimaryMainFrame()) {
web_contents_->GetPrimaryMainFrame()->AddMessageToConsole(
blink::mojom::ConsoleMessageLevel::kWarning, warning_message);
} else {
ErrorLogger::Warn(warning_message);
@ -29,8 +29,8 @@ void DeveloperConsoleLogger::Warn(const std::string& warning_message) const {
void DeveloperConsoleLogger::Error(const std::string& error_message) const {
if (!enabled_)
return;
if (web_contents_ && web_contents_->GetMainFrame()) {
web_contents_->GetMainFrame()->AddMessageToConsole(
if (web_contents_ && web_contents_->GetPrimaryMainFrame()) {
web_contents_->GetPrimaryMainFrame()->AddMessageToConsole(
blink::mojom::ConsoleMessageLevel::kError, error_message);
} else {
ErrorLogger::Error(error_message);

@ -149,7 +149,7 @@ class PaymentRequestStateTestBase : public testing::Test,
/*observer=*/nullptr, "en-US");
PaymentAppServiceFactory::SetForTesting(std::move(app_service));
state_ = std::make_unique<PaymentRequestState>(
web_contents_->GetMainFrame(), GURL("https://example.com"),
web_contents_->GetPrimaryMainFrame(), GURL("https://example.com"),
GURL("https://example.com/pay"),
url::Origin::Create(GURL("https://example.com")), spec_->AsWeakPtr(),
weak_ptr_factory_.GetWeakPtr(), "en-US", &test_personal_data_manager_,

@ -37,7 +37,7 @@ class PaymentRequestWebContentsManagerTest : public testing::Test {
// PaymentRequest is a DocumentService, whose lifetime is managed by the
// RenderFrameHost passed in here.
return new PaymentRequest(web_contents()->GetMainFrame(),
return new PaymentRequest(web_contents()->GetPrimaryMainFrame(),
std::move(delegate), std::move(display_manager),
std::move(receiver), mode,
/*observer_for_testing=*/nullptr);

@ -56,7 +56,7 @@ class MockAuthenticator : public webauthn::InternalAuthenticator {
MOCK_METHOD1(VerifyChallenge, void(const std::vector<uint8_t>&));
content::RenderFrameHost* GetRenderFrameHost() override {
return web_contents_->GetMainFrame();
return web_contents_->GetPrimaryMainFrame();
}
// Implements an webauthn::InternalAuthenticator method to delegate fields of

@ -53,7 +53,7 @@ class TestPDFWebContentsHelperClient : public PDFWebContentsHelperClient {
// PDFWebContentsHelperClient:
content::RenderFrameHost* FindPdfFrame(
content::WebContents* contents) override {
return contents->GetMainFrame();
return contents->GetPrimaryMainFrame();
}
void UpdateContentRestrictions(content::WebContents* contents,

@ -112,7 +112,7 @@ TEST_F(ProcessPriorityPolicyTest, GraphReflectedToRenderProcessHost) {
// Set the active contents in the RenderViewHostTestHarness.
SetContents(CreateTestWebContents());
auto* rvh = web_contents()->GetMainFrame()->GetRenderViewHost();
auto* rvh = web_contents()->GetPrimaryMainFrame()->GetRenderViewHost();
DCHECK(rvh);
auto* rph = rvh->GetProcess();
DCHECK(rph);

@ -43,7 +43,7 @@ IN_PROC_BROWSER_TEST_F(PerformanceManagerBrowserTest,
content::WebContents* contents = shell()->web_contents();
ASSERT_EQ(contents, old_contents);
ASSERT_EQ(contents->GetLastCommittedURL().possibly_invalid_spec(), kUrl);
content::RenderFrameHost* rfh = contents->GetMainFrame();
content::RenderFrameHost* rfh = contents->GetPrimaryMainFrame();
ASSERT_TRUE(rfh->IsRenderFrameLive());
base::WeakPtr<FrameNode> frame_node =
@ -152,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(PerformanceManagerFencedFrameBrowserTest,
embedded_test_server()->GetURL("/fenced_frames/title1.html");
content::RenderFrameHost* fenced_frame_host =
fenced_frame_test_helper().CreateFencedFrame(
GetWebContents()->GetMainFrame(), fenced_frame_url);
GetWebContents()->GetPrimaryMainFrame(), fenced_frame_url);
// Jump into the graph and make sure |fenced_frame_host| does not have a
// parent frame node.

@ -43,7 +43,7 @@ bool ConnectWindowOpenRelationshipIfExists(PerformanceManagerTabHelper* helper,
// will be an "original opener".
if (content::WebContents* original_opener_wc =
web_contents->GetFirstWebContentsInLiveOriginalOpenerChain()) {
opener_rfh = original_opener_wc->GetMainFrame();
opener_rfh = original_opener_wc->GetPrimaryMainFrame();
}
}
@ -86,7 +86,7 @@ PerformanceManagerTabHelper::PerformanceManagerTabHelper(
// We have an early WebContents creation hook so should see it when there is
// only a single frame, and it is not yet created. We sanity check that here.
#if DCHECK_IS_ON()
DCHECK(!web_contents->GetMainFrame()->IsRenderFrameLive());
DCHECK(!web_contents->GetPrimaryMainFrame()->IsRenderFrameLive());
size_t frame_count = 0;
web_contents->ForEachRenderFrameHost(base::BindRepeating(
[](size_t* frame_count, content::RenderFrameHost* render_frame_host) {
@ -106,7 +106,7 @@ PerformanceManagerTabHelper::PerformanceManagerTabHelper(
web_contents->IsCurrentlyAudible(), web_contents->GetLastActiveTime(),
// TODO(crbug.com/1211368): Support MPArch fully!
PageNode::PageState::kActive);
content::RenderFrameHost* main_rfh = web_contents->GetMainFrame();
content::RenderFrameHost* main_rfh = web_contents->GetPrimaryMainFrame();
DCHECK(main_rfh);
page->main_frame_tree_node_id = main_rfh->GetFrameTreeNodeId();
primary_page_ = page.get();

@ -240,7 +240,7 @@ TEST_F(PerformanceManagerTabHelperTest, GetFrameNode) {
// GetFrameNode() can return nullptr. In this test, it is achieved by using an
// empty RenderFrameHost.
auto* empty_frame = web_contents()->GetMainFrame();
auto* empty_frame = web_contents()->GetPrimaryMainFrame();
DCHECK(empty_frame);
auto* empty_frame_node = tab_helper->GetFrameNode(empty_frame);
@ -278,13 +278,13 @@ TEST_F(PerformanceManagerTabHelperTest,
content::NavigationSimulator::NavigateAndCommitFromBrowser(web_contents(),
GURL(kParentUrl));
auto* first_nav_main_rfh = web_contents()->GetMainFrame();
auto* first_nav_main_rfh = web_contents()->GetPrimaryMainFrame();
content::LeaveInPendingDeletionState(first_nav_main_rfh);
content::NavigationSimulator::NavigateAndCommitFromBrowser(
web_contents(), GURL(kCousinFreddyUrl));
EXPECT_NE(web_contents()->GetMainFrame(), first_nav_main_rfh);
EXPECT_NE(web_contents()->GetPrimaryMainFrame(), first_nav_main_rfh);
// Mock observer, this can only be used from the PM sequence.
MockPageNodeObserver observer;
@ -325,8 +325,8 @@ TEST_F(PerformanceManagerTabHelperTest,
// Sanity check to ensure that notification sent to the active main frame are
// forwarded. DidUpdateFaviconURL needs to be called twice as the first
// favicon change is always ignored.
tab_helper->DidUpdateFaviconURL(web_contents()->GetMainFrame(), {});
tab_helper->DidUpdateFaviconURL(web_contents()->GetMainFrame(), {});
tab_helper->DidUpdateFaviconURL(web_contents()->GetPrimaryMainFrame(), {});
tab_helper->DidUpdateFaviconURL(web_contents()->GetPrimaryMainFrame(), {});
{
base::RunLoop run_loop;

@ -50,7 +50,7 @@ class PerformanceManagerTest : public PerformanceManagerTestHarness {
TEST_F(PerformanceManagerTest, NodeAccessors) {
auto contents = CreateTestWebContents();
content::RenderFrameHost* rfh = contents->GetMainFrame();
content::RenderFrameHost* rfh = contents->GetPrimaryMainFrame();
ASSERT_TRUE(rfh);
content::RenderProcessHost* rph = rfh->GetProcess();
ASSERT_TRUE(rph);

@ -131,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(PerformanceManagerPrerenderingBrowserTest,
// Activate the prerendered document. Test that GetMainFrameNode now returns
// its main frame, and the original frame tree is gone.
content::RenderFrameDeletedObserver deleted_observer(
web_contents()->GetMainFrame());
web_contents()->GetPrimaryMainFrame());
content::test::PrerenderHostObserver prerender_observer(*web_contents(),
kPrerenderingUrl);
prerender_helper_.NavigatePrimaryPage(kPrerenderingUrl);

@ -44,7 +44,7 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostProxyTest,
// Get the RPH associated with the main frame.
content::RenderProcessHost* host =
shell()->web_contents()->GetMainFrame()->GetProcess();
shell()->web_contents()->GetPrimaryMainFrame()->GetProcess();
// And its associated ProcessNode.
auto* render_process_user_data =

@ -65,7 +65,7 @@ IN_PROC_BROWSER_TEST_F(V8ContextTrackerTest, SameOriginIframeAttributionData) {
NavigateAndWaitForConsoleMessage(contents, urla, "a.html loaded"));
// Get pointers to the RFHs for each frame.
content::RenderFrameHost* main_rfh = contents->GetMainFrame();
content::RenderFrameHost* main_rfh = contents->GetPrimaryMainFrame();
content::RenderFrameHost* child_rfh = ChildFrameAt(main_rfh, 0);
ASSERT_TRUE(child_rfh);
@ -90,7 +90,7 @@ IN_PROC_BROWSER_TEST_F(V8ContextTrackerTest, CrossOriginIframeAttributionData) {
NavigateAndWaitForConsoleMessage(contents, urla, "b.html loaded"));
// Get pointers to the RFHs for each frame.
content::RenderFrameHost* main_rfh = contents->GetMainFrame();
content::RenderFrameHost* main_rfh = contents->GetPrimaryMainFrame();
content::RenderFrameHost* child_rfh = ChildFrameAt(main_rfh, 0);
ASSERT_TRUE(child_rfh);
auto frame_node =
@ -119,7 +119,7 @@ IN_PROC_BROWSER_TEST_F(V8ContextTrackerTest, SameDocNavigation) {
ExpectCounts(2, 2, 0, 0);
// Get pointers to the RFHs for each frame.
content::RenderFrameHost* rfha = contents->GetMainFrame();
content::RenderFrameHost* rfha = contents->GetPrimaryMainFrame();
content::RenderFrameHost* rfhb = ChildFrameAt(rfha, 0);
// Execute a same document navigation in the child frame. This causes a
@ -143,7 +143,7 @@ IN_PROC_BROWSER_TEST_F(V8ContextTrackerTest, DetachedContext) {
ExpectCounts(2, 2, 0, 0);
// Get pointers to the RFHs for each frame.
content::RenderFrameHost* rfha = contents->GetMainFrame();
content::RenderFrameHost* rfha = contents->GetPrimaryMainFrame();
// Keep a pointer to the window associated with the child iframe, but
// unload it.

Some files were not shown because too many files have changed in this diff Show More