OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_WINDOW_MANAGER_CONNECTION_H_ | 5 #ifndef UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
6 #define UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | 6 #define UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/mus/public/cpp/window_tree_delegate.h" | 13 #include "components/mus/public/cpp/window_tree_delegate.h" |
14 #include "ui/views/mus/mus_export.h" | 14 #include "ui/views/mus/mus_export.h" |
15 #include "ui/views/mus/screen_mus_delegate.h" | 15 #include "ui/views/mus/screen_mus_delegate.h" |
16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
17 | 17 |
18 namespace mojo { | 18 namespace shell { |
19 class Connector; | 19 class Connector; |
20 } | 20 } |
21 | 21 |
22 namespace views { | 22 namespace views { |
23 class NativeWidget; | 23 class NativeWidget; |
24 class ScreenMus; | 24 class ScreenMus; |
25 namespace internal { | 25 namespace internal { |
26 class NativeWidgetDelegate; | 26 class NativeWidgetDelegate; |
27 } | 27 } |
28 | 28 |
29 // Provides configuration to mus in views. This consists of the following: | 29 // Provides configuration to mus in views. This consists of the following: |
30 // . Provides a Screen implementation backed by mus. | 30 // . Provides a Screen implementation backed by mus. |
31 // . Creates and owns a WindowTreeConnection. | 31 // . Creates and owns a WindowTreeConnection. |
32 // . Registers itself as the factory for creating NativeWidgets so that a | 32 // . Registers itself as the factory for creating NativeWidgets so that a |
33 // NativeWidgetMus is created. | 33 // NativeWidgetMus is created. |
34 // WindowManagerConnection is a singleton and should be created early on. | 34 // WindowManagerConnection is a singleton and should be created early on. |
35 // | 35 // |
36 // TODO(sky): this name is now totally confusing. Come up with a better one. | 36 // TODO(sky): this name is now totally confusing. Come up with a better one. |
37 class VIEWS_MUS_EXPORT WindowManagerConnection | 37 class VIEWS_MUS_EXPORT WindowManagerConnection |
38 : public NON_EXPORTED_BASE(mus::WindowTreeDelegate), | 38 : public NON_EXPORTED_BASE(mus::WindowTreeDelegate), |
39 public ScreenMusDelegate { | 39 public ScreenMusDelegate { |
40 public: | 40 public: |
41 static void Create(mojo::Connector* connector); | 41 static void Create(shell::Connector* connector); |
42 static WindowManagerConnection* Get(); | 42 static WindowManagerConnection* Get(); |
43 static bool Exists(); | 43 static bool Exists(); |
44 | 44 |
45 // Destroys the singleton instance. | 45 // Destroys the singleton instance. |
46 static void Reset(); | 46 static void Reset(); |
47 | 47 |
48 mojo::Connector* connector() { return connector_; } | 48 shell::Connector* connector() { return connector_; } |
49 | 49 |
50 mus::Window* NewWindow(const std::map<std::string, | 50 mus::Window* NewWindow(const std::map<std::string, |
51 std::vector<uint8_t>>& properties); | 51 std::vector<uint8_t>>& properties); |
52 | 52 |
53 NativeWidget* CreateNativeWidgetMus( | 53 NativeWidget* CreateNativeWidgetMus( |
54 const std::map<std::string, std::vector<uint8_t>>& properties, | 54 const std::map<std::string, std::vector<uint8_t>>& properties, |
55 const Widget::InitParams& init_params, | 55 const Widget::InitParams& init_params, |
56 internal::NativeWidgetDelegate* delegate); | 56 internal::NativeWidgetDelegate* delegate); |
57 | 57 |
58 private: | 58 private: |
59 explicit WindowManagerConnection(mojo::Connector* connector); | 59 explicit WindowManagerConnection(shell::Connector* connector); |
60 ~WindowManagerConnection() override; | 60 ~WindowManagerConnection() override; |
61 | 61 |
62 // mus::WindowTreeDelegate: | 62 // mus::WindowTreeDelegate: |
63 void OnEmbed(mus::Window* root) override; | 63 void OnEmbed(mus::Window* root) override; |
64 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 64 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
65 | 65 |
66 // ScreenMusDelegate: | 66 // ScreenMusDelegate: |
67 void OnWindowManagerFrameValuesChanged() override; | 67 void OnWindowManagerFrameValuesChanged() override; |
68 | 68 |
69 mojo::Connector* connector_; | 69 shell::Connector* connector_; |
70 std::unique_ptr<ScreenMus> screen_; | 70 std::unique_ptr<ScreenMus> screen_; |
71 std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_; | 71 std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); | 73 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace views | 76 } // namespace views |
77 | 77 |
78 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | 78 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
OLD | NEW |