[MPArch] Refactor proxy-iterating methods into BrowsingContextState

RenderFrameHostManager has some methods that update proxies, which
are more appropriately stored in BrowsingContextState instead.

Bug: 1270671
Change-Id: Ia3f3c5ce736663182252e70391afafbcd177ce4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3412032
Reviewed-by: Alexander Timin <[email protected]>
Reviewed-by: Rakina Zata Amni <[email protected]>
Commit-Queue: Harkiran Bolaria <[email protected]>
Cr-Commit-Position: refs/heads/main@{#979838}
diff --git a/content/browser/renderer_host/browsing_context_state.cc b/content/browser/renderer_host/browsing_context_state.cc
index c9ac79f..420baee 100644
--- a/content/browser/renderer_host/browsing_context_state.cc
+++ b/content/browser/renderer_host/browsing_context_state.cc
@@ -5,6 +5,7 @@
 #include "content/browser/renderer_host/browsing_context_state.h"
 
 #include "content/browser/renderer_host/frame_tree_node.h"
+#include "content/browser/renderer_host/render_frame_host_impl.h"
 #include "content/browser/renderer_host/render_view_host_impl.h"
 #include "content/common/content_navigation_policy.h"
 #include "services/network/public/cpp/web_sandbox_flags.h"
@@ -305,6 +306,16 @@
   }
 }
 
+void BrowsingContextState::OnDidStartLoading() {
+  for (const auto& pair : proxy_hosts_)
+    pair.second->GetAssociatedRemoteFrame()->DidStartLoading();
+}
+
+void BrowsingContextState::OnDidStopLoading() {
+  for (const auto& pair : proxy_hosts_)
+    pair.second->GetAssociatedRemoteFrame()->DidStopLoading();
+}
+
 void BrowsingContextState::ResetProxyHosts() {
   for (const auto& pair : proxy_hosts_) {
     pair.second->site_instance_group()->RemoveObserver(this);
@@ -312,4 +323,46 @@
   proxy_hosts_.clear();
 }
 
+void BrowsingContextState::UpdateOpener(SiteInstance* source_site_instance) {
+  for (const auto& pair : proxy_hosts_) {
+    if (pair.second->GetSiteInstance() == source_site_instance)
+      continue;
+    pair.second->UpdateOpener();
+  }
+}
+
+void BrowsingContextState::OnDidUpdateFrameOwnerProperties(
+    const blink::mojom::FrameOwnerProperties& properties) {
+  // Notify this frame's proxies if they live in a different process from its
+  // parent.  This is only currently needed for the allowFullscreen property,
+  // since that can be queried on RemoteFrame ancestors.
+  //
+  // TODO(alexmos): It would be sufficient to only send this update to proxies
+  // in the current FrameTree.
+  for (const auto& pair : proxy_hosts_) {
+    if (pair.second->site_instance_group() !=
+        parent_->GetSiteInstance()->group()) {
+      auto properties_for_remote_frame = properties.Clone();
+      RenderFrameProxyHost* proxy = pair.second.get();
+      proxy->GetAssociatedRemoteFrame()->SetFrameOwnerProperties(
+          std::move(properties_for_remote_frame));
+    }
+  }
+}
+
+void BrowsingContextState::ExecuteRemoteFramesBroadcastMethod(
+    base::RepeatingCallback<void(RenderFrameProxyHost*)> callback,
+    SiteInstance* instance_to_skip,
+    RenderFrameProxyHost* outer_delegate_proxy) {
+  for (const auto& pair : proxy_hosts_) {
+    if (outer_delegate_proxy == pair.second.get())
+      continue;
+    if (pair.second->GetSiteInstance() == instance_to_skip)
+      continue;
+    if (!pair.second->is_render_frame_proxy_live())
+      continue;
+    callback.Run(pair.second.get());
+  }
+}
+
 }  // namespace content
\ No newline at end of file