Chromium Code Reviews| 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 SERVICES_UI_DEMO_MUS_DEMO_H_ | 5 #ifndef SERVICES_UI_DEMO_MUS_DEMO_H_ |
| 6 #define SERVICES_UI_DEMO_MUS_DEMO_H_ | 6 #define SERVICES_UI_DEMO_MUS_DEMO_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <memory> | 8 #include <memory> |
| 10 #include <set> | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | 9 |
| 14 #include "base/callback.h" | 10 #include "base/callback.h" |
| 15 #include "base/macros.h" | 11 #include "base/macros.h" |
| 16 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 17 #include "services/service_manager/public/cpp/service.h" | 13 #include "services/service_manager/public/cpp/service.h" |
| 18 #include "ui/aura/mus/window_manager_delegate.h" | |
| 19 #include "ui/aura/mus/window_tree_client_delegate.h" | 14 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 20 #include "ui/display/screen_base.h" | 15 #include "ui/display/screen_base.h" |
| 21 | 16 |
| 22 namespace aura { | 17 namespace aura { |
| 23 class Env; | 18 class Env; |
| 24 class PropertyConverter; | 19 class PropertyConverter; |
| 25 | 20 |
| 26 namespace client { | 21 namespace client { |
| 27 class DefaultCaptureClient; | 22 class DefaultCaptureClient; |
| 28 } | 23 } |
| 29 } // namespace aura | 24 } // namespace aura |
| 30 | 25 |
| 31 namespace wm { | 26 namespace wm { |
| 32 class WMState; | 27 class WMState; |
| 33 } | 28 } |
| 34 | 29 |
| 35 namespace ui { | 30 namespace ui { |
| 36 namespace demo { | 31 namespace demo { |
| 37 | 32 |
| 38 class WindowTreeData; | 33 class WindowTreeData; |
| 39 | 34 |
| 40 // A simple MUS Demo service. This service connects to the service:ui, adds a | 35 // A simple MUS Demo service. This service connects to the service:ui, adds a |
| 41 // new window to the root Window, and draws a spinning square in the center of | 36 // new window to the root Window, and draws a spinning square in the center of |
| 42 // the window. Provides a simple way to demonstrate that the graphic stack works | 37 // the window. Provides a simple way to demonstrate that the graphic stack works |
| 43 // as intended. | 38 // as intended. |
| 44 class MusDemo : public service_manager::Service, | 39 class MusDemo : public service_manager::Service, |
| 45 public aura::WindowTreeClientDelegate, | 40 public aura::WindowTreeClientDelegate { |
| 46 public aura::WindowManagerDelegate { | |
| 47 public: | 41 public: |
| 48 MusDemo(); | 42 MusDemo(); |
| 49 ~MusDemo() override; | 43 ~MusDemo() override; |
| 50 | 44 |
| 45 protected: | |
| 46 void AddPrimaryDisplay(const display::Display& display); | |
| 47 void InitWindowTreeData( | |
| 48 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host); | |
| 49 void CleanupWindowTreeData(); | |
| 50 | |
| 51 private: | 51 private: |
| 52 virtual void OnStartImpl( | |
| 53 std::unique_ptr<aura::WindowTreeClient>& window_tree_client, | |
| 54 std::unique_ptr<WindowTreeData>& window_tree_data) = 0; | |
| 55 | |
| 52 // service_manager::Service: | 56 // service_manager::Service: |
| 53 void OnStart() override; | 57 void OnStart() override; |
| 54 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 58 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
| 55 service_manager::InterfaceRegistry* registry) override; | 59 service_manager::InterfaceRegistry* registry) override; |
| 56 | 60 |
| 57 // aura::WindowTreeClientDelegate: | 61 // aura::WindowTreeClientDelegate: |
| 58 void OnEmbed( | 62 void OnEmbed( |
| 59 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; | 63 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; |
| 60 void OnUnembed(aura::Window* root) override; | 64 void OnUnembed(aura::Window* root) override; |
| 61 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; | 65 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; |
| 62 void OnLostConnection(aura::WindowTreeClient* client) override; | 66 void OnLostConnection(aura::WindowTreeClient* client) override; |
| 63 void OnPointerEventObserved(const ui::PointerEvent& event, | 67 void OnPointerEventObserved(const ui::PointerEvent& event, |
| 64 aura::Window* target) override; | 68 aura::Window* target) override; |
| 65 aura::PropertyConverter* GetPropertyConverter() override; | 69 aura::PropertyConverter* GetPropertyConverter() override; |
| 66 | 70 |
| 67 // aura::WindowManagerDelegate: | |
| 68 void SetWindowManagerClient(aura::WindowManagerClient* client) override; | |
| 69 bool OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) override; | |
| 70 bool OnWmSetProperty( | |
| 71 aura::Window* window, | |
| 72 const std::string& name, | |
| 73 std::unique_ptr<std::vector<uint8_t>>* new_data) override; | |
| 74 void OnWmSetCanFocus(aura::Window* window, bool can_focus) override; | |
| 75 aura::Window* OnWmCreateTopLevelWindow( | |
| 76 ui::mojom::WindowType window_type, | |
| 77 std::map<std::string, std::vector<uint8_t>>* properties) override; | |
| 78 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows, | |
| 79 bool janky) override; | |
| 80 void OnWmWillCreateDisplay(const display::Display& display) override; | |
| 81 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, | |
| 82 const display::Display& display) override; | |
| 83 void OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) override; | |
| 84 void OnWmDisplayModified(const display::Display& display) override; | |
| 85 ui::mojom::EventResult OnAccelerator(uint32_t id, | |
| 86 const ui::Event& event) override; | |
| 87 void OnWmPerformMoveLoop(aura::Window* window, | |
| 88 ui::mojom::MoveLoopSource source, | |
| 89 const gfx::Point& cursor_location, | |
| 90 const base::Callback<void(bool)>& on_done) override; | |
| 91 void OnWmCancelMoveLoop(aura::Window* window) override; | |
| 92 void OnWmSetClientArea( | |
| 93 aura::Window* window, | |
| 94 const gfx::Insets& insets, | |
| 95 const std::vector<gfx::Rect>& additional_client_areas) override; | |
| 96 bool IsWindowActive(aura::Window* window) override; | |
| 97 void OnWmDeactivateWindow(aura::Window* window) override; | |
| 98 | |
| 99 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; | 71 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; |
| 100 std::unique_ptr<aura::Env> env_; | 72 std::unique_ptr<aura::Env> env_; |
| 101 std::unique_ptr<display::ScreenBase> screen_; | 73 std::unique_ptr<display::ScreenBase> screen_; |
| 102 | 74 |
| 103 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; | 75 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 104 std::unique_ptr<::wm::WMState> wm_state_; | 76 std::unique_ptr<::wm::WMState> wm_state_; |
| 105 std::unique_ptr<aura::PropertyConverter> property_converter_; | 77 std::unique_ptr<aura::PropertyConverter> property_converter_; |
| 106 | 78 |
| 107 std::unique_ptr<WindowTreeData> window_tree_data_; | 79 std::unique_ptr<WindowTreeData> window_tree_data_; |
| 108 | 80 |
| 109 DISALLOW_COPY_AND_ASSIGN(MusDemo); | 81 DISALLOW_COPY_AND_ASSIGN(MusDemo); |
| 110 }; | 82 }; |
| 111 | 83 |
| 112 } // namespace demo | 84 } // namespace demo |
| 113 } // namespace aura | 85 } // namespace aura |
|
kylechar
2017/02/16 16:27:38
Can you fix the end namespace comment? It's aura i
fwang
2017/02/17 06:46:33
Done.
| |
| 114 | 86 |
| 115 #endif // SERVICES_UI_DEMO_MUS_DEMO_H_ | 87 #endif // SERVICES_UI_DEMO_MUS_DEMO_H_ |
| OLD | NEW |