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

Unified Diff: ui/views/mus/window_manager_connection.cc

Issue 1567623003: Adds remainder of support for multiple roots to WS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 11 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
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/window_manager_connection.cc
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc
index 6fa8370e527fb9bbf6e279a32e8c0efa5cb35830..bd16be5947c23f1b9668e7a8161385d1b0ac6fdd 100644
--- a/ui/views/mus/window_manager_connection.cc
+++ b/ui/views/mus/window_manager_connection.cc
@@ -110,6 +110,9 @@ WindowManagerConnection* WindowManagerConnection::Get() {
mus::Window* WindowManagerConnection::NewWindow(
const std::map<std::string, std::vector<uint8_t>>& properties) {
+ if (window_tree_connection_)
+ return window_tree_connection_->NewTopLevelWindow(&properties);
+
mus::mojom::WindowTreeClientPtr window_tree_client;
mojo::InterfaceRequest<mus::mojom::WindowTreeClient>
window_tree_client_request = GetProxy(&window_tree_client);
@@ -118,16 +121,16 @@ mus::Window* WindowManagerConnection::NewWindow(
mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(properties));
base::ThreadRestrictions::ScopedAllowWait allow_wait;
- mus::WindowTreeConnection* window_tree_connection =
- mus::WindowTreeConnection::Create(
- this, std::move(window_tree_client_request),
- mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED);
- DCHECK_EQ(1u, window_tree_connection->GetRoots().size());
- return *window_tree_connection->GetRoots().begin();
+ window_tree_connection_.reset(mus::WindowTreeConnection::Create(
+ this, std::move(window_tree_client_request),
+ mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED));
+ window_tree_connection_->SetDeleteOnNoRoots(false);
+ DCHECK_EQ(1u, window_tree_connection_->GetRoots().size());
+ return *window_tree_connection_->GetRoots().begin();
}
WindowManagerConnection::WindowManagerConnection(mojo::ApplicationImpl* app)
- : app_(app) {
+ : app_(app), window_tree_connection_(nullptr) {
app->ConnectToService("mojo:mus", &window_manager_);
ui_init_.reset(new ui::mojo::UIInit(
@@ -137,9 +140,14 @@ WindowManagerConnection::WindowManagerConnection(mojo::ApplicationImpl* app)
base::Unretained(this)));
}
-WindowManagerConnection::~WindowManagerConnection() {}
+WindowManagerConnection::~WindowManagerConnection() {
+ // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate),
+ // destroy it while we are still valid.
+ window_tree_connection_.reset();
+}
void WindowManagerConnection::OnEmbed(mus::Window* root) {}
+
void WindowManagerConnection::OnConnectionLost(
mus::WindowTreeConnection* connection) {}
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698