| 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 #include <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "mojo/public/cpp/bindings/binding.h" | 8 #include "mojo/public/cpp/bindings/binding.h" |
| 9 #include "services/service_manager/public/c/main.h" | 9 #include "services/service_manager/public/c/main.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| 11 #include "services/service_manager/public/cpp/service.h" | 11 #include "services/service_manager/public/cpp/service.h" |
| 12 #include "services/service_manager/public/cpp/service_context.h" | 12 #include "services/service_manager/public/cpp/service_context.h" |
| 13 #include "services/service_manager/public/cpp/service_runner.h" | 13 #include "services/service_manager/public/cpp/service_runner.h" |
| 14 #include "services/ui/public/cpp/window.h" | 14 #include "services/ui/public/cpp/window.h" |
| 15 #include "services/ui/public/cpp/window_manager_delegate.h" | 15 #include "services/ui/public/cpp/window_manager_delegate.h" |
| 16 #include "services/ui/public/cpp/window_tree_client.h" | 16 #include "services/ui/public/cpp/window_tree_client.h" |
| 17 #include "services/ui/public/cpp/window_tree_client_delegate.h" | 17 #include "services/ui/public/cpp/window_tree_client_delegate.h" |
| 18 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
| 19 #include "ui/display/test/test_screen.h" |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 namespace test { | 22 namespace test { |
| 22 | 23 |
| 23 class TestWM : public service_manager::Service, | 24 class TestWM : public service_manager::Service, |
| 24 public ui::WindowTreeClientDelegate, | 25 public ui::WindowTreeClientDelegate, |
| 25 public ui::WindowManagerDelegate { | 26 public ui::WindowManagerDelegate { |
| 26 public: | 27 public: |
| 27 TestWM() {} | 28 TestWM() {} |
| 28 ~TestWM() override {} | 29 ~TestWM() override { display::Screen::SetScreenInstance(nullptr); } |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 // service_manager::Service: | 32 // service_manager::Service: |
| 32 void OnStart() override { | 33 void OnStart() override { |
| 34 test_screen_ = base::MakeUnique<display::test::TestScreen>(); |
| 35 display::Screen::SetScreenInstance(test_screen_.get()); |
| 33 window_tree_client_.reset(new ui::WindowTreeClient(this, this)); | 36 window_tree_client_.reset(new ui::WindowTreeClient(this, this)); |
| 34 window_tree_client_->ConnectAsWindowManager(context()->connector()); | 37 window_tree_client_->ConnectAsWindowManager(context()->connector()); |
| 35 } | 38 } |
| 36 | 39 |
| 37 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 40 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
| 38 service_manager::InterfaceRegistry* registry) override { | 41 service_manager::InterfaceRegistry* registry) override { |
| 39 return false; | 42 return false; |
| 40 } | 43 } |
| 41 | 44 |
| 42 // ui::WindowTreeClientDelegate: | 45 // ui::WindowTreeClientDelegate: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void OnWmDisplayRemoved(ui::Window* window) override { window->Destroy(); } | 101 void OnWmDisplayRemoved(ui::Window* window) override { window->Destroy(); } |
| 99 void OnWmDisplayModified(const display::Display& display) override {} | 102 void OnWmDisplayModified(const display::Display& display) override {} |
| 100 void OnWmPerformMoveLoop(Window* window, | 103 void OnWmPerformMoveLoop(Window* window, |
| 101 mojom::MoveLoopSource source, | 104 mojom::MoveLoopSource source, |
| 102 const gfx::Point& cursor_location, | 105 const gfx::Point& cursor_location, |
| 103 const base::Callback<void(bool)>& on_done) override { | 106 const base::Callback<void(bool)>& on_done) override { |
| 104 // Don't care. | 107 // Don't care. |
| 105 } | 108 } |
| 106 void OnWmCancelMoveLoop(Window* window) override {} | 109 void OnWmCancelMoveLoop(Window* window) override {} |
| 107 | 110 |
| 111 // Dummy screen required to be the screen instance. |
| 112 std::unique_ptr<display::test::TestScreen> test_screen_; |
| 113 |
| 108 ui::Window* root_ = nullptr; | 114 ui::Window* root_ = nullptr; |
| 109 ui::WindowManagerClient* window_manager_client_ = nullptr; | 115 ui::WindowManagerClient* window_manager_client_ = nullptr; |
| 110 std::unique_ptr<ui::WindowTreeClient> window_tree_client_; | 116 std::unique_ptr<ui::WindowTreeClient> window_tree_client_; |
| 111 | 117 |
| 112 DISALLOW_COPY_AND_ASSIGN(TestWM); | 118 DISALLOW_COPY_AND_ASSIGN(TestWM); |
| 113 }; | 119 }; |
| 114 | 120 |
| 115 } // namespace test | 121 } // namespace test |
| 116 } // namespace ui | 122 } // namespace ui |
| 117 | 123 |
| 118 MojoResult ServiceMain(MojoHandle service_request_handle) { | 124 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 119 service_manager::ServiceRunner runner(new ui::test::TestWM); | 125 service_manager::ServiceRunner runner(new ui::test::TestWM); |
| 120 return runner.Run(service_request_handle); | 126 return runner.Run(service_request_handle); |
| 121 } | 127 } |
| OLD | NEW |