Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: components/web_view/frame.h

Issue 1347023003: Rename frame classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/web_view/client_initiated_frame_connection.cc ('k') | components/web_view/frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_WEB_VIEW_FRAME_H_ 5 #ifndef COMPONENTS_WEB_VIEW_FRAME_H_
6 #define COMPONENTS_WEB_VIEW_FRAME_H_ 6 #define COMPONENTS_WEB_VIEW_FRAME_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "components/mus/public/cpp/types.h" 13 #include "components/mus/public/cpp/types.h"
14 #include "components/mus/public/cpp/view_observer.h" 14 #include "components/mus/public/cpp/view_observer.h"
15 #include "components/web_view/public/interfaces/frame_tree.mojom.h" 15 #include "components/web_view/public/interfaces/frame.mojom.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
17 17
18 namespace web_view { 18 namespace web_view {
19 19
20 class FrameTest; 20 class FrameTest;
21 class FrameTree; 21 class FrameTree;
22 class FrameTreeClient;
23 class FrameUserData; 22 class FrameUserData;
24 23
24 namespace mojom {
25 class FrameClient;
26 }
27
25 enum class ViewOwnership { 28 enum class ViewOwnership {
26 OWNS_VIEW, 29 OWNS_VIEW,
27 DOESNT_OWN_VIEW, 30 DOESNT_OWN_VIEW,
28 }; 31 };
29 32
30 // Frame represents an embedding in a frame. Frames own their children. 33 // Frame represents an embedding in a frame. Frames own their children.
31 // Frames automatically delete themself if the View the frame is associated 34 // Frames automatically delete themself if the View the frame is associated
32 // with is deleted. 35 // with is deleted.
33 // 36 //
34 // In general each Frame has a View. When a new Frame is created by a client 37 // In general each Frame has a View. When a new Frame is created by a client
35 // there may be a small amount of time where the View is not yet known 38 // there may be a small amount of time where the View is not yet known
36 // (separate pipes are used for the view and frame, resulting in undefined 39 // (separate pipes are used for the view and frame, resulting in undefined
37 // message ordering). In this case the view is null and will be set once we 40 // message ordering). In this case the view is null and will be set once we
38 // see the view (OnTreeChanged()). 41 // see the view (OnTreeChanged()).
39 // 42 //
40 // Each frame has an identifier of the app providing the FrameTreeClient 43 // Each frame has an identifier of the app providing the FrameClient
41 // (|app_id|). This id is used when servicing a request to navigate the frame. 44 // (|app_id|). This id is used when servicing a request to navigate the frame.
42 // When navigating, if the id of the new app matches that of the existing app, 45 // When navigating, if the id of the new app matches that of the existing app,
43 // then it is expected that the new FrameTreeClient will take over rendering to 46 // then it is expected that the new FrameClient will take over rendering to the
44 // the existing view. Because of this a new ViewTreeClient is not obtained and 47 // existing view. Because of this a new ViewTreeClient is not obtained and
45 // Embed() is not invoked on the View. The FrameTreeClient can detect this case 48 // Embed() is not invoked on the View. The FrameClient can detect this case by
46 // by the argument |reuse_existing_view| supplied to OnConnect(). Typically the 49 // the argument |reuse_existing_view| supplied to OnConnect(). Typically the id
47 // id is that of content handler id, but this is left up to the 50 // is that of content handler id, but this is left up to the FrameTreeDelegate
48 // FrameTreeDelegate to decide. 51 // to decide.
49 class Frame : public mus::ViewObserver, public FrameTreeServer { 52 class Frame : public mus::ViewObserver, public mojom::Frame {
50 public: 53 public:
51 using ClientPropertyMap = std::map<std::string, std::vector<uint8_t>>; 54 using ClientPropertyMap = std::map<std::string, std::vector<uint8_t>>;
52 55
53 Frame(FrameTree* tree, 56 Frame(FrameTree* tree,
54 mus::View* view, 57 mus::View* view,
55 uint32_t frame_id, 58 uint32_t frame_id,
56 uint32_t app_id, 59 uint32_t app_id,
57 ViewOwnership view_ownership, 60 ViewOwnership view_ownership,
58 FrameTreeClient* frame_tree_client, 61 mojom::FrameClient* frame_client,
59 scoped_ptr<FrameUserData> user_data, 62 scoped_ptr<FrameUserData> user_data,
60 const ClientPropertyMap& client_properties); 63 const ClientPropertyMap& client_properties);
61 ~Frame() override; 64 ~Frame() override;
62 65
63 void Init(Frame* parent, 66 void Init(Frame* parent,
64 mojo::ViewTreeClientPtr view_tree_client, 67 mojo::ViewTreeClientPtr view_tree_client,
65 mojo::InterfaceRequest<FrameTreeServer> server_request); 68 mojo::InterfaceRequest<mojom::Frame> frame_request);
66 69
67 // Walks the View tree starting at |view| going up returning the first 70 // Walks the View tree starting at |view| going up returning the first
68 // Frame that is associated with |view|. For example, if |view| 71 // Frame that is associated with |view|. For example, if |view|
69 // has a Frame associated with it, then that is returned. Otherwise 72 // has a Frame associated with it, then that is returned. Otherwise
70 // this checks view->parent() and so on. 73 // this checks view->parent() and so on.
71 static Frame* FindFirstFrameAncestor(mus::View* view); 74 static Frame* FindFirstFrameAncestor(mus::View* view);
72 75
73 FrameTree* tree() { return tree_; } 76 FrameTree* tree() { return tree_; }
74 77
75 Frame* parent() { return parent_; } 78 Frame* parent() { return parent_; }
(...skipping 26 matching lines...) Expand all
102 bool IsLoading() const; 105 bool IsLoading() const;
103 106
104 // Returns the sum total of loading progress from this Frame and all of its 107 // Returns the sum total of loading progress from this Frame and all of its
105 // children, as well as the number of Frames accumulated. 108 // children, as well as the number of Frames accumulated.
106 double GatherProgress(int* frame_count) const; 109 double GatherProgress(int* frame_count) const;
107 110
108 private: 111 private:
109 friend class FrameTest; 112 friend class FrameTest;
110 friend class FrameTree; 113 friend class FrameTree;
111 114
112 // Identifies whether the FrameTreeClient is from the same app or a different 115 // Identifies whether the FrameClient is from the same app or a different
113 // app. 116 // app.
114 enum class ClientType { 117 enum class ClientType {
115 // The client is either the root frame, or navigating an existing frame 118 // The client is either the root frame, or navigating an existing frame
116 // to a different app. 119 // to a different app.
117 EXISTING_FRAME_NEW_APP, 120 EXISTING_FRAME_NEW_APP,
118 121
119 // The client is the result of navigating an existing frame to a new app. 122 // The client is the result of navigating an existing frame to a new app.
120 EXISTING_FRAME_SAME_APP, 123 EXISTING_FRAME_SAME_APP,
121 124
122 // The client is the result of a new frame (not the root). 125 // The client is the result of a new frame (not the root).
123 NEW_CHILD_FRAME 126 NEW_CHILD_FRAME
124 }; 127 };
125 128
126 struct FrameTreeServerBinding; 129 struct FrameUserDataAndBinding;
127 130
128 // Initializes the client by sending it the state of the tree. 131 // Initializes the client by sending it the state of the tree.
129 // |frame_tree_server_binding| contains the current FrameTreeServerBinding 132 // |data_and_binding| contains the current FrameUserDataAndBinding (if any)
130 // (if any) and is destroyed after the connection responds to OnConnect(). 133 // and is destroyed after the connection responds to OnConnect().
131 // 134 //
132 // If |client_type| is SAME_APP we can't destroy the existing client 135 // If |client_type| is SAME_APP we can't destroy the existing client
133 // (and related data) until we get back the ack from OnConnect(). This way 136 // (and related data) until we get back the ack from OnConnect(). This way
134 // we know the client has completed the switch. If we did not do this it 137 // we know the client has completed the switch. If we did not do this it
135 // would be possible for the app to see it's existing FrameTreeServer 138 // would be possible for the app to see it's existing Frame connection lost
136 // connection lost (and assume the frame is being torn down) before the 139 // (and assume the frame is being torn down) before the OnConnect().
137 // OnConnect().
138 void InitClient(ClientType client_type, 140 void InitClient(ClientType client_type,
139 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding, 141 scoped_ptr<FrameUserDataAndBinding> data_and_binding,
140 mojo::ViewTreeClientPtr view_tree_client, 142 mojo::ViewTreeClientPtr view_tree_client,
141 mojo::InterfaceRequest<FrameTreeServer> server_request); 143 mojo::InterfaceRequest<mojom::Frame> frame_request);
142 144
143 // Callback from OnConnect(). This does nothing (other than destroying 145 // Callback from OnConnect(). This does nothing (other than destroying
144 // |frame_tree_server_binding|). See InitClient() for details as to why 146 // |data_and_binding|). See InitClient() for details as to why destruction of
145 // destruction of |frame_tree_server_binding| happens after OnConnect(). 147 // |data_and_binding| happens after OnConnect().
146 static void OnConnectAck( 148 static void OnConnectAck(
147 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding); 149 scoped_ptr<FrameUserDataAndBinding> data_and_binding);
148 150
149 // Callback from OnEmbed(). 151 // Callback from OnEmbed().
150 void OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id); 152 void OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id);
151 153
152 // Completes a navigation request; swapping the existing FrameTreeClient to 154 // Completes a navigation request; swapping the existing FrameClient to the
153 // the supplied arguments. 155 // supplied arguments.
154 void ChangeClient(FrameTreeClient* frame_tree_client, 156 void ChangeClient(mojom::FrameClient* frame_client,
155 scoped_ptr<FrameUserData> user_data, 157 scoped_ptr<FrameUserData> user_data,
156 mojo::ViewTreeClientPtr view_tree_client, 158 mojo::ViewTreeClientPtr view_tree_client,
157 uint32 app_id); 159 uint32 app_id);
158 160
159 void SetView(mus::View* view); 161 void SetView(mus::View* view);
160 162
161 // Adds this to |frames| and recurses through the children calling the 163 // Adds this to |frames| and recurses through the children calling the
162 // same function. 164 // same function.
163 void BuildFrameTree(std::vector<const Frame*>* frames) const; 165 void BuildFrameTree(std::vector<const Frame*>* frames) const;
164 166
165 void Add(Frame* node); 167 void Add(Frame* node);
166 void Remove(Frame* node); 168 void Remove(Frame* node);
167 169
168 // Starts a new navigation to |request|. The navigation proceeds as long 170 // Starts a new navigation to |request|. The navigation proceeds as long
169 // as there is a View and once OnWillNavigate() has returned. If there is 171 // as there is a View and once OnWillNavigate() has returned. If there is
170 // no View the navigation waits until the View is available. 172 // no View the navigation waits until the View is available.
171 void StartNavigate(mojo::URLRequestPtr request); 173 void StartNavigate(mojo::URLRequestPtr request);
172 void OnCanNavigateFrame(uint32_t app_id, 174 void OnCanNavigateFrame(uint32_t app_id,
173 FrameTreeClient* frame_tree_client, 175 mojom::FrameClient* frame_client,
174 scoped_ptr<FrameUserData> user_data, 176 scoped_ptr<FrameUserData> user_data,
175 mojo::ViewTreeClientPtr view_tree_client); 177 mojo::ViewTreeClientPtr view_tree_client);
176 178
177 // Notifies the client and all descendants as appropriate. 179 // Notifies the client and all descendants as appropriate.
178 void NotifyAdded(const Frame* source, 180 void NotifyAdded(const Frame* source,
179 const Frame* added_node, 181 const Frame* added_node,
180 uint32_t change_id); 182 uint32_t change_id);
181 void NotifyRemoved(const Frame* source, 183 void NotifyRemoved(const Frame* source,
182 const Frame* removed_node, 184 const Frame* removed_node,
183 uint32_t change_id); 185 uint32_t change_id);
184 void NotifyClientPropertyChanged(const Frame* source, 186 void NotifyClientPropertyChanged(const Frame* source,
185 const mojo::String& name, 187 const mojo::String& name,
186 const mojo::Array<uint8_t>& value); 188 const mojo::Array<uint8_t>& value);
187 void NotifyFrameLoadingStateChanged(const Frame* frame, bool loading); 189 void NotifyFrameLoadingStateChanged(const Frame* frame, bool loading);
188 void NotifyDispatchFrameLoadEvent(const Frame* frame); 190 void NotifyDispatchFrameLoadEvent(const Frame* frame);
189 191
190 // mus::ViewObserver: 192 // mus::ViewObserver:
191 void OnTreeChanged(const TreeChangeParams& params) override; 193 void OnTreeChanged(const TreeChangeParams& params) override;
192 void OnViewDestroying(mus::View* view) override; 194 void OnViewDestroying(mus::View* view) override;
193 void OnViewEmbeddedAppDisconnected(mus::View* view) override; 195 void OnViewEmbeddedAppDisconnected(mus::View* view) override;
194 196
195 // FrameTreeServer: 197 // mojom::Frame:
196 void PostMessageEventToFrame(uint32_t target_frame_id, 198 void PostMessageEventToFrame(uint32_t target_frame_id,
197 HTMLMessageEventPtr event) override; 199 mojom::HTMLMessageEventPtr event) override;
198 void LoadingStateChanged(bool loading, double progress) override; 200 void LoadingStateChanged(bool loading, double progress) override;
199 void TitleChanged(const mojo::String& title) override; 201 void TitleChanged(const mojo::String& title) override;
200 void DidCommitProvisionalLoad() override; 202 void DidCommitProvisionalLoad() override;
201 void SetClientProperty(const mojo::String& name, 203 void SetClientProperty(const mojo::String& name,
202 mojo::Array<uint8_t> value) override; 204 mojo::Array<uint8_t> value) override;
203 void OnCreatedFrame( 205 void OnCreatedFrame(
204 mojo::InterfaceRequest<FrameTreeServer> server_request, 206 mojo::InterfaceRequest<mojom::Frame> frame_request,
205 FrameTreeClientPtr client, 207 mojom::FrameClientPtr client,
206 uint32_t frame_id, 208 uint32_t frame_id,
207 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; 209 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override;
208 void RequestNavigate(NavigationTargetType target_type, 210 void RequestNavigate(mojom::NavigationTargetType target_type,
209 uint32_t target_frame_id, 211 uint32_t target_frame_id,
210 mojo::URLRequestPtr request) override; 212 mojo::URLRequestPtr request) override;
211 void DidNavigateLocally(const mojo::String& url) override; 213 void DidNavigateLocally(const mojo::String& url) override;
212 void DispatchLoadEventToParent() override; 214 void DispatchLoadEventToParent() override;
213 215
214 FrameTree* const tree_; 216 FrameTree* const tree_;
215 // WARNING: this may be null. See class description for details. 217 // WARNING: this may be null. See class description for details.
216 mus::View* view_; 218 mus::View* view_;
217 // The connection id returned from ViewManager::Embed(). Frames created by 219 // The connection id returned from ViewManager::Embed(). Frames created by
218 // way of OnCreatedFrame() inherit the id from the parent. 220 // way of OnCreatedFrame() inherit the id from the parent.
219 mus::ConnectionSpecificId embedded_connection_id_; 221 mus::ConnectionSpecificId embedded_connection_id_;
220 // ID for the frame, which is the same as that of the view. 222 // ID for the frame, which is the same as that of the view.
221 const uint32_t id_; 223 const uint32_t id_;
222 // ID of the app providing the FrameTreeClient and ViewTreeClient. 224 // ID of the app providing the FrameClient and ViewTreeClient.
223 uint32_t app_id_; 225 uint32_t app_id_;
224 Frame* parent_; 226 Frame* parent_;
225 ViewOwnership view_ownership_; 227 ViewOwnership view_ownership_;
226 std::vector<Frame*> children_; 228 std::vector<Frame*> children_;
227 scoped_ptr<FrameUserData> user_data_; 229 scoped_ptr<FrameUserData> user_data_;
228 230
229 FrameTreeClient* frame_tree_client_; 231 mojom::FrameClient* frame_client_;
230 232
231 bool loading_; 233 bool loading_;
232 double progress_; 234 double progress_;
233 235
234 ClientPropertyMap client_properties_; 236 ClientPropertyMap client_properties_;
235 237
236 // StartNavigate() stores the request here if the view isn't available at 238 // StartNavigate() stores the request here if the view isn't available at
237 // the time of StartNavigate(). 239 // the time of StartNavigate().
238 mojo::URLRequestPtr pending_navigate_; 240 mojo::URLRequestPtr pending_navigate_;
239 241
240 scoped_ptr<mojo::Binding<FrameTreeServer>> frame_tree_server_binding_; 242 scoped_ptr<mojo::Binding<mojom::Frame>> frame_binding_;
241 243
242 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; 244 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_;
243 245
244 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; 246 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_;
245 247
246 DISALLOW_COPY_AND_ASSIGN(Frame); 248 DISALLOW_COPY_AND_ASSIGN(Frame);
247 }; 249 };
248 250
249 } // namespace web_view 251 } // namespace web_view
250 252
251 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ 253 #endif // COMPONENTS_WEB_VIEW_FRAME_H_
OLDNEW
« no previous file with comments | « components/web_view/client_initiated_frame_connection.cc ('k') | components/web_view/frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698