Add IsPrimary to Page interface.

There are a few ways of determining if the Page is primary however we
want to provide a well lit path of the preferred API.

BUG=1192003, 1217621

Change-Id: Icb23c96deebb56a88416cd38012e69cc3b0c7a77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2970343
Commit-Queue: Dave Tapuska <[email protected]>
Reviewed-by: Sreeja Kamishetty <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Reviewed-by: Kevin McNee <[email protected]>
Reviewed-by: Lucas Gadani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#894808}
diff --git a/content/browser/renderer_host/page_impl.cc b/content/browser/renderer_host/page_impl.cc
index 7dccd50..85882f5 100644
--- a/content/browser/renderer_host/page_impl.cc
+++ b/content/browser/renderer_host/page_impl.cc
@@ -5,6 +5,7 @@
 #include "content/browser/renderer_host/page_impl.h"
 
 #include "content/browser/manifest/manifest_manager_host.h"
+#include "content/browser/renderer_host/frame_tree_node.h"
 #include "content/browser/renderer_host/render_frame_host_impl.h"
 
 namespace content {
@@ -23,4 +24,12 @@
   manifest_manager_host->GetManifest(std::move(callback));
 }
 
+bool PageImpl::IsPrimary() {
+  // TODO(https://crbug.com/1222722): Query RenderFrameHost::IsInFencedFrame()
+  // when it is available.
+  return main_document_.lifecycle_state() ==
+             RenderFrameHostImpl::LifecycleStateImpl::kActive &&
+         !main_document_.InsidePortal();
+}
+
 }  // namespace content