Rewrite GetPrimaryMainFrame comparison in terms of IsInPrimaryMainFrame (11/n)
This CL replaces the GetPrimaryMainFrame() comparison check in favor
of a more concise method IsInPrimaryMainFrame() in
js_to_browser_messaging.cc.
Bug: 1268893
Change-Id: I467cc020b30d327d3da49a8eec1926844afd2dc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4026986
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Antia Puentes <apuentes@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1072158}
diff --git a/components/js_injection/browser/js_to_browser_messaging.cc b/components/js_injection/browser/js_to_browser_messaging.cc
index 4f21a0d..f8abe03 100644
--- a/components/js_injection/browser/js_to_browser_messaging.cc
+++ b/components/js_injection/browser/js_to_browser_messaging.cc
@@ -112,8 +112,7 @@
if (!host_) {
const std::string origin_string = GetOriginString(source_origin);
- const bool is_main_frame =
- web_contents->GetPrimaryMainFrame() == render_frame_host_;
+ const bool is_main_frame = render_frame_host_->IsInPrimaryMainFrame();
host_ = connection_factory_->CreateHost(origin_string, is_main_frame,
reply_proxy_.get());
@@ -128,8 +127,7 @@
// PostMessage() has been received.
#if DCHECK_IS_ON()
DCHECK_EQ(GetOriginString(source_origin), origin_string_);
- DCHECK_EQ(is_main_frame_,
- web_contents->GetPrimaryMainFrame() == render_frame_host_);
+ DCHECK_EQ(is_main_frame_, render_frame_host_->IsInPrimaryMainFrame());
#endif
std::unique_ptr<WebMessage> web_message = std::make_unique<WebMessage>();
web_message->message = std::move(message);