Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / common / frame_replication_state.h
blob37612c873f7f2ae5aa5d6a0b4dce27e43066228c
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_FRAME_REPLICATION_STATE_H_
6 #define CONTENT_COMMON_FRAME_REPLICATION_STATE_H_
8 #include "content/common/content_export.h"
9 #include "url/origin.h"
11 namespace blink {
12 enum class WebTreeScopeType;
13 enum class WebSandboxFlags;
16 namespace content {
18 // This structure holds information that needs to be replicated between a
19 // RenderFrame and any of its associated RenderFrameProxies.
20 struct CONTENT_EXPORT FrameReplicationState {
21 FrameReplicationState();
22 FrameReplicationState(blink::WebTreeScopeType scope,
23 const std::string& name,
24 blink::WebSandboxFlags sandbox_flags);
25 ~FrameReplicationState();
27 // Current origin of the frame. This field is updated whenever a frame
28 // navigation commits.
30 // TODO(alexmos): For now, |origin| updates are immediately sent to all frame
31 // proxies when in --site-per-process mode. This isn't ideal, since Blink
32 // typically needs a proxy's origin only when performing security checks on
33 // the ancestors of a local frame. So, as a future improvement, we could
34 // delay sending origin updates to proxies until they have a local descendant
35 // (if ever). This would reduce leaking a user's browsing history into a
36 // compromized renderer.
37 url::Origin origin;
39 // Current sandbox flags of the frame. |sandbox_flags| are initialized for
40 // new child frames using the value of the <iframe> element's "sandbox"
41 // attribute. They are updated dynamically whenever a parent frame updates an
42 // <iframe>'s sandbox attribute via JavaScript.
44 // Updates to |sandbox_flags| are sent to proxies, but only after a
45 // subsequent navigation of the (sandboxed) frame, since the flags only take
46 // effect on navigation (see also FrameTreeNode::effective_sandbox_flags_).
47 // The proxies need updated flags so that they can be inherited properly if a
48 // proxy ever becomes a parent of a local frame.
49 blink::WebSandboxFlags sandbox_flags;
51 // The assigned name of the frame. This name can be empty, unlike the unique
52 // name generated internally in the DOM tree.
54 // |name| is set when a new child frame is created using the value of the
55 // <iframe> element's "name" attribute (see
56 // RenderFrameHostImpl::OnCreateChildFrame), and it is updated dynamically
57 // whenever a frame sets its window.name.
59 // |name| updates are immediately sent to all frame proxies (when in
60 // --site-per-process mode), so that other frames can look up or navigate a
61 // frame using its updated name (e.g., using window.open(url, frame_name)).
62 std::string name;
64 // Whether the frame is in a document tree or a shadow tree, per the Shadow
65 // DOM spec: https://w3c.github.io/webcomponents/spec/shadow/
66 // Note: This should really be const, as it can never change once a frame is
67 // created. However, making it const makes it a pain to embed into IPC message
68 // params: having a const member implicitly deletes the copy assignment
69 // operator.
70 blink::WebTreeScopeType scope;
72 // TODO(alexmos): Eventually, this structure can also hold other state that
73 // needs to be replicated, such as frame sizing info.
76 } // namespace content
78 #endif // CONTENT_COMMON_FRAME_REPLICATION_STATE_H_