OLD | NEW |
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_HTML_VIEWER_HTML_FRAME_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ |
6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ | 6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 class WebFrame; | 29 class WebFrame; |
30 class WebWidget; | 30 class WebWidget; |
31 } | 31 } |
32 | 32 |
33 namespace mojo { | 33 namespace mojo { |
34 class ApplicationImpl; | 34 class ApplicationImpl; |
35 class Rect; | 35 class Rect; |
36 } | |
37 | |
38 namespace mus { | |
39 class ScopedViewPtr; | 36 class ScopedViewPtr; |
40 class View; | 37 class View; |
41 } | 38 } |
42 | 39 |
43 namespace html_viewer { | 40 namespace html_viewer { |
44 | 41 |
45 class DevToolsAgentImpl; | 42 class DevToolsAgentImpl; |
46 class GeolocationClientImpl; | 43 class GeolocationClientImpl; |
47 class HTMLFrameDelegate; | 44 class HTMLFrameDelegate; |
48 class HTMLFrameTreeManager; | 45 class HTMLFrameTreeManager; |
49 class HTMLWidget; | 46 class HTMLWidget; |
50 class TouchHandler; | 47 class TouchHandler; |
51 class WebLayerTreeViewImpl; | 48 class WebLayerTreeViewImpl; |
52 | 49 |
53 // Frame is used to represent a single frame in the frame tree of a page. The | 50 // Frame is used to represent a single frame in the frame tree of a page. The |
54 // frame is either local or remote. Each Frame is associated with a single | 51 // frame is either local or remote. Each Frame is associated with a single |
55 // HTMLFrameTreeManager and can not be moved to another HTMLFrameTreeManager. | 52 // HTMLFrameTreeManager and can not be moved to another HTMLFrameTreeManager. |
56 // Local frames have a mus::View, remote frames do not. | 53 // Local frames have a mojo::View, remote frames do not. |
57 // | 54 // |
58 // HTMLFrame serves as the FrameTreeClient. It implements it by forwarding | 55 // HTMLFrame serves as the FrameTreeClient. It implements it by forwarding |
59 // the calls to HTMLFrameTreeManager so that HTMLFrameTreeManager can update | 56 // the calls to HTMLFrameTreeManager so that HTMLFrameTreeManager can update |
60 // the frame tree as appropriate. | 57 // the frame tree as appropriate. |
61 // | 58 // |
62 // Local frames may share the connection (and client implementation) with an | 59 // Local frames may share the connection (and client implementation) with an |
63 // ancestor. This happens when a child frame is created. Once a navigate | 60 // ancestor. This happens when a child frame is created. Once a navigate |
64 // happens the frame is swapped to a remote frame. | 61 // happens the frame is swapped to a remote frame. |
65 // | 62 // |
66 // Remote frames may become local again if the embed happens in the same | 63 // Remote frames may become local again if the embed happens in the same |
67 // process. See HTMLFrameTreeManager for details. | 64 // process. See HTMLFrameTreeManager for details. |
68 class HTMLFrame : public blink::WebFrameClient, | 65 class HTMLFrame : public blink::WebFrameClient, |
69 public blink::WebRemoteFrameClient, | 66 public blink::WebRemoteFrameClient, |
70 public web_view::FrameTreeClient, | 67 public web_view::FrameTreeClient, |
71 public mus::ViewObserver { | 68 public mojo::ViewObserver { |
72 public: | 69 public: |
73 struct CreateParams { | 70 struct CreateParams { |
74 CreateParams( | 71 CreateParams( |
75 HTMLFrameTreeManager* manager, | 72 HTMLFrameTreeManager* manager, |
76 HTMLFrame* parent, | 73 HTMLFrame* parent, |
77 uint32_t id, | 74 uint32_t id, |
78 mus::View* view, | 75 mojo::View* view, |
79 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties, | 76 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties, |
80 HTMLFrameDelegate* delegate) | 77 HTMLFrameDelegate* delegate) |
81 : manager(manager), | 78 : manager(manager), |
82 parent(parent), | 79 parent(parent), |
83 id(id), | 80 id(id), |
84 view(view), | 81 view(view), |
85 properties(properties), | 82 properties(properties), |
86 delegate(delegate), | 83 delegate(delegate), |
87 allow_local_shared_frame(false) {} | 84 allow_local_shared_frame(false) {} |
88 ~CreateParams() {} | 85 ~CreateParams() {} |
89 | 86 |
90 HTMLFrameTreeManager* manager; | 87 HTMLFrameTreeManager* manager; |
91 HTMLFrame* parent; | 88 HTMLFrame* parent; |
92 uint32_t id; | 89 uint32_t id; |
93 mus::View* view; | 90 mojo::View* view; |
94 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties; | 91 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties; |
95 HTMLFrameDelegate* delegate; | 92 HTMLFrameDelegate* delegate; |
96 | 93 |
97 private: | 94 private: |
98 friend class HTMLFrame; | 95 friend class HTMLFrame; |
99 | 96 |
100 // TODO(sky): nuke. | 97 // TODO(sky): nuke. |
101 bool allow_local_shared_frame; | 98 bool allow_local_shared_frame; |
102 }; | 99 }; |
103 | 100 |
(...skipping 17 matching lines...) Expand all Loading... |
121 | 118 |
122 // Returns the WebFrame for this Frame. This is either a WebLocalFrame or | 119 // Returns the WebFrame for this Frame. This is either a WebLocalFrame or |
123 // WebRemoteFrame. | 120 // WebRemoteFrame. |
124 blink::WebFrame* web_frame() { return web_frame_; } | 121 blink::WebFrame* web_frame() { return web_frame_; } |
125 | 122 |
126 // Returns the WebView for this frame, or null if there isn't one. The root | 123 // Returns the WebView for this frame, or null if there isn't one. The root |
127 // has a WebView, the children WebFrameWidgets. | 124 // has a WebView, the children WebFrameWidgets. |
128 blink::WebView* web_view(); | 125 blink::WebView* web_view(); |
129 blink::WebWidget* GetWebWidget(); | 126 blink::WebWidget* GetWebWidget(); |
130 | 127 |
131 // The mus::View this frame renders to. This is non-null for the local frame | 128 // The mojo::View this frame renders to. This is non-null for the local frame |
132 // the frame tree was created with as well as non-null for any frames created | 129 // the frame tree was created with as well as non-null for any frames created |
133 // locally. | 130 // locally. |
134 mus::View* view() { return view_; } | 131 mojo::View* view() { return view_; } |
135 | 132 |
136 HTMLFrameTreeManager* frame_tree_manager() { return frame_tree_manager_; } | 133 HTMLFrameTreeManager* frame_tree_manager() { return frame_tree_manager_; } |
137 | 134 |
138 // Returns null if the browser side didn't request to setup an agent in this | 135 // Returns null if the browser side didn't request to setup an agent in this |
139 // frame. | 136 // frame. |
140 DevToolsAgentImpl* devtools_agent() { return devtools_agent_.get(); } | 137 DevToolsAgentImpl* devtools_agent() { return devtools_agent_.get(); } |
141 | 138 |
142 // Returns true if the Frame is local, false if remote. | 139 // Returns true if the Frame is local, false if remote. |
143 bool IsLocal() const; | 140 bool IsLocal() const; |
144 | 141 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // The local root is the first ancestor (starting at this) that has its own | 203 // The local root is the first ancestor (starting at this) that has its own |
207 // connection. | 204 // connection. |
208 HTMLFrame* GetLocalRoot(); | 205 HTMLFrame* GetLocalRoot(); |
209 | 206 |
210 // Returns the ApplicationImpl from the local root's delegate. | 207 // Returns the ApplicationImpl from the local root's delegate. |
211 mojo::ApplicationImpl* GetLocalRootApp(); | 208 mojo::ApplicationImpl* GetLocalRootApp(); |
212 | 209 |
213 // Gets the FrameTreeServer to use for this frame. | 210 // Gets the FrameTreeServer to use for this frame. |
214 web_view::FrameTreeServer* GetFrameTreeServer(); | 211 web_view::FrameTreeServer* GetFrameTreeServer(); |
215 | 212 |
216 void SetView(mus::View* view); | 213 void SetView(mojo::View* view); |
217 | 214 |
218 // Creates the appropriate WebWidget implementation for the Frame. | 215 // Creates the appropriate WebWidget implementation for the Frame. |
219 void CreateRootWebWidget(); | 216 void CreateRootWebWidget(); |
220 void CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame); | 217 void CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame); |
221 | 218 |
222 void UpdateFocus(); | 219 void UpdateFocus(); |
223 | 220 |
224 // Swaps this frame from a local frame to remote frame. |request| is the url | 221 // Swaps this frame from a local frame to remote frame. |request| is the url |
225 // to load in the frame. | 222 // to load in the frame. |
226 void SwapToRemote(); | 223 void SwapToRemote(); |
227 | 224 |
228 // Swaps this frame from a remote frame to a local frame. | 225 // Swaps this frame from a remote frame to a local frame. |
229 void SwapToLocal( | 226 void SwapToLocal( |
230 HTMLFrameDelegate* delegate, | 227 HTMLFrameDelegate* delegate, |
231 mus::View* view, | 228 mojo::View* view, |
232 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties); | 229 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties); |
233 | 230 |
234 // Invoked when changing the delegate. This informs the new delegate to take | 231 // Invoked when changing the delegate. This informs the new delegate to take |
235 // over. This is used when a different connection is going to take over | 232 // over. This is used when a different connection is going to take over |
236 // responsibility for the frame. | 233 // responsibility for the frame. |
237 void SwapDelegate(HTMLFrameDelegate* delegate); | 234 void SwapDelegate(HTMLFrameDelegate* delegate); |
238 | 235 |
239 GlobalState* global_state() { return frame_tree_manager_->global_state(); } | 236 GlobalState* global_state() { return frame_tree_manager_->global_state(); } |
240 | 237 |
241 // Returns the Frame associated with the specified WebFrame. | 238 // Returns the Frame associated with the specified WebFrame. |
242 HTMLFrame* FindFrameWithWebFrame(blink::WebFrame* web_frame); | 239 HTMLFrame* FindFrameWithWebFrame(blink::WebFrame* web_frame); |
243 | 240 |
244 // The various frameDetached() implementations call into this. | 241 // The various frameDetached() implementations call into this. |
245 void FrameDetachedImpl(blink::WebFrame* web_frame); | 242 void FrameDetachedImpl(blink::WebFrame* web_frame); |
246 | 243 |
247 // mus::ViewObserver methods: | 244 // mojo::ViewObserver methods: |
248 void OnViewBoundsChanged(mus::View* view, | 245 void OnViewBoundsChanged(mojo::View* view, |
249 const mojo::Rect& old_bounds, | 246 const mojo::Rect& old_bounds, |
250 const mojo::Rect& new_bounds) override; | 247 const mojo::Rect& new_bounds) override; |
251 void OnViewDestroyed(mus::View* view) override; | 248 void OnViewDestroyed(mojo::View* view) override; |
252 void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override; | 249 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; |
253 void OnViewFocusChanged(mus::View* gained_focus, | 250 void OnViewFocusChanged(mojo::View* gained_focus, |
254 mus::View* lost_focus) override; | 251 mojo::View* lost_focus) override; |
255 | 252 |
256 // web_view::FrameTreeClient: | 253 // web_view::FrameTreeClient: |
257 void OnConnect(web_view::FrameTreeServerPtr server, | 254 void OnConnect(web_view::FrameTreeServerPtr server, |
258 uint32_t change_id, | 255 uint32_t change_id, |
259 uint32_t view_id, | 256 uint32_t view_id, |
260 web_view::ViewConnectType view_connect_type, | 257 web_view::ViewConnectType view_connect_type, |
261 mojo::Array<web_view::FrameDataPtr> frame_data, | 258 mojo::Array<web_view::FrameDataPtr> frame_data, |
262 const OnConnectCallback& callback) override; | 259 const OnConnectCallback& callback) override; |
263 void OnFrameAdded(uint32_t change_id, | 260 void OnFrameAdded(uint32_t change_id, |
264 web_view::FrameDataPtr frame_data) override; | 261 web_view::FrameDataPtr frame_data) override; |
(...skipping 17 matching lines...) Expand all Loading... |
282 float scale_factor); | 279 float scale_factor); |
283 virtual void navigate(const blink::WebURLRequest& request, | 280 virtual void navigate(const blink::WebURLRequest& request, |
284 bool should_replace_current_entry); | 281 bool should_replace_current_entry); |
285 virtual void reload(bool ignore_cache, bool is_client_redirect); | 282 virtual void reload(bool ignore_cache, bool is_client_redirect); |
286 virtual void forwardInputEvent(const blink::WebInputEvent* event); | 283 virtual void forwardInputEvent(const blink::WebInputEvent* event); |
287 | 284 |
288 HTMLFrameTreeManager* frame_tree_manager_; | 285 HTMLFrameTreeManager* frame_tree_manager_; |
289 HTMLFrame* parent_; | 286 HTMLFrame* parent_; |
290 // |view_| is non-null for local frames or remote frames that were once | 287 // |view_| is non-null for local frames or remote frames that were once |
291 // local. | 288 // local. |
292 mus::View* view_; | 289 mojo::View* view_; |
293 // The id for this frame. If there is a view, this is the same id as the | 290 // The id for this frame. If there is a view, this is the same id as the |
294 // view has. | 291 // view has. |
295 const uint32_t id_; | 292 const uint32_t id_; |
296 std::vector<HTMLFrame*> children_; | 293 std::vector<HTMLFrame*> children_; |
297 blink::WebFrame* web_frame_; | 294 blink::WebFrame* web_frame_; |
298 scoped_ptr<HTMLWidget> html_widget_; | 295 scoped_ptr<HTMLWidget> html_widget_; |
299 scoped_ptr<GeolocationClientImpl> geolocation_client_impl_; | 296 scoped_ptr<GeolocationClientImpl> geolocation_client_impl_; |
300 scoped_ptr<TouchHandler> touch_handler_; | 297 scoped_ptr<TouchHandler> touch_handler_; |
301 | 298 |
302 scoped_ptr<cc_blink::WebLayerImpl> web_layer_; | 299 scoped_ptr<cc_blink::WebLayerImpl> web_layer_; |
303 | 300 |
304 HTMLFrameDelegate* delegate_; | 301 HTMLFrameDelegate* delegate_; |
305 scoped_ptr<mojo::Binding<web_view::FrameTreeClient>> | 302 scoped_ptr<mojo::Binding<web_view::FrameTreeClient>> |
306 frame_tree_client_binding_; | 303 frame_tree_client_binding_; |
307 web_view::FrameTreeServerPtr server_; | 304 web_view::FrameTreeServerPtr server_; |
308 | 305 |
309 ReplicatedFrameState state_; | 306 ReplicatedFrameState state_; |
310 | 307 |
311 // If this frame is the result of creating a local frame | 308 // If this frame is the result of creating a local frame |
312 // (createChildFrame()), then |owned_view_| is the View initially created | 309 // (createChildFrame()), then |owned_view_| is the View initially created |
313 // for the frame. While the frame is local |owned_view_| is the same as | 310 // for the frame. While the frame is local |owned_view_| is the same as |
314 // |view_|. If this frame becomes remote |view_| is set to null and | 311 // |view_|. If this frame becomes remote |view_| is set to null and |
315 // |owned_view_| remains as the View initially created for the frame. | 312 // |owned_view_| remains as the View initially created for the frame. |
316 // | 313 // |
317 // This is done to ensure the View isn't prematurely deleted (it must exist | 314 // This is done to ensure the View isn't prematurely deleted (it must exist |
318 // as long as the frame is valid). If the View was deleted as soon as the | 315 // as long as the frame is valid). If the View was deleted as soon as the |
319 // frame was swapped to remote then the process rendering to the view would | 316 // frame was swapped to remote then the process rendering to the view would |
320 // be severed. | 317 // be severed. |
321 scoped_ptr<mus::ScopedViewPtr> owned_view_; | 318 scoped_ptr<mojo::ScopedViewPtr> owned_view_; |
322 | 319 |
323 // This object is only valid in the context of performance tests. | 320 // This object is only valid in the context of performance tests. |
324 tracing::StartupPerformanceDataCollectorPtr | 321 tracing::StartupPerformanceDataCollectorPtr |
325 startup_performance_data_collector_; | 322 startup_performance_data_collector_; |
326 | 323 |
327 scoped_ptr<DevToolsAgentImpl> devtools_agent_; | 324 scoped_ptr<DevToolsAgentImpl> devtools_agent_; |
328 | 325 |
329 base::WeakPtrFactory<HTMLFrame> weak_factory_; | 326 base::WeakPtrFactory<HTMLFrame> weak_factory_; |
330 | 327 |
331 DISALLOW_COPY_AND_ASSIGN(HTMLFrame); | 328 DISALLOW_COPY_AND_ASSIGN(HTMLFrame); |
332 }; | 329 }; |
333 | 330 |
334 } // namespace html_viewer | 331 } // namespace html_viewer |
335 | 332 |
336 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ | 333 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ |
OLD | NEW |