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> |
(...skipping 23 matching lines...) Expand all Loading... |
34 // . Creates and owns a WindowTreeClient. | 34 // . Creates and owns a WindowTreeClient. |
35 // . Registers itself as the factory for creating NativeWidgets so that a | 35 // . Registers itself as the factory for creating NativeWidgets so that a |
36 // NativeWidgetMus is created. | 36 // NativeWidgetMus is created. |
37 // WindowManagerConnection is a singleton and should be created early on. | 37 // WindowManagerConnection is a singleton and should be created early on. |
38 // | 38 // |
39 // TODO(sky): this name is now totally confusing. Come up with a better one. | 39 // TODO(sky): this name is now totally confusing. Come up with a better one. |
40 class VIEWS_MUS_EXPORT WindowManagerConnection | 40 class VIEWS_MUS_EXPORT WindowManagerConnection |
41 : public NON_EXPORTED_BASE(mus::WindowTreeClientDelegate), | 41 : public NON_EXPORTED_BASE(mus::WindowTreeClientDelegate), |
42 public ScreenMusDelegate { | 42 public ScreenMusDelegate { |
43 public: | 43 public: |
44 static void Create(shell::Connector* connector, | 44 static std::unique_ptr<WindowManagerConnection> Create( |
45 const shell::Identity& identity); | 45 shell::Connector* connector, |
| 46 const shell::Identity& identity); |
46 static WindowManagerConnection* Get(); | 47 static WindowManagerConnection* Get(); |
47 static bool Exists(); | 48 static bool Exists(); |
48 | 49 |
49 // Destroys the singleton instance. | 50 ~WindowManagerConnection() override; |
50 static void Reset(); | |
51 | 51 |
52 shell::Connector* connector() { return connector_; } | 52 shell::Connector* connector() { return connector_; } |
53 | 53 |
54 mus::Window* NewWindow(const std::map<std::string, | 54 mus::Window* NewWindow(const std::map<std::string, |
55 std::vector<uint8_t>>& properties); | 55 std::vector<uint8_t>>& properties); |
56 | 56 |
57 NativeWidget* CreateNativeWidgetMus( | 57 NativeWidget* CreateNativeWidgetMus( |
58 const std::map<std::string, std::vector<uint8_t>>& properties, | 58 const std::map<std::string, std::vector<uint8_t>>& properties, |
59 const Widget::InitParams& init_params, | 59 const Widget::InitParams& init_params, |
60 internal::NativeWidgetDelegate* delegate); | 60 internal::NativeWidgetDelegate* delegate); |
61 | 61 |
62 void AddPointerWatcher(PointerWatcher* watcher); | 62 void AddPointerWatcher(PointerWatcher* watcher); |
63 void RemovePointerWatcher(PointerWatcher* watcher); | 63 void RemovePointerWatcher(PointerWatcher* watcher); |
64 | 64 |
65 private: | 65 private: |
66 friend class WindowManagerConnectionTest; | 66 friend class WindowManagerConnectionTest; |
67 | 67 |
68 WindowManagerConnection(shell::Connector* connector, | 68 WindowManagerConnection(shell::Connector* connector, |
69 const shell::Identity& identity); | 69 const shell::Identity& identity); |
70 ~WindowManagerConnection() override; | |
71 | 70 |
72 // Returns true if there is one or more pointer watchers for this client. | 71 // Returns true if there is one or more pointer watchers for this client. |
73 bool HasPointerWatcher(); | 72 bool HasPointerWatcher(); |
74 | 73 |
75 // mus::WindowTreeClientDelegate: | 74 // mus::WindowTreeClientDelegate: |
76 void OnEmbed(mus::Window* root) override; | 75 void OnEmbed(mus::Window* root) override; |
77 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override; | 76 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override; |
78 void OnEventObserved(const ui::Event& event, mus::Window* target) override; | 77 void OnEventObserved(const ui::Event& event, mus::Window* target) override; |
79 | 78 |
80 // ScreenMusDelegate: | 79 // ScreenMusDelegate: |
81 void OnWindowManagerFrameValuesChanged() override; | 80 void OnWindowManagerFrameValuesChanged() override; |
82 gfx::Point GetCursorScreenPoint() override; | 81 gfx::Point GetCursorScreenPoint() override; |
83 | 82 |
84 shell::Connector* connector_; | 83 shell::Connector* connector_; |
85 shell::Identity identity_; | 84 shell::Identity identity_; |
86 std::unique_ptr<ScreenMus> screen_; | 85 std::unique_ptr<ScreenMus> screen_; |
87 std::unique_ptr<mus::WindowTreeClient> client_; | 86 std::unique_ptr<mus::WindowTreeClient> client_; |
88 // Must be empty on destruction. | 87 // Must be empty on destruction. |
89 base::ObserverList<PointerWatcher, true> pointer_watchers_; | 88 base::ObserverList<PointerWatcher, true> pointer_watchers_; |
90 bool created_device_data_manager_; | 89 bool created_device_data_manager_; |
91 | 90 |
92 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); | 91 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); |
93 }; | 92 }; |
94 | 93 |
95 } // namespace views | 94 } // namespace views |
96 | 95 |
97 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | 96 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
OLD | NEW |