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