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

Unified Diff: services/ui/demo/mus_demo_external.cc

Issue 2622103004: Mus Demo: Demonstrate external window mode (Closed)
Patch Set: Add MusDemoExternal Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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..2844a7a11788fd7942abb62c6390c866e8926f5a
--- /dev/null
+++ b/services/ui/demo/mus_demo_external.cc
@@ -0,0 +1,44 @@
+// 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/public/interfaces/constants.mojom.h"
+#include "ui/aura/mus/window_tree_client.h"
+#include "ui/aura/mus/window_tree_host_mus.h"
+
+namespace ui {
+namespace demo {
+
+// Size of square in pixels to draw.
+const int kSquareSize = 500;
+
+MusDemoExternal::MusDemoExternal() {}
+
+void MusDemoExternal::OnStartImpl() {
+ context()->connector()->BindInterface(ui::mojom::kServiceName,
+ &window_tree_host_factory_);
+ mojom::WindowTreeClientPtr tree_client;
+ window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>(
+ context()->connector(), this, nullptr, MakeRequest(&tree_client));
+ window_tree_data_ = base::MakeUnique<WindowTreeData>(
+ window_tree_host_factory_.get(), std::move(tree_client), kSquareSize);
+ // TODO(tonikitoo,fwang): Open two external windows with different square
+ // sizes.
+}
+
+void MusDemoExternal::OnEmbed(
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
+ DCHECK(window_tree_data_);
+ window_tree_data_->Init(std::move(window_tree_host));
+}
+
+void MusDemoExternal::OnEmbedRootDestroyed(
+ aura::WindowTreeHostMus* window_tree_host) {
+ window_tree_data_.reset();
+}
+
+} // namespace demo
+} // namespace aura

Powered by Google App Engine
This is Rietveld 408576698