| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | |
| 6 #define UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <map> | |
| 11 #include <memory> | |
| 12 #include <set> | |
| 13 #include <string> | |
| 14 #include <vector> | |
| 15 | |
| 16 #include "base/macros.h" | |
| 17 #include "services/service_manager/public/cpp/identity.h" | |
| 18 #include "services/ui/public/cpp/window_tree_client_delegate.h" | |
| 19 #include "ui/base/dragdrop/os_exchange_data_provider_factory.h" | |
| 20 #include "ui/views/mus/mus_export.h" | |
| 21 #include "ui/views/mus/screen_mus_delegate.h" | |
| 22 #include "ui/views/widget/widget.h" | |
| 23 | |
| 24 namespace service_manager { | |
| 25 class Connector; | |
| 26 } | |
| 27 | |
| 28 namespace ui { | |
| 29 class Gpu; | |
| 30 } | |
| 31 | |
| 32 namespace views { | |
| 33 class NativeWidget; | |
| 34 class PointerWatcherEventRouter; | |
| 35 class ScreenMus; | |
| 36 class SurfaceContextFactory; | |
| 37 namespace internal { | |
| 38 class NativeWidgetDelegate; | |
| 39 } | |
| 40 | |
| 41 namespace test { | |
| 42 class WindowManagerConnectionTestApi; | |
| 43 } | |
| 44 | |
| 45 // Provides configuration to mus in views. This consists of the following: | |
| 46 // . Provides a Screen implementation backed by mus. | |
| 47 // . Provides a Clipboard implementation backed by mus. | |
| 48 // . Creates and owns a WindowTreeClient. | |
| 49 // . Registers itself as the factory for creating NativeWidgets so that a | |
| 50 // NativeWidgetMus is created. | |
| 51 // WindowManagerConnection is a singleton and should be created early on. | |
| 52 // | |
| 53 // TODO(sky): this name is now totally confusing. Come up with a better one. | |
| 54 class VIEWS_MUS_EXPORT WindowManagerConnection | |
| 55 : public NON_EXPORTED_BASE(ui::WindowTreeClientDelegate), | |
| 56 public ScreenMusDelegate, | |
| 57 public ui::OSExchangeDataProviderFactory::Factory { | |
| 58 public: | |
| 59 ~WindowManagerConnection() override; | |
| 60 | |
| 61 // |io_task_runner| is used by the gpu service. If no task runner is provided, | |
| 62 // then a new thread is created and used by ui::Gpu. | |
| 63 static std::unique_ptr<WindowManagerConnection> Create( | |
| 64 service_manager::Connector* connector, | |
| 65 const service_manager::Identity& identity, | |
| 66 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr); | |
| 67 static WindowManagerConnection* Get(); | |
| 68 static bool Exists(); | |
| 69 | |
| 70 PointerWatcherEventRouter* pointer_watcher_event_router() { | |
| 71 return pointer_watcher_event_router_.get(); | |
| 72 } | |
| 73 service_manager::Connector* connector() { return connector_; } | |
| 74 ui::Gpu* gpu() { return gpu_.get(); } | |
| 75 ui::WindowTreeClient* client() { return client_.get(); } | |
| 76 | |
| 77 ui::Window* NewTopLevelWindow( | |
| 78 const std::map<std::string, std::vector<uint8_t>>& properties); | |
| 79 | |
| 80 NativeWidget* CreateNativeWidgetMus( | |
| 81 const std::map<std::string, std::vector<uint8_t>>& properties, | |
| 82 const Widget::InitParams& init_params, | |
| 83 internal::NativeWidgetDelegate* delegate); | |
| 84 | |
| 85 const std::set<ui::Window*>& GetRoots() const; | |
| 86 | |
| 87 private: | |
| 88 friend class test::WindowManagerConnectionTestApi; | |
| 89 | |
| 90 WindowManagerConnection( | |
| 91 service_manager::Connector* connector, | |
| 92 const service_manager::Identity& identity, | |
| 93 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
| 94 | |
| 95 // Exposed for tests. | |
| 96 ui::Window* GetUiWindowAtScreenPoint(const gfx::Point& point); | |
| 97 | |
| 98 // ui::WindowTreeClientDelegate: | |
| 99 void OnEmbed(ui::Window* root) override; | |
| 100 void OnLostConnection(ui::WindowTreeClient* client) override; | |
| 101 void OnEmbedRootDestroyed(ui::Window* root) override; | |
| 102 void OnPointerEventObserved(const ui::PointerEvent& event, | |
| 103 ui::Window* target) override; | |
| 104 | |
| 105 // ScreenMusDelegate: | |
| 106 void OnWindowManagerFrameValuesChanged() override; | |
| 107 gfx::Point GetCursorScreenPoint() override; | |
| 108 aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) override; | |
| 109 | |
| 110 // ui:OSExchangeDataProviderFactory::Factory: | |
| 111 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override; | |
| 112 | |
| 113 service_manager::Connector* connector_; | |
| 114 service_manager::Identity identity_; | |
| 115 std::unique_ptr<ScreenMus> screen_; | |
| 116 std::unique_ptr<ui::WindowTreeClient> client_; | |
| 117 std::unique_ptr<ui::Gpu> gpu_; | |
| 118 std::unique_ptr<PointerWatcherEventRouter> pointer_watcher_event_router_; | |
| 119 std::unique_ptr<SurfaceContextFactory> compositor_context_factory_; | |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); | |
| 122 }; | |
| 123 | |
| 124 } // namespace views | |
| 125 | |
| 126 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | |
| OLD | NEW |