Chromium Code Reviews| 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/demo/window_tree_data.h" | |
| 9 #include "services/ui/public/interfaces/constants.mojom.h" | |
| 10 #include "services/ui/public/interfaces/window_tree_host.mojom.h" | |
| 11 #include "ui/aura/mus/window_tree_client.h" | |
| 12 #include "ui/aura/mus/window_tree_host_mus.h" | |
| 13 #include "ui/display/display.h" | |
| 14 | |
| 15 namespace ui { | |
| 16 namespace demo { | |
| 17 | |
| 18 class WindowTreeDataExternal : public WindowTreeData { | |
|
kylechar
2017/02/21 18:51:08
WindowTreeDataExternal + kSquareSize should be in
fwang
2017/02/21 19:02:21
Done.
| |
| 19 public: | |
| 20 // Creates a new window tree host associated to the WindowTreeData. | |
| 21 WindowTreeDataExternal(mojom::WindowTreeHostFactory* factory, | |
| 22 mojom::WindowTreeClientPtr tree_client, | |
| 23 int square_size) | |
| 24 : WindowTreeData(square_size) { | |
| 25 factory->CreateWindowTreeHost(MakeRequest(&host_), std::move(tree_client)); | |
| 26 } | |
| 27 | |
| 28 // Holds the Mojo pointer to the window tree host. | |
| 29 mojom::WindowTreeHostPtr host_; | |
|
fwang
2017/02/21 17:44:17
Oops, missing private here :-( Will take care of i
fwang
2017/02/21 19:02:21
Done.
| |
| 30 }; | |
| 31 | |
| 32 // Size of square in pixels to draw. | |
| 33 const int kSquareSize = 500; | |
| 34 | |
| 35 MusDemoExternal::MusDemoExternal() {} | |
| 36 | |
| 37 MusDemoExternal::~MusDemoExternal() {} | |
| 38 | |
| 39 void MusDemoExternal::OnStartImpl( | |
| 40 std::unique_ptr<aura::WindowTreeClient>* window_tree_client, | |
| 41 std::unique_ptr<WindowTreeData>* window_tree_data) { | |
| 42 context()->connector()->BindInterface(ui::mojom::kServiceName, | |
| 43 &window_tree_host_factory_); | |
| 44 mojom::WindowTreeClientPtr tree_client; | |
| 45 window_tree_client->reset(new aura::WindowTreeClient( | |
|
kylechar
2017/02/21 18:51:08
Do something like the following for these?
*windo
fwang
2017/02/21 19:02:21
Mmh, not sure what it did not work when I initiall
| |
| 46 context()->connector(), this, nullptr, MakeRequest(&tree_client))); | |
| 47 // TODO(tonikitoo,fwang): Open two external windows with different square | |
| 48 // sizes. | |
| 49 window_tree_data->reset(new WindowTreeDataExternal( | |
| 50 window_tree_host_factory_.get(), std::move(tree_client), kSquareSize)); | |
| 51 | |
| 52 // TODO(tonikitoo,fwang): Implement management of displays in external mode. | |
| 53 // For now, a fake display is created in order to work around an assertion in | |
| 54 // aura::GetDeviceScaleFactorFromDisplay(). | |
| 55 fake_display_ = base::MakeUnique<display::Display>(0); | |
|
kylechar
2017/02/21 18:51:08
|fake_display_| doesn't need to be a member variab
fwang
2017/02/21 19:02:21
Done.
| |
| 56 AddPrimaryDisplay(*fake_display_); | |
| 57 } | |
| 58 | |
| 59 void MusDemoExternal::OnEmbed( | |
| 60 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | |
| 61 InitWindowTreeData(std::move(window_tree_host)); | |
| 62 } | |
| 63 | |
| 64 void MusDemoExternal::OnEmbedRootDestroyed( | |
| 65 aura::WindowTreeHostMus* window_tree_host) { | |
| 66 CleanupWindowTreeData(); | |
| 67 } | |
| 68 | |
| 69 } // namespace demo | |
| 70 } // namespace ui | |
| OLD | NEW |