Remove obsolete entries from .gitignore.
[chromium-blink-merge.git] / components / mus / view_tree_host_impl.h
blob0b7f1b97a2280c70fa462f00579d9e4dc70f0264
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_MUS_VIEW_TREE_HOST_IMPL_H_
6 #define COMPONENTS_MUS_VIEW_TREE_HOST_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/mus/display_manager.h"
10 #include "components/mus/event_dispatcher.h"
11 #include "components/mus/focus_controller_delegate.h"
12 #include "components/mus/public/cpp/types.h"
13 #include "components/mus/public/interfaces/view_tree_host.mojom.h"
14 #include "components/mus/server_view.h"
16 namespace cc {
17 class SurfaceManager;
20 namespace mus {
21 class SurfacesScheduler;
24 namespace mus {
26 class ConnectionManager;
27 class FocusController;
28 class ViewTreeHostDelegate;
29 class ViewTreeImpl;
31 // ViewTreeHostImpl is an implementation of the ViewTreeHost interface.
32 // It serves as a top level root view for a window. Its lifetime is managed by
33 // ConnectionManager. If the connection to the client breaks or if the user
34 // closes the associated window, then this object and related state will be
35 // deleted.
36 class ViewTreeHostImpl : public DisplayManagerDelegate,
37 public mojo::ViewTreeHost,
38 public FocusControllerDelegate {
39 public:
40 // TODO(fsamuel): All these parameters are just plumbing for creating
41 // DisplayManagers. We should probably just store these common parameters
42 // in the DisplayManagerFactory and pass them along on DisplayManager::Create.
43 ViewTreeHostImpl(mojo::ViewTreeHostClientPtr client,
44 ConnectionManager* connection_manager,
45 bool is_headless,
46 mojo::ApplicationImpl* app_impl,
47 const scoped_refptr<GpuState>& gpu_state,
48 const scoped_refptr<SurfacesState>& surfaces_state);
49 ~ViewTreeHostImpl() override;
51 // Initializes state that depends on the existence of a ViewTreeHostImpl.
52 void Init(ViewTreeHostDelegate* delegate);
54 ViewTreeImpl* GetViewTree();
56 mojo::ViewTreeHostClient* client() const { return client_.get(); }
58 // Returns whether |view| is a descendant of this root but not itself a
59 // root view.
60 bool IsViewAttachedToRoot(const ServerView* view) const;
62 // Schedules a paint for the specified region in the coordinates of |view| if
63 // the |view| is in this viewport. Returns whether |view| is in the viewport.
64 bool SchedulePaintIfInViewport(const ServerView* view,
65 const gfx::Rect& bounds);
67 // Returns the metrics for this viewport.
68 const mojo::ViewportMetrics& GetViewportMetrics() const;
70 ConnectionManager* connection_manager() { return connection_manager_; }
72 // Returns the root ServerView of this viewport.
73 ServerView* root_view() { return root_.get(); }
74 const ServerView* root_view() const { return root_.get(); }
76 void SetFocusedView(ServerView* view);
77 ServerView* GetFocusedView();
78 void DestroyFocusController();
80 void UpdateTextInputState(ServerView* view, const ui::TextInputState& state);
81 void SetImeVisibility(ServerView* view, bool visible);
83 void OnAccelerator(uint32_t accelerator_id, mojo::EventPtr event);
84 void DispatchInputEventToView(const ServerView* target, mojo::EventPtr event);
86 // ViewTreeHost:
87 void SetSize(mojo::SizePtr size) override;
88 void SetTitle(const mojo::String& title) override;
89 void AddAccelerator(uint32_t id,
90 mojo::KeyboardCode keyboard_code,
91 mojo::EventFlags flags) override;
92 void RemoveAccelerator(uint32_t id) override;
94 private:
95 void OnClientClosed();
97 // DisplayManagerDelegate:
98 ServerView* GetRootView() override;
99 void OnEvent(ViewId id, mojo::EventPtr event) override;
100 void OnDisplayClosed() override;
101 void OnViewportMetricsChanged(
102 const mojo::ViewportMetrics& old_metrics,
103 const mojo::ViewportMetrics& new_metrics) override;
105 // FocusControllerDelegate:
106 void OnFocusChanged(ServerView* old_focused_view,
107 ServerView* new_focused_view) override;
109 ViewTreeHostDelegate* delegate_;
110 ConnectionManager* const connection_manager_;
111 mojo::ViewTreeHostClientPtr client_;
112 EventDispatcher event_dispatcher_;
113 scoped_ptr<ServerView> root_;
114 scoped_ptr<DisplayManager> display_manager_;
115 scoped_ptr<FocusController> focus_controller_;
117 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostImpl);
120 } // namespace mus
122 #endif // COMPONENTS_MUS_VIEW_TREE_HOST_IMPL_H_