| 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_FRAME_TREE_MANAGER_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ |
| 6 #define COMPONENTS_HTML_VIEWER_FRAME_TREE_MANAGER_H_ | 6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" | 10 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" |
| 11 #include "mandoline/tab/public/interfaces/frame_tree.mojom.h" | 11 #include "mandoline/tab/public/interfaces/frame_tree.mojom.h" |
| 12 #include "mojo/application/public/cpp/lazy_interface_ptr.h" | 12 #include "mojo/application/public/cpp/lazy_interface_ptr.h" |
| 13 #include "third_party/WebKit/public/web/WebFrameClient.h" | 13 #include "third_party/WebKit/public/web/WebFrameClient.h" |
| 14 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 14 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace mojo { | 29 namespace mojo { |
| 30 class ApplicationConnection; | 30 class ApplicationConnection; |
| 31 class ApplicationImpl; | 31 class ApplicationImpl; |
| 32 class View; | 32 class View; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace html_viewer { | 35 namespace html_viewer { |
| 36 | 36 |
| 37 class Frame; | 37 class HTMLFrame; |
| 38 class FrameTreeManagerDelegate; | 38 class HTMLFrameTreeManagerDelegate; |
| 39 class GlobalState; | 39 class GlobalState; |
| 40 | 40 |
| 41 // FrameTreeManager is responsible for managing the frames that comprise a | 41 // HTMLFrameTreeManager is responsible for managing the frames that comprise a |
| 42 // document. Some of the frames may be remote. FrameTreeManager updates its | 42 // document. Some of the frames may be remote. HTMLFrameTreeManager updates its |
| 43 // state in response to changes from the FrameTreeServer, as well as changes | 43 // state in response to changes from the FrameTreeServer, as well as changes |
| 44 // from the underlying frames. The frame tree has at least one local frame | 44 // from the underlying frames. The frame tree has at least one local frame |
| 45 // that is backed by a mojo::View. | 45 // that is backed by a mojo::View. |
| 46 class FrameTreeManager : public mandoline::FrameTreeClient { | 46 class HTMLFrameTreeManager : public mandoline::FrameTreeClient { |
| 47 public: | 47 public: |
| 48 FrameTreeManager(GlobalState* global_state, | 48 HTMLFrameTreeManager(GlobalState* global_state, |
| 49 mojo::ApplicationImpl* app, | 49 mojo::ApplicationImpl* app, |
| 50 mojo::ApplicationConnection* app_connection, | 50 mojo::ApplicationConnection* app_connection, |
| 51 uint32_t local_frame_id, | 51 uint32_t local_frame_id, |
| 52 mandoline::FrameTreeServerPtr server); | 52 mandoline::FrameTreeServerPtr server); |
| 53 ~FrameTreeManager() override; | 53 ~HTMLFrameTreeManager() override; |
| 54 | 54 |
| 55 void Init(mojo::View* local_view, | 55 void Init(mojo::View* local_view, |
| 56 mojo::Array<mandoline::FrameDataPtr> frame_data); | 56 mojo::Array<mandoline::FrameDataPtr> frame_data); |
| 57 | 57 |
| 58 void set_delegate(FrameTreeManagerDelegate* delegate) { | 58 void set_delegate(HTMLFrameTreeManagerDelegate* delegate) { |
| 59 delegate_ = delegate; | 59 delegate_ = delegate; |
| 60 } | 60 } |
| 61 | 61 |
| 62 GlobalState* global_state() { return global_state_; } | 62 GlobalState* global_state() { return global_state_; } |
| 63 mojo::ApplicationImpl* app() { return app_; } | 63 mojo::ApplicationImpl* app() { return app_; } |
| 64 | 64 |
| 65 // Returns the Frame/WebFrame that is rendering to the supplied view. | 65 // Returns the Frame/WebFrame that is rendering to the supplied view. |
| 66 // TODO(sky): we need to support more than one local frame. | 66 // TODO(sky): we need to support more than one local frame. |
| 67 Frame* GetLocalFrame(); | 67 HTMLFrame* GetLocalFrame(); |
| 68 blink::WebLocalFrame* GetLocalWebFrame(); | 68 blink::WebLocalFrame* GetLocalWebFrame(); |
| 69 | 69 |
| 70 blink::WebView* GetWebView(); | 70 blink::WebView* GetWebView(); |
| 71 | 71 |
| 72 void LoadingStarted(); | 72 void LoadingStarted(); |
| 73 void LoadingStopped(); | 73 void LoadingStopped(); |
| 74 void ProgressChanged(double progress); | 74 void ProgressChanged(double progress); |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 friend class Frame; | 77 friend class HTMLFrame; |
| 78 | 78 |
| 79 // Returns the navigation policy for the specified frame. | 79 // Returns the navigation policy for the specified frame. |
| 80 blink::WebNavigationPolicy DecidePolicyForNavigation( | 80 blink::WebNavigationPolicy DecidePolicyForNavigation( |
| 81 Frame* frame, | 81 HTMLFrame* frame, |
| 82 const blink::WebFrameClient::NavigationPolicyInfo& info); | 82 const blink::WebFrameClient::NavigationPolicyInfo& info); |
| 83 | 83 |
| 84 // Invoked when a Frame finishes loading. | 84 // Invoked when a Frame finishes loading. |
| 85 void OnFrameDidFinishLoad(Frame* frame); | 85 void OnFrameDidFinishLoad(HTMLFrame* frame); |
| 86 | 86 |
| 87 // Invoked when a Frame navigates. | 87 // Invoked when a Frame navigates. |
| 88 void OnFrameDidNavigateLocally(Frame* frame, const std::string& url); | 88 void OnFrameDidNavigateLocally(HTMLFrame* frame, const std::string& url); |
| 89 | 89 |
| 90 // Invoked when a Frame is destroye. | 90 // Invoked when a Frame is destroye. |
| 91 void OnFrameDestroyed(Frame* frame); | 91 void OnFrameDestroyed(HTMLFrame* frame); |
| 92 | 92 |
| 93 // Invoked when the name of a frame changes. | 93 // Invoked when the name of a frame changes. |
| 94 void OnFrameDidChangeName(Frame* frame, const blink::WebString& name); | 94 void OnFrameDidChangeName(HTMLFrame* frame, const blink::WebString& name); |
| 95 | 95 |
| 96 // mandoline::FrameTreeClient: | 96 // mandoline::FrameTreeClient: |
| 97 void OnConnect(mandoline::FrameTreeServerPtr server, | 97 void OnConnect(mandoline::FrameTreeServerPtr server, |
| 98 mojo::Array<mandoline::FrameDataPtr> frame_data) override; | 98 mojo::Array<mandoline::FrameDataPtr> frame_data) override; |
| 99 void OnFrameAdded(mandoline::FrameDataPtr frame_data) override; | 99 void OnFrameAdded(mandoline::FrameDataPtr frame_data) override; |
| 100 void OnFrameRemoved(uint32_t frame_id) override; | 100 void OnFrameRemoved(uint32_t frame_id) override; |
| 101 void OnFrameNameChanged(uint32_t frame_id, const mojo::String& name) override; | 101 void OnFrameNameChanged(uint32_t frame_id, const mojo::String& name) override; |
| 102 | 102 |
| 103 GlobalState* global_state_; | 103 GlobalState* global_state_; |
| 104 | 104 |
| 105 mojo::ApplicationImpl* app_; | 105 mojo::ApplicationImpl* app_; |
| 106 | 106 |
| 107 FrameTreeManagerDelegate* delegate_; | 107 HTMLFrameTreeManagerDelegate* delegate_; |
| 108 | 108 |
| 109 // Frame id of the frame we're rendering to. | 109 // Frame id of the frame we're rendering to. |
| 110 const uint32_t local_frame_id_; | 110 const uint32_t local_frame_id_; |
| 111 | 111 |
| 112 mandoline::FrameTreeServerPtr server_; | 112 mandoline::FrameTreeServerPtr server_; |
| 113 | 113 |
| 114 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; | 114 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; |
| 115 | 115 |
| 116 Frame* root_; | 116 HTMLFrame* root_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(FrameTreeManager); | 118 DISALLOW_COPY_AND_ASSIGN(HTMLFrameTreeManager); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace html_viewer | 121 } // namespace html_viewer |
| 122 | 122 |
| 123 #endif // COMPONENTS_HTML_VIEWER_FRAME_TREE_MANAGER_H_ | 123 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ |
| OLD | NEW |