Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_BROWSER_RENDERER_HOST_BROWSING_CONTEXT_STATE_H_ |
| 6 | #define CONTENT_BROWSER_RENDERER_HOST_BROWSING_CONTEXT_STATE_H_ |
| 7 | |
David Sanders | aad7820 | 2022-01-23 02:13:29 | [diff] [blame] | 8 | #include "base/feature_list.h" |
Kevin McNee | 7705fe8 | 2024-11-07 18:56:31 | [diff] [blame] | 9 | #include "base/functional/function_ref.h" |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
Harkiran Bolaria | 875d4f6 | 2022-05-17 16:18:23 | [diff] [blame] | 11 | #include "base/memory/safe_ref.h" |
Arthur Hemery | a3e593f | 2023-05-11 17:15:57 | [diff] [blame] | 12 | #include "base/unguessable_token.h" |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 13 | #include "content/browser/renderer_host/render_frame_proxy_host.h" |
| 14 | #include "content/browser/site_instance_group.h" |
Arthur Hemery | c2f98e3d | 2022-10-03 15:37:26 | [diff] [blame] | 15 | #include "content/public/browser/browsing_instance_id.h" |
Sandor Major | 878f835 | 2025-02-18 20:16:02 | [diff] [blame] | 16 | #include "services/network/public/cpp/permissions_policy/permissions_policy_declaration.h" |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 17 | #include "third_party/blink/public/mojom/frame/frame_replication_state.mojom-forward.h" |
Harkiran Bolaria | 3bf5457f | 2022-03-10 20:04:37 | [diff] [blame] | 18 | #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 19 | |
| 20 | namespace features { |
| 21 | // Currently there are two paths - legacy code, in which BrowsingContextState |
| 22 | // will be 1:1 with FrameTreeNode, allowing us to move proxy storage to it as a |
| 23 | // no-op, and a new path hidden behind a feature flag, which will create a new |
| 24 | // BrowsingContextState for cross-BrowsingInstance navigations. |
| 25 | |
| 26 | CONTENT_EXPORT extern const base::Feature |
| 27 | kNewBrowsingContextStateOnBrowsingContextGroupSwap; |
| 28 | |
| 29 | enum class BrowsingContextStateImplementationType { |
| 30 | kLegacyOneToOneWithFrameTreeNode, |
| 31 | kSwapForCrossBrowsingInstanceNavigations, |
| 32 | }; |
| 33 | |
| 34 | CONTENT_EXPORT BrowsingContextStateImplementationType GetBrowsingContextMode(); |
| 35 | } // namespace features |
| 36 | |
| 37 | namespace content { |
| 38 | |
David Sanders | 73ebb80c | 2022-04-19 00:53:12 | [diff] [blame] | 39 | class RenderFrameHostImpl; |
| 40 | |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 41 | // BrowsingContextState is intended to store all state associated with a given |
| 42 | // browsing context (BrowsingInstance in the code, as defined in the HTML spec |
| 43 | // (https://html.spec.whatwg.org/multipage/browsers.html#browsing-context), |
| 44 | // in particular RenderFrameProxyHosts and FrameReplicationState. Each |
| 45 | // RenderFrameHost will have an associated BrowsingContextState (which never |
| 46 | // changes), but each BrowsingContextState can be shared between multiple |
| 47 | // RenderFrameHosts for the same frame/FrameTreeNode. |
| 48 | |
Harkiran Bolaria | 2912a6b3 | 2022-02-22 16:43:45 | [diff] [blame] | 49 | // BrowsingContextState is responsible for proxy storage and |
| 50 | // RenderFrameHostManager is responsible for connecting different |
| 51 | // BrowsingContextStates and creating proxies for appropriate SiteInstances. |
| 52 | |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 53 | // A new BCS will be created when a new RenderFrameHost is created for a new |
| 54 | // frame or a speculative RFH is created for a cross-BrowsingInstance (browsing |
| 55 | // context group in the spec) navigation (speculative RFHs created in the same |
| 56 | // BrowsingInstance will use the same BrowsingContextState as the old |
| 57 | // RenderFrameHost). For pages stored in bfcache and used for prerendering |
| 58 | // activations, BrowsingContextState will travel automatically together with the |
| 59 | // RenderFrameHost. |
| 60 | |
| 61 | // Note: "browsing context" is an HTML spec term (close to a "frame") and it's |
| 62 | // different from content::BrowserContext, which represents a "browser profile". |
| 63 | |
Alison Gale | 770f3fc | 2024-04-27 00:39:58 | [diff] [blame] | 64 | // TODO(crbug.com/40205442): Currently it's under implementation and there are |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 65 | // two different modes, controlled by a flag: kLegacyOneToOneWithFrameTreeNode, |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 66 | // where BrowsingContextState is 1:1 with FrameTreeNode and exists for the |
| 67 | // duration of the FrameTreeNode lifetime, and |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 68 | // kSwapForCrossBrowsingInstanceNavigations intended state with the behaviour |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 69 | // described above, tied to the lifetime of the RenderFrameHostImpl. |
| 70 | // kLegacyOneToOneWithFrameTreeNode is currently enabled and will be removed |
| 71 | // once the functionality gated behind kSwapForCrossBrowsingInstanceNavigations |
| 72 | // is implemented. |
Harkiran Bolaria | d22a1dca | 2022-02-22 17:01:12 | [diff] [blame] | 73 | class CONTENT_EXPORT BrowsingContextState |
| 74 | : public base::RefCounted<BrowsingContextState>, |
| 75 | public SiteInstanceGroup::Observer { |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 76 | public: |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 77 | using RenderFrameProxyHostMap = |
| 78 | std::unordered_map<SiteInstanceGroupId, |
Devon Loehr | 92631c89 | 2025-01-02 20:15:15 | [diff] [blame] | 79 | std::unique_ptr<RenderFrameProxyHost>>; |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 80 | |
Camille Lamy | c935192 | 2025-05-01 02:57:44 | [diff] [blame] | 81 | // Currently `browsing_instance_id` will be null iff the legacy mode is |
| 82 | // enabled, as the legacy mode BrowsingContextState is 1:1 with FrameTreeNode |
| 83 | // and therefore doesn't have a dedicated associated BrowsingInstance. |
| 84 | // TODO(crbug.com/40205442): Make `browsing_instance_id` non-optional when the |
| 85 | // legacy path is removed. |
| 86 | BrowsingContextState(blink::mojom::FrameReplicationStatePtr replication_state, |
| 87 | RenderFrameHostImpl* parent, |
| 88 | std::optional<BrowsingInstanceId> browsing_instance_id); |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 89 | |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 90 | // Returns a const reference to the map of proxy hosts. The keys are |
| 91 | // SiteInstanceGroup IDs, the values are RenderFrameProxyHosts. |
| 92 | const RenderFrameProxyHostMap& proxy_hosts() const { return proxy_hosts_; } |
| 93 | |
| 94 | RenderFrameProxyHostMap& proxy_hosts() { return proxy_hosts_; } |
| 95 | |
Harkiran Bolaria | 57e2b06 | 2022-03-14 10:27:58 | [diff] [blame] | 96 | // Returns true if this is a main BrowsingContextState. True if and only if |
| 97 | // this BrowsingContextState doesn't have a parent. |
| 98 | bool is_main_frame() const { return !parent_; } |
| 99 | |
Harkiran Bolaria | 4eacb3a | 2021-12-13 20:03:47 | [diff] [blame] | 100 | const blink::mojom::FrameReplicationState& current_replication_state() const { |
| 101 | return *replication_state_; |
| 102 | } |
| 103 | |
| 104 | const std::string& frame_name() const { return replication_state_->name; } |
| 105 | |
| 106 | // Returns the currently active frame policy for this frame, including the |
| 107 | // sandbox flags which were present at the time the document was loaded, and |
| 108 | // the permissions policy container policy, which is set by the iframe's |
| 109 | // allowfullscreen, allowpaymentrequest, and allow attributes, along with the |
| 110 | // origin of the iframe's src attribute (which may be different from the URL |
| 111 | // of the document currently loaded into the frame). This does not include |
| 112 | // policy changes that have been made by updating the containing iframe |
| 113 | // element attributes since the frame was last navigated; use |
| 114 | // pending_frame_policy() for those. |
| 115 | const blink::FramePolicy& effective_frame_policy() const { |
| 116 | return replication_state_->frame_policy; |
| 117 | } |
| 118 | |
| 119 | // Returns the sandbox flags currently in effect for this frame. This includes |
| 120 | // flags inherited from parent frames, the currently active flags from the |
| 121 | // <iframe> element hosting this frame, as well as any flags set from a |
| 122 | // Content-Security-Policy HTTP header. This does not include flags that have |
| 123 | // have been updated in an <iframe> element but have not taken effect yet; use |
| 124 | // pending_frame_policy() for those. To see the flags which will take effect |
| 125 | // on navigation (which does not include the CSP-set flags), use |
| 126 | // effective_frame_policy(). |
| 127 | network::mojom::WebSandboxFlags active_sandbox_flags() const { |
| 128 | return replication_state_->active_sandbox_flags; |
| 129 | } |
| 130 | |
| 131 | void set_frame_name(const std::string& unique_name, const std::string& name) { |
| 132 | replication_state_->unique_name = unique_name; |
| 133 | replication_state_->name = name; |
| 134 | } |
| 135 | |
Harkiran Bolaria | 4eacb3a | 2021-12-13 20:03:47 | [diff] [blame] | 136 | void set_has_active_user_gesture(bool has_active_user_gesture) { |
| 137 | replication_state_->has_active_user_gesture = has_active_user_gesture; |
| 138 | } |
| 139 | |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 140 | // All proxies except outer delegate proxies should belong to the same |
Camille Lamy | c935192 | 2025-05-01 02:57:44 | [diff] [blame] | 141 | // BrowsingInstance as their BrowsingContextState. |
Arthur Hemery | 08d8288 | 2023-04-27 12:33:14 | [diff] [blame] | 142 | // |
| 143 | // When kSwapForCrossBrowsingInstanceNavigations is enabled, we might change |
| 144 | // BrowsingContextState during a navigation. To ensure that we haven't mixed |
Camille Lamy | c935192 | 2025-05-01 02:57:44 | [diff] [blame] | 145 | // up things, we CHECK that proxies are in the same BrowsingInstance. We do |
| 146 | // this CHECK in all functions for creating, deleting, and accessing proxies. |
| 147 | // See BrowsingContextState::GetRenderFrameProxyHostImpl() for an example. |
Arthur Hemery | 08d8288 | 2023-04-27 12:33:14 | [diff] [blame] | 148 | // |
| 149 | // When we expect to be in one the exception cases we specify it via the |
| 150 | // ProxyAccessMode enum below, which will disable the CHECKs. |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 151 | enum class ProxyAccessMode { |
| 152 | kRegular, |
| 153 | kAllowOuterDelegate, |
| 154 | }; |
| 155 | |
Harkiran Bolaria | 7fdb4c64 | 2021-12-20 12:47:00 | [diff] [blame] | 156 | RenderFrameProxyHost* GetRenderFrameProxyHost( |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 157 | SiteInstanceGroup* site_instance_group, |
| 158 | ProxyAccessMode proxy_access_mode = ProxyAccessMode::kRegular) const; |
Harkiran Bolaria | 7fdb4c64 | 2021-12-20 12:47:00 | [diff] [blame] | 159 | |
Harkiran Bolaria | d22a1dca | 2022-02-22 17:01:12 | [diff] [blame] | 160 | // Returns the number of RenderFrameProxyHosts for this frame. |
| 161 | size_t GetProxyCount(); |
| 162 | |
Harkiran Bolaria | 880a763 | 2022-02-28 16:02:50 | [diff] [blame] | 163 | // Set the current name and notify proxies about the update. |
| 164 | void SetFrameName(const std::string& name, const std::string& unique_name); |
| 165 | |
Harkiran Bolaria | e352143 | 2021-12-14 11:27:43 | [diff] [blame] | 166 | // Set the current origin and notify proxies about the update. |
| 167 | void SetCurrentOrigin(const url::Origin& origin, |
| 168 | bool is_potentially_trustworthy_unique_origin); |
| 169 | |
| 170 | // Sets the current insecure request policy, and notifies proxies about the |
| 171 | // update. |
| 172 | void SetInsecureRequestPolicy(blink::mojom::InsecureRequestPolicy policy); |
| 173 | |
| 174 | // Sets the current set of insecure urls to upgrade, and notifies proxies |
| 175 | // about the update. |
| 176 | void SetInsecureNavigationsSet( |
| 177 | const std::vector<uint32_t>& insecure_navigations_set); |
| 178 | |
Harkiran Bolaria | 5ce2763 | 2022-01-20 15:05:05 | [diff] [blame] | 179 | // Sets the sticky user activation status and notifies proxies about the |
Harkiran Bolaria | e352143 | 2021-12-14 11:27:43 | [diff] [blame] | 180 | // update. |
| 181 | void OnSetHadStickyUserActivationBeforeNavigation(bool value); |
| 182 | |
David Bokan | fa230cc | 2022-07-22 18:02:33 | [diff] [blame] | 183 | // Sets whether this is an ad frame and notifies the proxies about the update. |
| 184 | void SetIsAdFrame(bool is_ad_frame); |
Harkiran Bolaria | e352143 | 2021-12-14 11:27:43 | [diff] [blame] | 185 | |
Harkiran Bolaria | e182a594 | 2021-12-20 17:23:31 | [diff] [blame] | 186 | // Delete a RenderFrameProxyHost owned by this object. |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 187 | void DeleteRenderFrameProxyHost( |
| 188 | SiteInstanceGroup* site_instance_group, |
| 189 | ProxyAccessMode proxy_access_mode = ProxyAccessMode::kRegular); |
Harkiran Bolaria | e182a594 | 2021-12-20 17:23:31 | [diff] [blame] | 190 | |
Sharon Yang | a2fe85e | 2022-02-09 21:38:29 | [diff] [blame] | 191 | // SiteInstanceGroup::Observer |
| 192 | void ActiveFrameCountIsZero(SiteInstanceGroup* site_instance_group) override; |
Sharon Yang | 417a5df | 2024-04-23 17:57:15 | [diff] [blame] | 193 | void KeepAliveCountIsZero(SiteInstanceGroup* site_instance_group) override; |
Sharon Yang | a2fe85e | 2022-02-09 21:38:29 | [diff] [blame] | 194 | void RenderProcessGone(SiteInstanceGroup* site_instance_group, |
Harkiran Bolaria | e182a594 | 2021-12-20 17:23:31 | [diff] [blame] | 195 | const ChildProcessTerminationInfo& info) override; |
| 196 | |
Harkiran Bolaria | 5ce2763 | 2022-01-20 15:05:05 | [diff] [blame] | 197 | // Set the frame_policy provided in function parameter as active frame policy, |
| 198 | // while leaving the FrameTreeNode::pending_frame_policy_ untouched. This |
| 199 | // functionality is used on FrameTreeNode initialization, where it is |
| 200 | // associated with a RenderFrameHost. Returns a boolean indicating whether |
| 201 | // there was an update to the FramePolicy. |
| 202 | bool CommitFramePolicy(const blink::FramePolicy& frame_policy); |
| 203 | |
| 204 | // Updates the active sandbox flags in this frame, in response to a |
| 205 | // Content-Security-Policy header adding additional flags, in addition to |
| 206 | // those given to this frame by its parent, or in response to the |
| 207 | // Permissions-Policy header being set. Usually this will be when we create |
| 208 | // WebContents with an opener. Note that on navigation, these updates will be |
| 209 | // cleared, and the flags in the pending frame policy will be applied to the |
| 210 | // frame. The old document's frame policy should therefore not impact the new |
| 211 | // document's frame policy. |
| 212 | // Returns true iff this operation has changed state of either sandbox flags |
| 213 | // or permissions policy. |
| 214 | bool UpdateFramePolicyHeaders( |
| 215 | network::mojom::WebSandboxFlags sandbox_flags, |
Sandor Major | 878f835 | 2025-02-18 20:16:02 | [diff] [blame] | 216 | const network::ParsedPermissionsPolicy& parsed_header); |
Harkiran Bolaria | 5ce2763 | 2022-01-20 15:05:05 | [diff] [blame] | 217 | |
| 218 | // Notify all of the proxies about the updated FramePolicy, excluding the |
| 219 | // parent, as it will already know. |
Sharon Yang | 571baee | 2022-03-18 19:01:54 | [diff] [blame] | 220 | void SendFramePolicyUpdatesToProxies(SiteInstanceGroup* parent_group, |
Harkiran Bolaria | 5ce2763 | 2022-01-20 15:05:05 | [diff] [blame] | 221 | const blink::FramePolicy& frame_policy); |
| 222 | |
Harkiran Bolaria | 2912a6b3 | 2022-02-22 16:43:45 | [diff] [blame] | 223 | // Create a RenderFrameProxyHost owned by this object. This |
Sharon Yang | dcc5f25 | 2024-05-09 18:27:23 | [diff] [blame] | 224 | // RenderFrameProxyHost represents the browsing context in this |
| 225 | // SiteInstanceGroup. |
Alison Gale | 770f3fc | 2024-04-27 00:39:58 | [diff] [blame] | 226 | // TODO(crbug.com/40205442): Currently we pass a FrameTreeNode because it is |
Harkiran Bolaria | 2912a6b3 | 2022-02-22 16:43:45 | [diff] [blame] | 227 | // required for the constructor to RenderFrameProxyHost. However, the stored |
| 228 | // reference to FrameTreeNode should be replaced by a BrowsingContextState |
| 229 | // instead; FrameTreeNode will need to be removed from here as well. |
| 230 | RenderFrameProxyHost* CreateRenderFrameProxyHost( |
Sharon Yang | dcc5f25 | 2024-05-09 18:27:23 | [diff] [blame] | 231 | SiteInstanceGroup* site_instance_group, |
Harkiran Bolaria | 2912a6b3 | 2022-02-22 16:43:45 | [diff] [blame] | 232 | const scoped_refptr<RenderViewHostImpl>& rvh, |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 233 | FrameTreeNode* frame_tree_node, |
Dave Tapuska | 14457010 | 2022-08-02 19:28:27 | [diff] [blame] | 234 | ProxyAccessMode proxy_access_mode = ProxyAccessMode::kRegular, |
| 235 | const blink::RemoteFrameToken& frame_token = blink::RemoteFrameToken()); |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 236 | |
| 237 | // Called on the RFHM of the inner WebContents to create a |
Sharon Yang | dcc5f25 | 2024-05-09 18:27:23 | [diff] [blame] | 238 | // RenderFrameProxyHost in its outer WebContents' SiteInstanceGroup, |
| 239 | // |outer_contents_site_instance_group|. |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 240 | RenderFrameProxyHost* CreateOuterDelegateProxy( |
Sharon Yang | dcc5f25 | 2024-05-09 18:27:23 | [diff] [blame] | 241 | SiteInstanceGroup* outer_contents_site_instance_group, |
Dave Tapuska | 14457010 | 2022-08-02 19:28:27 | [diff] [blame] | 242 | FrameTreeNode* frame_tree_node, |
| 243 | const blink::RemoteFrameToken& frame_token); |
Harkiran Bolaria | 2912a6b3 | 2022-02-22 16:43:45 | [diff] [blame] | 244 | |
Harkiran Bolaria | 0b3bdef0 | 2022-03-10 13:04:40 | [diff] [blame] | 245 | // Deletes any proxy hosts associated with this node. Used during destruction |
| 246 | // of WebContentsImpl. |
| 247 | void ResetProxyHosts(); |
| 248 | |
Harkiran Bolaria | 3f83fba7 | 2022-03-10 17:48:40 | [diff] [blame] | 249 | // Notification methods to tell this RenderFrameHostManager that the frame it |
| 250 | // is responsible for has started or stopped loading a document. |
| 251 | void OnDidStartLoading(); |
| 252 | void OnDidStopLoading(); |
| 253 | |
| 254 | // Notify proxies that an opener has been updated. |
Sharon Yang | 571baee | 2022-03-18 19:01:54 | [diff] [blame] | 255 | void UpdateOpener(SiteInstanceGroup* source_site_instance_group); |
Harkiran Bolaria | 3f83fba7 | 2022-03-10 17:48:40 | [diff] [blame] | 256 | |
| 257 | void OnDidUpdateFrameOwnerProperties( |
| 258 | const blink::mojom::FrameOwnerProperties& properties); |
| 259 | |
| 260 | void ExecuteRemoteFramesBroadcastMethod( |
Kevin McNee | 7705fe8 | 2024-11-07 18:56:31 | [diff] [blame] | 261 | base::FunctionRef<void(RenderFrameProxyHost*)> callback, |
Sharon Yang | 6b531343 | 2023-03-24 05:07:57 | [diff] [blame] | 262 | SiteInstanceGroup* group_to_skip, |
Harkiran Bolaria | 3f83fba7 | 2022-03-10 17:48:40 | [diff] [blame] | 263 | RenderFrameProxyHost* outer_delegate_proxy); |
| 264 | |
Alexander Timin | 074cd18 | 2022-03-23 18:11:22 | [diff] [blame] | 265 | using TraceProto = perfetto::protos::pbzero::BrowsingContextState; |
| 266 | // Write a representation of this object into a trace. |
| 267 | void WriteIntoTrace(perfetto::TracedProto<TraceProto> proto) const; |
Harkiran Bolaria | 3bf5457f | 2022-03-10 20:04:37 | [diff] [blame] | 268 | |
Harkiran Bolaria | 875d4f6 | 2022-05-17 16:18:23 | [diff] [blame] | 269 | base::SafeRef<BrowsingContextState> GetSafeRef(); |
| 270 | |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 271 | protected: |
| 272 | friend class base::RefCounted<BrowsingContextState>; |
| 273 | |
Sharon Yang | 98309fb1 | 2023-07-28 00:11:40 | [diff] [blame] | 274 | ~BrowsingContextState() override; |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 275 | |
| 276 | private: |
Harkiran Bolaria | a834778 | 2022-04-06 09:25:11 | [diff] [blame] | 277 | RenderFrameProxyHost* GetRenderFrameProxyHostImpl( |
Harkiran Bolaria | e45272d | 2022-04-12 08:05:01 | [diff] [blame] | 278 | SiteInstanceGroup* site_instance_group, |
| 279 | ProxyAccessMode proxy_access_mode) const; |
Harkiran Bolaria | a834778 | 2022-04-06 09:25:11 | [diff] [blame] | 280 | |
Sharon Yang | 417a5df | 2024-04-23 17:57:15 | [diff] [blame] | 281 | // Helper to check if all refcounts SiteInstanceGroup keeps track of are zero. |
| 282 | // Deletes all corresponding proxies if so. RefCountType is for tracing. |
| 283 | enum RefCountType { |
| 284 | kActiveFrameCount = 0, |
| 285 | kKeepAliveCount = 1, |
| 286 | }; |
| 287 | void CheckIfSiteInstanceGroupIsUnused(SiteInstanceGroup* site_instance_group, |
| 288 | RefCountType ref_count_type); |
| 289 | |
Harkiran Bolaria | 2912a6b3 | 2022-02-22 16:43:45 | [diff] [blame] | 290 | // Proxy hosts for this browsing context in various renderer processes, keyed |
| 291 | // by SiteInstanceGroup ID. |
Harkiran Bolaria | 812f2287 | 2021-12-08 13:34:50 | [diff] [blame] | 292 | RenderFrameProxyHostMap proxy_hosts_; |
Harkiran Bolaria | 4eacb3a | 2021-12-13 20:03:47 | [diff] [blame] | 293 | |
| 294 | // Track information that needs to be replicated to processes that have |
| 295 | // proxies for this frame. |
| 296 | blink::mojom::FrameReplicationStatePtr replication_state_; |
Harkiran Bolaria | 880a763 | 2022-02-28 16:02:50 | [diff] [blame] | 297 | |
| 298 | // Parent document of this BrowsingContextState, might be null if this is a |
| 299 | // main frame BrowsingContextState. |
| 300 | const raw_ptr<RenderFrameHostImpl> parent_; |
Harkiran Bolaria | 0b3bdef0 | 2022-03-10 13:04:40 | [diff] [blame] | 301 | |
Camille Lamy | c935192 | 2025-05-01 02:57:44 | [diff] [blame] | 302 | // ID of the BrowsingInstance to which this BrowsingContextState belongs. |
| 303 | // Currently `browsing_instance_id` and will be null iff the legacy mode is |
| 304 | // enabled, as the legacy mode BrowsingContextState is 1:1 with FrameTreeNode |
| 305 | // and therefore doesn't have a dedicated associated BrowsingInstance. |
| 306 | // TODO(crbug.com/40205442): Make `browsing_instance_id` non-optional when the |
| 307 | // legacy path is removed. |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 308 | const std::optional<BrowsingInstanceId> browsing_instance_id_; |
Harkiran Bolaria | 875d4f6 | 2022-05-17 16:18:23 | [diff] [blame] | 309 | |
| 310 | base::WeakPtrFactory<BrowsingContextState> weak_factory_{this}; |
Harkiran Bolaria | 8dec6f9 | 2021-12-07 14:57:12 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | } // namespace content |
| 314 | |
| 315 | #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSING_CONTEXT_STATE_H_ |