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

Unified Diff: ui/aura/mus/window_tree_client.cc

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: rebased Created 3 years, 9 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/aura/mus/window_tree_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client.cc
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc
index bc00034df1b57ced12c7b4e8cd97573612256d7d..f6c28e6be901ab23bc1274c27272c6ab68f2b39c 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -183,6 +183,7 @@ WindowTreeClient::WindowTreeClient(
binding_(this),
tree_(nullptr),
in_destructor_(false),
+ in_external_window_mode_(false),
weak_factory_(this) {
DCHECK(delegate_);
// Allow for a null request in tests.
@@ -220,6 +221,22 @@ WindowTreeClient::~WindowTreeClient() {
}
}
+void WindowTreeClient::ConnectViaWindowTreeHostFactory() {
+ // The client id doesn't really matter, we use 101 purely for debugging.
+ client_id_ = 101;
+
+ ui::mojom::WindowTreeHostFactoryRegistrarPtr host_factory_registrar;
+ connector_->BindInterface(ui::mojom::kServiceName, &host_factory_registrar);
+
+ ui::mojom::WindowTreePtr window_tree;
+ host_factory_registrar->Register(MakeRequest(&window_tree_host_factory_ptr_),
+ MakeRequest(&window_tree),
+ binding_.CreateInterfacePtrAndBind());
+ SetWindowTree(std::move(window_tree));
+
+ in_external_window_mode_ = true;
+}
+
void WindowTreeClient::ConnectViaWindowTreeFactory() {
// The client id doesn't really matter, we use 101 purely for debugging.
client_id_ = 101;
@@ -419,6 +436,14 @@ std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this,
display_id);
window_tree_host->InitHost();
+
+ ConfigureWindowDataFromServer(window_tree_host.get(), window_data);
+ return window_tree_host;
+}
+
+void WindowTreeClient::ConfigureWindowDataFromServer(
+ WindowTreeHostMus* window_tree_host,
+ const ui::mojom::WindowData& window_data) {
SetLocalPropertiesFromServerProperties(
WindowMus::Get(window_tree_host->window()), window_data);
if (window_data.visible) {
@@ -427,7 +452,6 @@ std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
}
SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()),
window_data.bounds);
- return window_tree_host;
}
WindowMus* WindowTreeClient::NewWindowFromWindowData(
@@ -843,7 +867,29 @@ void WindowTreeClient::OnEmbed(ClientSpecificId client_id,
int64_t display_id,
Id focused_window_id,
bool drawn) {
+ if (in_external_window_mode_) {
+ // No need to set 'tree_ptr_' whether it was already set during
+ // ConnectViaWindowManagerHostFactory.
+ DCHECK(tree_ptr_);
+ DCHECK(!tree);
+
+ auto it = windows_.find(focused_window_id);
+ DCHECK(it != windows_.end());
+
+ WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(it->second);
+ window_tree_host->InitHost();
+ ConfigureWindowDataFromServer(window_tree_host, *root_data);
+
+ // TODO(tonikitoo): Fix the WindowTreeClientDelegate::OnEmbed API.
+ // In external window mode, this needs not to pass the ownership of the
+ // WindowTreeHostMus instance to the delegate_. A raw pointer should
+ // surface.
+ delegate_->OnEmbed(nullptr);
+ return;
+ }
+
DCHECK(!tree_ptr_);
+ DCHECK(tree);
tree_ptr_ = std::move(tree);
is_from_embed_ = true;
@@ -1716,8 +1762,12 @@ void WindowTreeClient::OnWindowTreeHostCancelWindowMove(
std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
const std::map<std::string, std::vector<uint8_t>>* properties) {
+ WindowMusType window_type = in_external_window_mode_
+ ? WindowMusType::EMBED
+ : WindowMusType::TOP_LEVEL;
+
std::unique_ptr<WindowPortMus> window_port =
- base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL);
+ base::MakeUnique<WindowPortMus>(this, window_type);
roots_.insert(window_port.get());
window_port->set_server_id(MakeTransportId(client_id_, next_window_id_++));
@@ -1729,11 +1779,21 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
transport_properties[property_pair.first] = property_pair.second;
}
- const uint32_t change_id =
- ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
- window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW));
- tree_->NewTopLevelWindow(change_id, window_port->server_id(),
- transport_properties);
+ if (in_external_window_mode_) {
+ // Triggers the creation of a mojom::WindowTreeHost (aka ws::Display)
+ // instance on the server side.
+ // Ends up calling back to client side, aura::WindowTreeClient::OnEmbed.
+ ui::mojom::WindowTreeHostPtr host;
+ window_tree_host_factory_ptr_->CreatePlatformWindow(
+ MakeRequest(&host), window_port->server_id());
+ } else {
+ const uint32_t change_id =
+ ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
+ window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW));
+ tree_->NewTopLevelWindow(change_id, window_port->server_id(),
+ transport_properties);
+ }
+
return window_port;
}
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698