Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / view_manager / view_tree_host_impl.h
blob7c113f5927fcb05728f49533eecdeddfa9a5ef8e
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_VIEW_MANAGER_VIEW_TREE_HOST_IMPL_H_
6 #define COMPONENTS_VIEW_MANAGER_VIEW_TREE_HOST_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/view_manager/display_manager.h"
10 #include "components/view_manager/public/cpp/types.h"
11 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h"
12 #include "components/view_manager/server_view.h"
14 namespace cc {
15 class SurfaceManager;
18 namespace surfaces {
19 class SurfacesScheduler;
22 namespace view_manager {
24 class ConnectionManager;
25 class ViewTreeHostDelegate;
26 class ViewTreeImpl;
28 // ViewTreeHostImpl is an implementation of the ViewTreeHost interface.
29 // It serves as a top level root view for a window. Its lifetime is managed by
30 // ConnectionManager. If the connection to the client breaks or if the user
31 // closes the associated window, then this object and related state will be
32 // deleted.
33 class ViewTreeHostImpl : public DisplayManagerDelegate,
34 public mojo::ViewTreeHost {
35 public:
36 // TODO(fsamuel): All these parameters are just plumbing for creating
37 // DisplayManagers. We should probably just store these common parameters
38 // in the DisplayManagerFactory and pass them along on DisplayManager::Create.
39 ViewTreeHostImpl(
40 mojo::ViewTreeHostClientPtr client,
41 ConnectionManager* connection_manager,
42 bool is_headless,
43 mojo::ApplicationImpl* app_impl,
44 const scoped_refptr<gles2::GpuState>& gpu_state,
45 const scoped_refptr<surfaces::SurfacesState>& surfaces_state);
46 ~ViewTreeHostImpl() override;
48 // Initializes state that depends on the existence of a ViewTreeHostImpl.
49 void Init(ViewTreeHostDelegate* delegate);
51 ViewTreeImpl* GetViewTree();
53 mojo::ViewTreeHostClient* client() const { return client_.get(); }
55 // Returns whether |view| is a descendant of this root but not itself a
56 // root view.
57 bool IsViewAttachedToRoot(const ServerView* view) const;
59 // Schedules a paint for the specified region in the coordinates of |view| if
60 // the |view| is in this viewport. Returns whether |view| is in the viewport.
61 bool SchedulePaintIfInViewport(const ServerView* view,
62 const gfx::Rect& bounds);
64 // Returns the metrics for this viewport.
65 const mojo::ViewportMetrics& GetViewportMetrics() const;
67 ConnectionManager* connection_manager() { return connection_manager_; }
69 // Returns the root ServerView of this viewport.
70 ServerView* root_view() { return root_.get(); }
72 void UpdateTextInputState(const ui::TextInputState& state);
73 void SetImeVisibility(bool visible);
75 // ViewTreeHost:
76 void SetSize(mojo::SizePtr size) override;
77 void AddAccelerator(uint32_t id,
78 mojo::KeyboardCode keyboard_code,
79 mojo::EventFlags flags) override;
80 void RemoveAccelerator(uint32_t id) override;
82 private:
83 // DisplayManagerDelegate:
84 ServerView* GetRootView() override;
85 void OnEvent(mojo::EventPtr event) override;
86 void OnDisplayClosed() override;
87 void OnViewportMetricsChanged(
88 const mojo::ViewportMetrics& old_metrics,
89 const mojo::ViewportMetrics& new_metrics) override;
91 ViewTreeHostDelegate* delegate_;
92 ConnectionManager* const connection_manager_;
93 mojo::ViewTreeHostClientPtr client_;
94 scoped_ptr<ServerView> root_;
95 scoped_ptr<DisplayManager> display_manager_;
97 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostImpl);
100 } // namespace view_manager
102 #endif // COMPONENTS_VIEW_MANAGER_VIEW_TREE_HOST_IMPL_H_