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