Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: components/mus/test_wm/test_wm.cc

Issue 2018823002: Eliminate WindowTreeConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@connection
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/mus/public/cpp/window.h" 5 #include "components/mus/public/cpp/window.h"
6 #include "components/mus/public/cpp/window_manager_delegate.h" 6 #include "components/mus/public/cpp/window_manager_delegate.h"
7 #include "components/mus/public/cpp/window_tree_connection.h" 7 #include "components/mus/public/cpp/window_tree_client.h"
8 #include "components/mus/public/cpp/window_tree_delegate.h" 8 #include "components/mus/public/cpp/window_tree_client_delegate.h"
9 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" 9 #include "components/mus/public/interfaces/window_manager_factory.mojom.h"
10 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/bindings/binding.h" 11 #include "mojo/public/cpp/bindings/binding.h"
12 #include "services/shell/public/cpp/application_runner.h" 12 #include "services/shell/public/cpp/application_runner.h"
13 #include "services/shell/public/cpp/connector.h" 13 #include "services/shell/public/cpp/connector.h"
14 #include "services/shell/public/cpp/shell_client.h" 14 #include "services/shell/public/cpp/shell_client.h"
15 #include "ui/display/display.h" 15 #include "ui/display/display.h"
16 #include "ui/display/mojo/display_type_converters.h" 16 #include "ui/display/mojo/display_type_converters.h"
17 17
18 namespace mus { 18 namespace mus {
19 namespace test { 19 namespace test {
20 20
21 class TestWM : public shell::ShellClient, 21 class TestWM : public shell::ShellClient,
22 public mus::mojom::WindowManagerFactory, 22 public mus::mojom::WindowManagerFactory,
23 public mus::WindowTreeDelegate, 23 public mus::WindowTreeClientDelegate,
24 public mus::WindowManagerDelegate { 24 public mus::WindowManagerDelegate {
25 public: 25 public:
26 TestWM() : window_manager_factory_binding_(this) {} 26 TestWM() : window_manager_factory_binding_(this) {}
27 ~TestWM() override {} 27 ~TestWM() override {}
28 28
29 private: 29 private:
30 // shell::ShellClient: 30 // shell::ShellClient:
31 void Initialize(shell::Connector* connector, 31 void Initialize(shell::Connector* connector,
32 const shell::Identity& identity, 32 const shell::Identity& identity,
33 uint32_t id) override { 33 uint32_t id) override {
34 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; 34 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service;
35 connector->ConnectToInterface("mojo:mus", &wm_factory_service); 35 connector->ConnectToInterface("mojo:mus", &wm_factory_service);
36 wm_factory_service->SetWindowManagerFactory( 36 wm_factory_service->SetWindowManagerFactory(
37 window_manager_factory_binding_.CreateInterfacePtrAndBind()); 37 window_manager_factory_binding_.CreateInterfacePtrAndBind());
38 } 38 }
39 bool AcceptConnection(shell::Connection* connection) override { 39 bool AcceptConnection(shell::Connection* connection) override {
40 return true; 40 return true;
41 } 41 }
42 42
43 // mus::mojom::WindowManagerFactory: 43 // mus::mojom::WindowManagerFactory:
44 void CreateWindowManager( 44 void CreateWindowManager(
45 mus::mojom::DisplayPtr display, 45 mus::mojom::DisplayPtr display,
46 mus::mojom::WindowTreeClientRequest request) override { 46 mus::mojom::WindowTreeClientRequest request) override {
47 mus::WindowTreeConnection::CreateForWindowManager( 47 new mus::WindowTreeClient(this, this, std::move(request));
48 this, std::move(request),
49 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, this);
50 } 48 }
51 49
52 // mus::WindowTreeDelegate: 50 // mus::WindowTreeClientDelegate:
53 void OnEmbed(mus::Window* root) override { 51 void OnEmbed(mus::Window* root) override {
54 root_ = root; 52 root_ = root;
55 window_manager_client_->AddActivationParent(root_); 53 window_manager_client_->AddActivationParent(root_);
56 mus::mojom::FrameDecorationValuesPtr frame_decoration_values = 54 mus::mojom::FrameDecorationValuesPtr frame_decoration_values =
57 mus::mojom::FrameDecorationValues::New(); 55 mus::mojom::FrameDecorationValues::New();
58 frame_decoration_values->max_title_bar_button_width = 0; 56 frame_decoration_values->max_title_bar_button_width = 0;
59 window_manager_client_->SetFrameDecorationValues( 57 window_manager_client_->SetFrameDecorationValues(
60 std::move(frame_decoration_values)); 58 std::move(frame_decoration_values));
61 } 59 }
62 void OnConnectionLost(mus::WindowTreeConnection* connection) override { 60 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override {}
63 }
64 void OnEventObserved(const ui::Event& event, mus::Window* target) override { 61 void OnEventObserved(const ui::Event& event, mus::Window* target) override {
65 // Don't care. 62 // Don't care.
66 } 63 }
67 64
68 // mus::WindowManagerDelegate: 65 // mus::WindowManagerDelegate:
69 void SetWindowManagerClient(mus::WindowManagerClient* client) override { 66 void SetWindowManagerClient(mus::WindowManagerClient* client) override {
70 window_manager_client_ = client; 67 window_manager_client_ = client;
71 } 68 }
72 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override { 69 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override {
73 return true; 70 return true;
74 } 71 }
75 bool OnWmSetProperty( 72 bool OnWmSetProperty(
76 mus::Window* window, 73 mus::Window* window,
77 const std::string& name, 74 const std::string& name,
78 std::unique_ptr<std::vector<uint8_t>>* new_data) override { 75 std::unique_ptr<std::vector<uint8_t>>* new_data) override {
79 return true; 76 return true;
80 } 77 }
81 mus::Window* OnWmCreateTopLevelWindow( 78 mus::Window* OnWmCreateTopLevelWindow(
82 std::map<std::string, std::vector<uint8_t>>* properties) override { 79 std::map<std::string, std::vector<uint8_t>>* properties) override {
83 mus::Window* window = root_->connection()->NewWindow(properties); 80 mus::Window* window = root_->window_tree()->NewWindow(properties);
84 window->SetBounds(gfx::Rect(10, 10, 500, 500)); 81 window->SetBounds(gfx::Rect(10, 10, 500, 500));
85 root_->AddChild(window); 82 root_->AddChild(window);
86 return window; 83 return window;
87 } 84 }
88 void OnWmClientJankinessChanged(const std::set<Window*>& client_windows, 85 void OnWmClientJankinessChanged(const std::set<Window*>& client_windows,
89 bool janky) override { 86 bool janky) override {
90 // Don't care. 87 // Don't care.
91 } 88 }
92 void OnAccelerator(uint32_t id, const ui::Event& event) override { 89 void OnAccelerator(uint32_t id, const ui::Event& event) override {
93 // Don't care. 90 // Don't care.
94 } 91 }
95 92
96 mojo::Binding<mus::mojom::WindowManagerFactory> 93 mojo::Binding<mus::mojom::WindowManagerFactory>
97 window_manager_factory_binding_; 94 window_manager_factory_binding_;
98 mus::Window* root_ = nullptr; 95 mus::Window* root_ = nullptr;
99 mus::WindowManagerClient* window_manager_client_ = nullptr; 96 mus::WindowManagerClient* window_manager_client_ = nullptr;
100 97
101 DISALLOW_COPY_AND_ASSIGN(TestWM); 98 DISALLOW_COPY_AND_ASSIGN(TestWM);
102 }; 99 };
103 100
104 } // namespace test 101 } // namespace test
105 } // namespace mus 102 } // namespace mus
106 103
107 MojoResult MojoMain(MojoHandle shell_handle) { 104 MojoResult MojoMain(MojoHandle shell_handle) {
108 shell::ApplicationRunner runner(new mus::test::TestWM); 105 shell::ApplicationRunner runner(new mus::test::TestWM);
109 return runner.Run(shell_handle); 106 return runner.Run(shell_handle);
110 } 107 }
OLDNEW
« no previous file with comments | « components/mus/public/cpp/window_tree_host_factory.h ('k') | components/mus/ws/window_manager_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698