1 // Copyright 2015 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.
7 import "network/public/interfaces/url_loader.mojom";
9 // This files defines the interfaces and structures used for frames.
11 // When a client in the frame tree is connected to by way of the ViewManager a
12 // FrameClient is obtained (from the ServiceProvider interface request passed
13 // in ViewManager::OnEmbed()). The FrameClient is told the frame tree (by way
14 // of OnConnection()), which allows the client to use other frames in the tree
15 // (assuming the client has the appropriate permissions).
17 // frame_ids are the same as views ids. This means that when a client creates
18 // a new view to be part of the frame tree it immediately knows the id to use
21 // The server provides an id that may be used to identify the state of the
22 // tree. The change id is an integer that is incremented every time the
23 // structure of the tree changes. The change id is not used by the server; the
24 // server only updates the change id and notifies clients of the new id (by
25 // way of structure change functions such as OnFrameAdded()).
27 // Expresses a preference for where a navigation should occur.
28 enum NavigationTargetType {
32 // In the specified frame.
39 // Provides information about a frame.
41 // 0 if the frame has no parent (its the root).
45 // A map of the properties supplied by the client. The server does not
46 // intepret these values in anyway, the meaning and usage is left up to
48 map<string, array<uint8>>? client_properties;
51 // TODO(sky): decide which bits of this make sense for all frames, and move the
52 // html specific parts into properties.
53 struct HTMLMessageEvent {
54 // The serialized script value.
57 // The origin of the source frame.
60 // The origin for the message's target.
61 string? target_origin;
63 // TODO(sky): these two are not implemented. Figure out what they should be.
64 // Information about the MessagePorts this message contains.
65 // IPC_STRUCT_MEMBER(std::vector<content::TransferredMessagePort>, message_ports)
66 // IPC_STRUCT_MEMBER(std::vector<int>, new_routing_ids)
70 // Requests the server to message the specified frame with |event|. If the
71 // operation is allowed OnPostMessageEvent() is called on the appropriate
73 PostMessageEventToFrame(uint32 target_frame_id, HTMLMessageEvent event);
75 // Notifies the server that the loading state and progress changed.
76 LoadingStateChanged(bool loading, double progress);
78 // Called when the title becomes available or changes.
79 TitleChanged(string? title);
81 // Called when the response body has been received.
82 DidCommitProvisionalLoad();
84 // Sets the value of the specified client property, notifying clients if the
85 // value changed. If |value| is null the property is removed.
86 SetClientProperty(string name, array<uint8>? value);
88 // Called when the client creates a new frame. |frame_id| corresponds to
89 // the id of the view hosting the frame, and |parent_id| the id of the
90 // parent. See FrameData::client_properties for details of
91 // |client_properties|.
93 // Note that the FrameClient still gets an OnConnect(), but the only thing of
94 // interest is the callback.
95 OnCreatedFrame(Frame& frame_request,
98 map<string, array<uint8>> client_properties);
100 // Requests a navigation. If |target_TYPE| is |EXISTING_FRAME|, then
101 // |target_frame_id| identifies the frame to navigate in. Otherwise
102 // |target_frame_id| is unused.
103 RequestNavigate(NavigationTargetType target_type,
104 uint32 target_frame_id,
105 mojo.URLRequest request);
107 // The frame navigated locally, for example, pushState() navigations in an
109 DidNavigateLocally(string url);
111 // Dispatches a load event to the parent of the frame.
112 DispatchLoadEventToParent();
115 enum ViewConnectType {
116 // Indicates the app is already a ViewTreeClient and the existing view should
117 // be used. In this case the app is not asked for a new ViewTreeClient.
120 // Indicates a new ViewTreeClient is obtained and the View provided to
121 // OnEmbed() should be used.
125 interface FrameClient {
126 // Called once per client. |frame_data| gives the contents of the tree.
127 // |view_id| is the id of the view the FrameClient should render to. If a
128 // ViewTreeClient is asked for then |view_id| is the same id as that of the
129 // View supplied to ViewTreeClient::OnEmbed().
130 OnConnect(Frame? frame,
133 ViewConnectType view_connect_type,
134 array<FrameData>? frame_data) => ();
136 // Called when a new frame is added to the tree.
137 OnFrameAdded(uint32 change_id, FrameData frame_data);
139 // Called when a frame is removed from the tree.
140 OnFrameRemoved(uint32 change_id, uint32 frame_id);
142 // Called when a client property changes.
143 OnFrameClientPropertyChanged(uint32 frame_id,
145 array<uint8>? new_value);
147 // See description in PostMessageEventToFrame().
148 OnPostMessageEvent(uint32 source_frame_id,
149 uint32 target_frame_id,
150 HTMLMessageEvent event);
152 // Called prior to starting a new navigation. This is only called on the
153 // FrameClient that is rendering to the frame, and only when another content
154 // handler is going to start handling the rendering.
157 // Called to notify that |frame_id|'s loading state has changed. This is only
158 // called on the FrameClient rendering the parent of |frame_id|.
159 OnFrameLoadingStateChanged(uint32 frame_id, bool loading);
161 // Called to dispatch a load event of |frame_id| in its parent. This is only
162 // called on the FrameClient rendering the parent of |frame_id|.
163 OnDispatchFrameLoadEvent(uint32 frame_id);