Don't preload rarely seen large images
[chromium-blink-merge.git] / components / html_viewer / frame_tree_manager.h
blobef13e7dacaf9b0a596deb59ebcd750168e7d357a
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.
5 #ifndef COMPONENTS_HTML_VIEWER_FRAME_TREE_MANAGER_H_
6 #define COMPONENTS_HTML_VIEWER_FRAME_TREE_MANAGER_H_
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"
16 namespace blink {
17 class WebFrame;
18 class WebFrameClient;
19 class WebLocalFrame;
20 class WebRemoteFrameClient;
21 class WebView;
24 namespace gfx {
25 class Size;
28 namespace mojo {
29 class ApplicationConnection;
30 class ApplicationImpl;
31 class View;
34 namespace html_viewer {
36 class Frame;
37 class FrameTreeManagerDelegate;
38 class GlobalState;
40 // FrameTreeManager is responsible for managing the frames that comprise a
41 // document. Some of the frames may be remote. FrameTreeManager updates its
42 // state in response to changes from the FrameTreeServer, as well as changes
43 // from the underlying frames. The frame tree has at least one local frame
44 // that is backed by a mojo::View.
45 class FrameTreeManager : public mandoline::FrameTreeClient {
46 public:
47 FrameTreeManager(GlobalState* global_state,
48 mojo::ApplicationImpl* app,
49 mojo::ApplicationConnection* app_connection,
50 uint32_t local_frame_id,
51 mandoline::FrameTreeServerPtr server);
52 ~FrameTreeManager() override;
54 void Init(mojo::View* local_view,
55 mojo::Array<mandoline::FrameDataPtr> frame_data);
57 void set_delegate(FrameTreeManagerDelegate* delegate) {
58 delegate_ = delegate;
61 GlobalState* global_state() { return global_state_; }
62 mojo::ApplicationImpl* app() { return app_; }
64 // Returns the Frame/WebFrame that is rendering to the supplied view.
65 // TODO(sky): we need to support more than one local frame.
66 Frame* GetLocalFrame();
67 blink::WebLocalFrame* GetLocalWebFrame();
69 blink::WebView* GetWebView();
71 private:
72 friend class Frame;
74 // Recursively calls Init() on |frame| and it's children.
75 void InitFrames(mojo::View* local_view, Frame* frame);
77 // Returns the navigation policy for the specified frame.
78 blink::WebNavigationPolicy DecidePolicyForNavigation(
79 Frame* frame,
80 const blink::WebFrameClient::NavigationPolicyInfo& info);
82 // Invoked when a Frame finishes loading.
83 void OnFrameDidFinishLoad(Frame* frame);
85 // Invoked when a Frame navigates.
86 void OnFrameDidNavigateLocally(Frame* frame, const std::string& url);
88 // Invoked when a Frame is destroye.
89 void OnFrameDestroyed(Frame* frame);
91 // mandoline::FrameTreeClient:
92 void OnConnect(mandoline::FrameTreeServerPtr server,
93 mojo::Array<mandoline::FrameDataPtr> frame_data) override;
94 void OnFrameAdded(mandoline::FrameDataPtr frame_data) override;
95 void OnFrameRemoved(uint32_t frame_id) override;
97 GlobalState* global_state_;
99 mojo::ApplicationImpl* app_;
101 FrameTreeManagerDelegate* delegate_;
103 // Frame id of the frame we're rendering to.
104 const uint32_t local_frame_id_;
106 mandoline::FrameTreeServerPtr server_;
108 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_;
110 Frame* root_;
112 DISALLOW_COPY_AND_ASSIGN(FrameTreeManager);
115 } // namespace html_viewer
117 #endif // COMPONENTS_HTML_VIEWER_FRAME_TREE_MANAGER_H_