| 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 <utility> | 6 #include <utility> |
| 6 | 7 |
| 7 #include "mojo/public/cpp/bindings/binding.h" | 8 #include "mojo/public/cpp/bindings/binding.h" |
| 8 #include "services/shell/public/c/main.h" | 9 #include "services/shell/public/c/main.h" |
| 9 #include "services/shell/public/cpp/connector.h" | 10 #include "services/shell/public/cpp/connector.h" |
| 10 #include "services/shell/public/cpp/service.h" | 11 #include "services/shell/public/cpp/service.h" |
| 11 #include "services/shell/public/cpp/service_runner.h" | 12 #include "services/shell/public/cpp/service_runner.h" |
| 12 #include "services/ui/public/cpp/window.h" | 13 #include "services/ui/public/cpp/window.h" |
| 13 #include "services/ui/public/cpp/window_manager_delegate.h" | 14 #include "services/ui/public/cpp/window_manager_delegate.h" |
| 14 #include "services/ui/public/cpp/window_tree_client.h" | 15 #include "services/ui/public/cpp/window_tree_client.h" |
| 15 #include "services/ui/public/cpp/window_tree_client_delegate.h" | 16 #include "services/ui/public/cpp/window_tree_client_delegate.h" |
| 16 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 namespace test { | 20 namespace test { |
| 20 | 21 |
| 21 class TestWM : public shell::Service, | 22 class TestWM : public shell::Service, |
| 22 public ui::WindowTreeClientDelegate, | 23 public ui::WindowTreeClientDelegate, |
| 23 public ui::WindowManagerDelegate { | 24 public ui::WindowManagerDelegate { |
| 24 public: | 25 public: |
| 25 TestWM() {} | 26 TestWM() {} |
| 26 ~TestWM() override { delete window_tree_client_; } | 27 ~TestWM() override {} |
| 27 | 28 |
| 28 private: | 29 private: |
| 29 // shell::Service: | 30 // shell::Service: |
| 30 void OnStart(const shell::Identity& identity) override { | 31 void OnStart(const shell::Identity& identity) override { |
| 31 window_tree_client_ = new ui::WindowTreeClient(this, this, nullptr); | 32 window_tree_client_.reset(new ui::WindowTreeClient(this, this)); |
| 32 window_tree_client_->ConnectAsWindowManager(connector()); | 33 window_tree_client_->ConnectAsWindowManager(connector()); |
| 33 } | 34 } |
| 34 | 35 |
| 35 // ui::WindowTreeClientDelegate: | 36 // ui::WindowTreeClientDelegate: |
| 36 void OnEmbed(ui::Window* root) override { | 37 void OnEmbed(ui::Window* root) override { |
| 37 // WindowTreeClients configured as the window manager should never get | 38 // WindowTreeClients configured as the window manager should never get |
| 38 // OnEmbed(). | 39 // OnEmbed(). |
| 39 NOTREACHED(); | 40 NOTREACHED(); |
| 40 } | 41 } |
| 41 void OnDidDestroyClient(ui::WindowTreeClient* client) override { | 42 void OnLostConnection(WindowTreeClient* client) override { |
| 42 window_tree_client_ = nullptr; | 43 window_tree_client_.reset(); |
| 44 } |
| 45 void OnEmbedRootDestroyed(ui::Window* root) override { |
| 46 // WindowTreeClients configured as the window manager should never get |
| 47 // OnEmbedRootDestroyed(). |
| 48 NOTREACHED(); |
| 43 } | 49 } |
| 44 void OnPointerEventObserved(const ui::PointerEvent& event, | 50 void OnPointerEventObserved(const ui::PointerEvent& event, |
| 45 ui::Window* target) override { | 51 ui::Window* target) override { |
| 46 // Don't care. | 52 // Don't care. |
| 47 } | 53 } |
| 48 | 54 |
| 49 // ui::WindowManagerDelegate: | 55 // ui::WindowManagerDelegate: |
| 50 void SetWindowManagerClient(ui::WindowManagerClient* client) override { | 56 void SetWindowManagerClient(ui::WindowManagerClient* client) override { |
| 51 window_manager_client_ = client; | 57 window_manager_client_ = client; |
| 52 } | 58 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void OnWmPerformMoveLoop(Window* window, | 92 void OnWmPerformMoveLoop(Window* window, |
| 87 mojom::MoveLoopSource source, | 93 mojom::MoveLoopSource source, |
| 88 const gfx::Point& cursor_location, | 94 const gfx::Point& cursor_location, |
| 89 const base::Callback<void(bool)>& on_done) override { | 95 const base::Callback<void(bool)>& on_done) override { |
| 90 // Don't care. | 96 // Don't care. |
| 91 } | 97 } |
| 92 void OnWmCancelMoveLoop(Window* window) override {} | 98 void OnWmCancelMoveLoop(Window* window) override {} |
| 93 | 99 |
| 94 ui::Window* root_ = nullptr; | 100 ui::Window* root_ = nullptr; |
| 95 ui::WindowManagerClient* window_manager_client_ = nullptr; | 101 ui::WindowManagerClient* window_manager_client_ = nullptr; |
| 96 // See WindowTreeClient for details on ownership. | 102 std::unique_ptr<ui::WindowTreeClient> window_tree_client_; |
| 97 ui::WindowTreeClient* window_tree_client_ = nullptr; | |
| 98 | 103 |
| 99 DISALLOW_COPY_AND_ASSIGN(TestWM); | 104 DISALLOW_COPY_AND_ASSIGN(TestWM); |
| 100 }; | 105 }; |
| 101 | 106 |
| 102 } // namespace test | 107 } // namespace test |
| 103 } // namespace ui | 108 } // namespace ui |
| 104 | 109 |
| 105 MojoResult ServiceMain(MojoHandle service_request_handle) { | 110 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 106 shell::ServiceRunner runner(new ui::test::TestWM); | 111 shell::ServiceRunner runner(new ui::test::TestWM); |
| 107 return runner.Run(service_request_handle); | 112 return runner.Run(service_request_handle); |
| 108 } | 113 } |
| OLD | NEW |