Index: services/ui/demo/mus_demo_external.cc |
diff --git a/services/ui/demo/mus_demo_external.cc b/services/ui/demo/mus_demo_external.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d81fd04b4bdcf33557c23b7212e95a49386667f9 |
--- /dev/null |
+++ b/services/ui/demo/mus_demo_external.cc |
@@ -0,0 +1,70 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "services/ui/demo/mus_demo_external.h" |
+ |
+#include "services/service_manager/public/cpp/service_context.h" |
+#include "services/ui/demo/window_tree_data.h" |
+#include "services/ui/public/interfaces/constants.mojom.h" |
+#include "services/ui/public/interfaces/window_tree_host.mojom.h" |
+#include "ui/aura/mus/window_tree_client.h" |
+#include "ui/aura/mus/window_tree_host_mus.h" |
+#include "ui/display/display.h" |
+ |
+namespace ui { |
+namespace demo { |
+ |
+class WindowTreeDataExternal : public WindowTreeData { |
kylechar
2017/02/21 18:51:08
WindowTreeDataExternal + kSquareSize should be in
fwang
2017/02/21 19:02:21
Done.
|
+ public: |
+ // Creates a new window tree host associated to the WindowTreeData. |
+ WindowTreeDataExternal(mojom::WindowTreeHostFactory* factory, |
+ mojom::WindowTreeClientPtr tree_client, |
+ int square_size) |
+ : WindowTreeData(square_size) { |
+ factory->CreateWindowTreeHost(MakeRequest(&host_), std::move(tree_client)); |
+ } |
+ |
+ // Holds the Mojo pointer to the window tree host. |
+ 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.
|
+}; |
+ |
+// Size of square in pixels to draw. |
+const int kSquareSize = 500; |
+ |
+MusDemoExternal::MusDemoExternal() {} |
+ |
+MusDemoExternal::~MusDemoExternal() {} |
+ |
+void MusDemoExternal::OnStartImpl( |
+ std::unique_ptr<aura::WindowTreeClient>* window_tree_client, |
+ std::unique_ptr<WindowTreeData>* window_tree_data) { |
+ context()->connector()->BindInterface(ui::mojom::kServiceName, |
+ &window_tree_host_factory_); |
+ mojom::WindowTreeClientPtr tree_client; |
+ 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
|
+ context()->connector(), this, nullptr, MakeRequest(&tree_client))); |
+ // TODO(tonikitoo,fwang): Open two external windows with different square |
+ // sizes. |
+ window_tree_data->reset(new WindowTreeDataExternal( |
+ window_tree_host_factory_.get(), std::move(tree_client), kSquareSize)); |
+ |
+ // TODO(tonikitoo,fwang): Implement management of displays in external mode. |
+ // For now, a fake display is created in order to work around an assertion in |
+ // aura::GetDeviceScaleFactorFromDisplay(). |
+ 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.
|
+ AddPrimaryDisplay(*fake_display_); |
+} |
+ |
+void MusDemoExternal::OnEmbed( |
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
+ InitWindowTreeData(std::move(window_tree_host)); |
+} |
+ |
+void MusDemoExternal::OnEmbedRootDestroyed( |
+ aura::WindowTreeHostMus* window_tree_host) { |
+ CleanupWindowTreeData(); |
+} |
+ |
+} // namespace demo |
+} // namespace ui |