OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 UI_VIEWS_MUS_MUS_CLIENT_H_ | 5 #ifndef UI_VIEWS_MUS_MUS_CLIENT_H_ |
6 #define UI_VIEWS_MUS_MUS_CLIENT_H_ | 6 #define UI_VIEWS_MUS_MUS_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 namespace internal { | 51 namespace internal { |
52 class NativeWidgetDelegate; | 52 class NativeWidgetDelegate; |
53 } | 53 } |
54 | 54 |
55 namespace test { | 55 namespace test { |
56 class MusClientTestApi; | 56 class MusClientTestApi; |
57 } | 57 } |
58 | 58 |
59 // MusClient establishes a connection to mus and sets up necessary state so that | 59 // MusClient establishes a connection to mus and sets up necessary state so that |
60 // aura and views target mus. This class is useful for typical clients, not the | 60 // aura and views target mus. This class is useful for typical clients, not the |
61 // WindowManager. Most clients don't create this directly, rather use | 61 // WindowManager. This class is created by AuraInit when |
62 // AuraInit. | 62 // AuraInit::Mode::AURA_MUS is passed as the mode. |
| 63 // AuraInit::Mode::AURA to AuraInit and MusClient will be created for us. |
63 class VIEWS_MUS_EXPORT MusClient | 64 class VIEWS_MUS_EXPORT MusClient |
64 : public aura::WindowTreeClientDelegate, | 65 : public aura::WindowTreeClientDelegate, |
65 public ScreenMusDelegate, | 66 public ScreenMusDelegate, |
66 public ui::OSExchangeDataProviderFactory::Factory { | 67 public ui::OSExchangeDataProviderFactory::Factory { |
67 public: | 68 public: |
68 // Most clients should use AuraInit, which creates a MusClient. | |
69 // |create_wm_state| indicates whether MusClient should create a wm::WMState. | |
70 MusClient( | |
71 service_manager::Connector* connector, | |
72 const service_manager::Identity& identity, | |
73 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr, | |
74 bool create_wm_state = true); | |
75 ~MusClient() override; | 69 ~MusClient() override; |
76 | 70 |
77 static MusClient* Get() { return instance_; } | 71 static MusClient* Get() { return instance_; } |
78 static bool Exists() { return instance_ != nullptr; } | |
79 | 72 |
80 // Returns true if a DesktopNativeWidgetAura should be created given the | 73 // Returns true if a DesktopNativeWidgetAura should be created given the |
81 // specified params. If this returns false a NativeWidgetAura should be | 74 // specified params. If this returns false a NativeWidgetAura should be |
82 // created. | 75 // created. |
83 static bool ShouldCreateDesktopNativeWidgetAura( | 76 static bool ShouldCreateDesktopNativeWidgetAura( |
84 const Widget::InitParams& init_params); | 77 const Widget::InitParams& init_params); |
85 | 78 |
86 // Returns the properties to supply to mus when creating a window. | 79 // Returns the properties to supply to mus when creating a window. |
87 static std::map<std::string, std::vector<uint8_t>> | 80 static std::map<std::string, std::vector<uint8_t>> |
88 ConfigurePropertiesFromParams(const Widget::InitParams& init_params); | 81 ConfigurePropertiesFromParams(const Widget::InitParams& init_params); |
89 | 82 |
90 aura::WindowTreeClient* window_tree_client() { | 83 aura::WindowTreeClient* window_tree_client() { |
91 return window_tree_client_.get(); | 84 return window_tree_client_.get(); |
92 } | 85 } |
93 | 86 |
94 PointerWatcherEventRouter2* pointer_watcher_event_router() { | 87 PointerWatcherEventRouter2* pointer_watcher_event_router() { |
95 return pointer_watcher_event_router_.get(); | 88 return pointer_watcher_event_router_.get(); |
96 } | 89 } |
97 | 90 |
98 ui::Gpu* gpu() { return gpu_.get(); } | |
99 | |
100 // Creates DesktopNativeWidgetAura with DesktopWindowTreeHostMus. This is | 91 // Creates DesktopNativeWidgetAura with DesktopWindowTreeHostMus. This is |
101 // set as the factory function used for creating NativeWidgets when a | 92 // set as the factory function used for creating NativeWidgets when a |
102 // NativeWidget has not been explicitly set. | 93 // NativeWidget has not been explicitly set. |
103 NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params, | 94 NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params, |
104 internal::NativeWidgetDelegate* delegate); | 95 internal::NativeWidgetDelegate* delegate); |
105 | 96 |
106 void AddObserver(MusClientObserver* observer); | 97 void AddObserver(MusClientObserver* observer); |
107 void RemoveObserver(MusClientObserver* observer); | 98 void RemoveObserver(MusClientObserver* observer); |
108 | 99 |
109 private: | 100 private: |
110 friend class AuraInit; | 101 friend class AuraInit; |
111 friend class test::MusClientTestApi; | 102 friend class test::MusClientTestApi; |
112 | 103 |
| 104 MusClient( |
| 105 service_manager::Connector* connector, |
| 106 const service_manager::Identity& identity, |
| 107 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr); |
| 108 |
113 // aura::WindowTreeClientDelegate: | 109 // aura::WindowTreeClientDelegate: |
114 void OnEmbed( | 110 void OnEmbed( |
115 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; | 111 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; |
116 void OnLostConnection(aura::WindowTreeClient* client) override; | 112 void OnLostConnection(aura::WindowTreeClient* client) override; |
117 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; | 113 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; |
118 void OnPointerEventObserved(const ui::PointerEvent& event, | 114 void OnPointerEventObserved(const ui::PointerEvent& event, |
119 aura::Window* target) override; | 115 aura::Window* target) override; |
120 aura::client::CaptureClient* GetCaptureClient() override; | 116 aura::client::CaptureClient* GetCaptureClient() override; |
121 aura::PropertyConverter* GetPropertyConverter() override; | 117 aura::PropertyConverter* GetPropertyConverter() override; |
122 | 118 |
123 // ScreenMusDelegate: | 119 // ScreenMusDelegate: |
124 void OnWindowManagerFrameValuesChanged() override; | 120 void OnWindowManagerFrameValuesChanged() override; |
125 gfx::Point GetCursorScreenPoint() override; | 121 gfx::Point GetCursorScreenPoint() override; |
126 aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) override; | 122 aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) override; |
127 | 123 |
128 // ui:OSExchangeDataProviderFactory::Factory: | 124 // ui:OSExchangeDataProviderFactory::Factory: |
129 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override; | 125 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override; |
130 | 126 |
131 static MusClient* instance_; | 127 static MusClient* instance_; |
132 | 128 |
133 service_manager::Identity identity_; | 129 service_manager::Identity identity_; |
134 | 130 |
135 base::ObserverList<MusClientObserver> observer_list_; | 131 base::ObserverList<MusClientObserver> observer_list_; |
136 | 132 |
137 // NOTE: this may be null (creation is based on argument supplied to | |
138 // constructor). | |
139 std::unique_ptr<wm::WMState> wm_state_; | 133 std::unique_ptr<wm::WMState> wm_state_; |
140 | 134 |
141 std::unique_ptr<ScreenMus> screen_; | 135 std::unique_ptr<ScreenMus> screen_; |
142 | 136 |
143 std::unique_ptr<aura::PropertyConverter> property_converter_; | 137 std::unique_ptr<aura::PropertyConverter> property_converter_; |
144 | 138 |
145 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; | 139 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; |
146 | 140 |
147 std::unique_ptr<ui::Gpu> gpu_; | 141 std::unique_ptr<ui::Gpu> gpu_; |
148 | 142 |
149 std::unique_ptr<PointerWatcherEventRouter2> pointer_watcher_event_router_; | 143 std::unique_ptr<PointerWatcherEventRouter2> pointer_watcher_event_router_; |
150 | 144 |
151 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; | 145 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; |
152 | 146 |
153 DISALLOW_COPY_AND_ASSIGN(MusClient); | 147 DISALLOW_COPY_AND_ASSIGN(MusClient); |
154 }; | 148 }; |
155 | 149 |
156 } // namespace views | 150 } // namespace views |
157 | 151 |
158 #endif // UI_VIEWS_MUS_MUS_CLIENT_H_ | 152 #endif // UI_VIEWS_MUS_MUS_CLIENT_H_ |
OLD | NEW |