OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 #include "services/ui/demo/mus_demo_external.h" |
| 6 |
| 7 #include "services/service_manager/public/cpp/service_context.h" |
| 8 #include "services/ui/public/interfaces/constants.mojom.h" |
| 9 #include "ui/aura/mus/window_tree_client.h" |
| 10 #include "ui/aura/mus/window_tree_host_mus.h" |
| 11 |
| 12 namespace ui { |
| 13 namespace demo { |
| 14 |
| 15 // Size of square in pixels to draw. |
| 16 const int kSquareSize = 500; |
| 17 |
| 18 MusDemoExternal::MusDemoExternal() {} |
| 19 |
| 20 void MusDemoExternal::OnStartImpl() { |
| 21 context()->connector()->BindInterface(ui::mojom::kServiceName, |
| 22 &window_tree_host_factory_); |
| 23 mojom::WindowTreeClientPtr tree_client; |
| 24 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( |
| 25 context()->connector(), this, nullptr, MakeRequest(&tree_client)); |
| 26 window_tree_data_ = base::MakeUnique<WindowTreeData>( |
| 27 window_tree_host_factory_.get(), std::move(tree_client), kSquareSize); |
| 28 // TODO(tonikitoo,fwang): Open two external windows with different square |
| 29 // sizes. |
| 30 } |
| 31 |
| 32 void MusDemoExternal::OnEmbed( |
| 33 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 34 DCHECK(window_tree_data_); |
| 35 window_tree_data_->Init(std::move(window_tree_host)); |
| 36 } |
| 37 |
| 38 void MusDemoExternal::OnEmbedRootDestroyed( |
| 39 aura::WindowTreeHostMus* window_tree_host) { |
| 40 window_tree_data_.reset(); |
| 41 } |
| 42 |
| 43 } // namespace demo |
| 44 } // namespace aura |
OLD | NEW |