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