| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "components/html_viewer/html_frame_tree_manager.h" | 12 #include "components/html_viewer/html_frame_tree_manager.h" |
| 13 #include "components/html_viewer/replicated_frame_state.h" | 13 #include "components/html_viewer/replicated_frame_state.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 "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 16 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 17 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 17 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 18 #include "third_party/WebKit/public/web/WebFrameClient.h" | 18 #include "third_party/WebKit/public/web/WebFrameClient.h" |
| 19 #include "third_party/WebKit/public/web/WebRemoteFrameClient.h" | 19 #include "third_party/WebKit/public/web/WebRemoteFrameClient.h" |
| 20 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 20 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 21 #include "third_party/WebKit/public/web/WebTextInputInfo.h" | 21 #include "third_party/WebKit/public/web/WebTextInputInfo.h" |
| 22 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 22 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 23 | 23 |
| 24 namespace cc_blink { | 24 namespace cc_blink { |
| 25 class WebLayerImpl; | 25 class WebLayerImpl; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 class HTMLFrameTreeManager; | 48 class HTMLFrameTreeManager; |
| 49 class HTMLWidget; | 49 class HTMLWidget; |
| 50 class TouchHandler; | 50 class TouchHandler; |
| 51 class WebLayerTreeViewImpl; | 51 class WebLayerTreeViewImpl; |
| 52 | 52 |
| 53 // 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 |
| 54 // 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 |
| 55 // HTMLFrameTreeManager and can not be moved to another HTMLFrameTreeManager. | 55 // HTMLFrameTreeManager and can not be moved to another HTMLFrameTreeManager. |
| 56 // Local frames have a mus::View, remote frames do not. | 56 // Local frames have a mus::View, remote frames do not. |
| 57 // | 57 // |
| 58 // HTMLFrame serves as the FrameTreeClient. It implements it by forwarding | 58 // HTMLFrame serves as the FrameClient. It implements it by forwarding the |
| 59 // the calls to HTMLFrameTreeManager so that HTMLFrameTreeManager can update | 59 // calls to HTMLFrameTreeManager so that HTMLFrameTreeManager can update the |
| 60 // the frame tree as appropriate. | 60 // frame tree as appropriate. |
| 61 // | 61 // |
| 62 // Local frames may share the connection (and client implementation) with an | 62 // Local frames may share the connection (and client implementation) with an |
| 63 // 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 |
| 64 // happens the frame is swapped to a remote frame. | 64 // happens the frame is swapped to a remote frame. |
| 65 // | 65 // |
| 66 // 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 |
| 67 // process. See HTMLFrameTreeManager for details. | 67 // process. See HTMLFrameTreeManager for details. |
| 68 class HTMLFrame : public blink::WebFrameClient, | 68 class HTMLFrame : public blink::WebFrameClient, |
| 69 public blink::WebRemoteFrameClient, | 69 public blink::WebRemoteFrameClient, |
| 70 public web_view::FrameTreeClient, | 70 public web_view::mojom::FrameClient, |
| 71 public mus::ViewObserver { | 71 public mus::ViewObserver { |
| 72 public: | 72 public: |
| 73 struct CreateParams { | 73 struct CreateParams { |
| 74 CreateParams( | 74 CreateParams( |
| 75 HTMLFrameTreeManager* manager, | 75 HTMLFrameTreeManager* manager, |
| 76 HTMLFrame* parent, | 76 HTMLFrame* parent, |
| 77 uint32_t id, | 77 uint32_t id, |
| 78 mus::View* view, | 78 mus::View* view, |
| 79 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties, | 79 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties, |
| 80 HTMLFrameDelegate* delegate) | 80 HTMLFrameDelegate* delegate) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 const blink::WebHistoryItem& item, | 188 const blink::WebHistoryItem& item, |
| 189 blink::WebHistoryCommitType commit_type); | 189 blink::WebHistoryCommitType commit_type); |
| 190 virtual void didReceiveTitle(blink::WebLocalFrame* frame, | 190 virtual void didReceiveTitle(blink::WebLocalFrame* frame, |
| 191 const blink::WebString& title, | 191 const blink::WebString& title, |
| 192 blink::WebTextDirection direction); | 192 blink::WebTextDirection direction); |
| 193 | 193 |
| 194 private: | 194 private: |
| 195 friend class HTMLFrameTreeManager; | 195 friend class HTMLFrameTreeManager; |
| 196 | 196 |
| 197 // Binds this frame to the specified server. |this| serves as the | 197 // Binds this frame to the specified server. |this| serves as the |
| 198 // FrameTreeClient for the server. | 198 // FrameClient for the server. |
| 199 void Bind(web_view::FrameTreeServerPtr frame_tree_server, | 199 void Bind(web_view::mojom::FramePtr frame, |
| 200 mojo::InterfaceRequest<web_view::FrameTreeClient> | 200 mojo::InterfaceRequest<web_view::mojom::FrameClient> |
| 201 frame_tree_client_request); | 201 frame_client_request); |
| 202 | 202 |
| 203 // Sets the appropriate value from the client property. |name| identifies | 203 // Sets the appropriate value from the client property. |name| identifies |
| 204 // the property and |new_data| the new value. | 204 // the property and |new_data| the new value. |
| 205 void SetValueFromClientProperty(const std::string& name, | 205 void SetValueFromClientProperty(const std::string& name, |
| 206 mojo::Array<uint8_t> new_data); | 206 mojo::Array<uint8_t> new_data); |
| 207 | 207 |
| 208 // The local root is the first ancestor (starting at this) that has its own | 208 // The local root is the first ancestor (starting at this) that has its own |
| 209 // delegate. | 209 // delegate. |
| 210 HTMLFrame* GetFirstAncestorWithDelegate(); | 210 HTMLFrame* GetFirstAncestorWithDelegate(); |
| 211 | 211 |
| 212 // Returns the ApplicationImpl from the first ancestor with a delegate. | 212 // Returns the ApplicationImpl from the first ancestor with a delegate. |
| 213 mojo::ApplicationImpl* GetApp(); | 213 mojo::ApplicationImpl* GetApp(); |
| 214 | 214 |
| 215 // Gets the FrameTreeServer to use for this frame. | 215 // Gets the server Frame to use for this frame. |
| 216 web_view::FrameTreeServer* GetFrameTreeServer(); | 216 web_view::mojom::Frame* GetServerFrame(); |
| 217 | 217 |
| 218 void SetView(mus::View* view); | 218 void SetView(mus::View* view); |
| 219 | 219 |
| 220 // Creates the appropriate WebWidget implementation for the Frame. | 220 // Creates the appropriate WebWidget implementation for the Frame. |
| 221 void CreateRootWebWidget(); | 221 void CreateRootWebWidget(); |
| 222 void CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame); | 222 void CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame); |
| 223 | 223 |
| 224 void UpdateFocus(); | 224 void UpdateFocus(); |
| 225 | 225 |
| 226 // Swaps this frame from a local frame to remote frame. |request| is the url | 226 // Swaps this frame from a local frame to remote frame. |request| is the url |
| (...skipping 21 matching lines...) Expand all Loading... |
| 248 | 248 |
| 249 // mus::ViewObserver methods: | 249 // mus::ViewObserver methods: |
| 250 void OnViewBoundsChanged(mus::View* view, | 250 void OnViewBoundsChanged(mus::View* view, |
| 251 const mojo::Rect& old_bounds, | 251 const mojo::Rect& old_bounds, |
| 252 const mojo::Rect& new_bounds) override; | 252 const mojo::Rect& new_bounds) override; |
| 253 void OnViewDestroyed(mus::View* view) override; | 253 void OnViewDestroyed(mus::View* view) override; |
| 254 void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override; | 254 void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override; |
| 255 void OnViewFocusChanged(mus::View* gained_focus, | 255 void OnViewFocusChanged(mus::View* gained_focus, |
| 256 mus::View* lost_focus) override; | 256 mus::View* lost_focus) override; |
| 257 | 257 |
| 258 // web_view::FrameTreeClient: | 258 // web_view::mojom::FrameClient: |
| 259 void OnConnect(web_view::FrameTreeServerPtr server, | 259 void OnConnect(web_view::mojom::FramePtr server, |
| 260 uint32_t change_id, | 260 uint32_t change_id, |
| 261 uint32_t view_id, | 261 uint32_t view_id, |
| 262 web_view::ViewConnectType view_connect_type, | 262 web_view::mojom::ViewConnectType view_connect_type, |
| 263 mojo::Array<web_view::FrameDataPtr> frame_data, | 263 mojo::Array<web_view::mojom::FrameDataPtr> frame_data, |
| 264 const OnConnectCallback& callback) override; | 264 const OnConnectCallback& callback) override; |
| 265 void OnFrameAdded(uint32_t change_id, | 265 void OnFrameAdded(uint32_t change_id, |
| 266 web_view::FrameDataPtr frame_data) override; | 266 web_view::mojom::FrameDataPtr frame_data) override; |
| 267 void OnFrameRemoved(uint32_t change_id, uint32_t frame_id) override; | 267 void OnFrameRemoved(uint32_t change_id, uint32_t frame_id) override; |
| 268 void OnFrameClientPropertyChanged(uint32_t frame_id, | 268 void OnFrameClientPropertyChanged(uint32_t frame_id, |
| 269 const mojo::String& name, | 269 const mojo::String& name, |
| 270 mojo::Array<uint8_t> new_value) override; | 270 mojo::Array<uint8_t> new_value) override; |
| 271 void OnPostMessageEvent( | 271 void OnPostMessageEvent( |
| 272 uint32_t source_frame_id, | 272 uint32_t source_frame_id, |
| 273 uint32_t target_frame_id, | 273 uint32_t target_frame_id, |
| 274 web_view::HTMLMessageEventPtr serialized_event) override; | 274 web_view::mojom::HTMLMessageEventPtr serialized_event) override; |
| 275 void OnWillNavigate() override; | 275 void OnWillNavigate() override; |
| 276 void OnFrameLoadingStateChanged(uint32_t frame_id, bool loading) override; | 276 void OnFrameLoadingStateChanged(uint32_t frame_id, bool loading) override; |
| 277 void OnDispatchFrameLoadEvent(uint32_t frame_id) override; | 277 void OnDispatchFrameLoadEvent(uint32_t frame_id) override; |
| 278 | 278 |
| 279 // blink::WebRemoteFrameClient: | 279 // blink::WebRemoteFrameClient: |
| 280 virtual void frameDetached(blink::WebRemoteFrameClient::DetachType type); | 280 virtual void frameDetached(blink::WebRemoteFrameClient::DetachType type); |
| 281 virtual void postMessageEvent(blink::WebLocalFrame* source_web_frame, | 281 virtual void postMessageEvent(blink::WebLocalFrame* source_web_frame, |
| 282 blink::WebRemoteFrame* target_web_frame, | 282 blink::WebRemoteFrame* target_web_frame, |
| 283 blink::WebSecurityOrigin target_origin, | 283 blink::WebSecurityOrigin target_origin, |
| 284 blink::WebDOMMessageEvent event); | 284 blink::WebDOMMessageEvent event); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 299 const uint32_t id_; | 299 const uint32_t id_; |
| 300 std::vector<HTMLFrame*> children_; | 300 std::vector<HTMLFrame*> children_; |
| 301 blink::WebFrame* web_frame_; | 301 blink::WebFrame* web_frame_; |
| 302 scoped_ptr<HTMLWidget> html_widget_; | 302 scoped_ptr<HTMLWidget> html_widget_; |
| 303 scoped_ptr<GeolocationClientImpl> geolocation_client_impl_; | 303 scoped_ptr<GeolocationClientImpl> geolocation_client_impl_; |
| 304 scoped_ptr<TouchHandler> touch_handler_; | 304 scoped_ptr<TouchHandler> touch_handler_; |
| 305 | 305 |
| 306 scoped_ptr<cc_blink::WebLayerImpl> web_layer_; | 306 scoped_ptr<cc_blink::WebLayerImpl> web_layer_; |
| 307 | 307 |
| 308 HTMLFrameDelegate* delegate_; | 308 HTMLFrameDelegate* delegate_; |
| 309 scoped_ptr<mojo::Binding<web_view::FrameTreeClient>> | 309 scoped_ptr<mojo::Binding<web_view::mojom::FrameClient>> frame_client_binding_; |
| 310 frame_tree_client_binding_; | 310 web_view::mojom::FramePtr server_; |
| 311 web_view::FrameTreeServerPtr server_; | |
| 312 | 311 |
| 313 ReplicatedFrameState state_; | 312 ReplicatedFrameState state_; |
| 314 | 313 |
| 315 // If this frame is the result of creating a local frame | 314 // If this frame is the result of creating a local frame |
| 316 // (createChildFrame()), then |owned_view_| is the View initially created | 315 // (createChildFrame()), then |owned_view_| is the View initially created |
| 317 // for the frame. While the frame is local |owned_view_| is the same as | 316 // for the frame. While the frame is local |owned_view_| is the same as |
| 318 // |view_|. If this frame becomes remote |view_| is set to null and | 317 // |view_|. If this frame becomes remote |view_| is set to null and |
| 319 // |owned_view_| remains as the View initially created for the frame. | 318 // |owned_view_| remains as the View initially created for the frame. |
| 320 // | 319 // |
| 321 // This is done to ensure the View isn't prematurely deleted (it must exist | 320 // This is done to ensure the View isn't prematurely deleted (it must exist |
| 322 // as long as the frame is valid). If the View was deleted as soon as the | 321 // as long as the frame is valid). If the View was deleted as soon as the |
| 323 // frame was swapped to remote then the process rendering to the view would | 322 // frame was swapped to remote then the process rendering to the view would |
| 324 // be severed. | 323 // be severed. |
| 325 scoped_ptr<mus::ScopedViewPtr> owned_view_; | 324 scoped_ptr<mus::ScopedViewPtr> owned_view_; |
| 326 | 325 |
| 327 // This object is only valid in the context of performance tests. | 326 // This object is only valid in the context of performance tests. |
| 328 tracing::StartupPerformanceDataCollectorPtr | 327 tracing::StartupPerformanceDataCollectorPtr |
| 329 startup_performance_data_collector_; | 328 startup_performance_data_collector_; |
| 330 | 329 |
| 331 scoped_ptr<DevToolsAgentImpl> devtools_agent_; | 330 scoped_ptr<DevToolsAgentImpl> devtools_agent_; |
| 332 | 331 |
| 333 base::WeakPtrFactory<HTMLFrame> weak_factory_; | 332 base::WeakPtrFactory<HTMLFrame> weak_factory_; |
| 334 | 333 |
| 335 DISALLOW_COPY_AND_ASSIGN(HTMLFrame); | 334 DISALLOW_COPY_AND_ASSIGN(HTMLFrame); |
| 336 }; | 335 }; |
| 337 | 336 |
| 338 } // namespace html_viewer | 337 } // namespace html_viewer |
| 339 | 338 |
| 340 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ | 339 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_H_ |
| OLD | NEW |