| 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 9fbd03f3146a5073be224f61347b7fda5e2a2c63..df76b4be223ceef715f603f79bf5c1719839c012 100644
|
| --- a/ui/aura/mus/window_tree_client.cc
|
| +++ b/ui/aura/mus/window_tree_client.cc
|
| @@ -344,7 +344,7 @@ bool WindowTreeClient::ApplyServerChangeToExistingInFlightChange(
|
| }
|
|
|
| void WindowTreeClient::BuildWindowTree(
|
| - const mojo::Array<ui::mojom::WindowDataPtr>& windows) {
|
| + const std::vector<ui::mojom::WindowDataPtr>& windows) {
|
| for (const auto& window_data : windows) {
|
| WindowMus* parent = window_data->parent_id == kInvalidServerId
|
| ? nullptr
|
| @@ -370,14 +370,8 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus(
|
| void WindowTreeClient::SetLocalPropertiesFromServerProperties(
|
| WindowMus* window,
|
| const ui::mojom::WindowDataPtr& window_data) {
|
| - for (auto& pair : window_data->properties) {
|
| - if (pair.second.is_null()) {
|
| - window->SetPropertyFromServer(pair.first, nullptr);
|
| - } else {
|
| - std::vector<uint8_t> stl_value = pair.second.To<std::vector<uint8_t>>();
|
| - window->SetPropertyFromServer(pair.first, &stl_value);
|
| - }
|
| - }
|
| + for (auto& pair : window_data->properties)
|
| + window->SetPropertyFromServer(pair.first, &pair.second);
|
| }
|
|
|
| std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
|
| @@ -560,7 +554,7 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
|
|
|
| const bool create_top_level = !window_manager_delegate_ && IsRoot(window);
|
|
|
| - mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties;
|
| + std::unordered_map<std::string, std::vector<uint8_t>> transport_properties;
|
| std::set<const void*> property_keys =
|
| window->GetWindow()->GetAllPropertKeys();
|
| PropertyConverter* property_converter = delegate_->GetPropertyConverter();
|
| @@ -572,10 +566,9 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
|
| continue;
|
| }
|
| if (!transport_value) {
|
| - transport_properties[transport_name] = mojo::Array<uint8_t>(nullptr);
|
| + transport_properties[transport_name] = std::vector<uint8_t>();
|
| } else {
|
| - transport_properties[transport_name] =
|
| - mojo::Array<uint8_t>::From(*transport_value);
|
| + transport_properties[transport_name] = std::move(*transport_value);
|
| }
|
| }
|
|
|
| @@ -585,7 +578,7 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
|
| : ChangeType::NEW_WINDOW));
|
| if (create_top_level) {
|
| tree_->NewTopLevelWindow(change_id, window->server_id(),
|
| - std::move(transport_properties));
|
| + transport_properties);
|
| } else {
|
| tree_->NewWindow(change_id, window->server_id(),
|
| std::move(transport_properties));
|
| @@ -721,20 +714,15 @@ void WindowTreeClient::OnWindowMusPropertyChanged(
|
| }
|
| DCHECK_EQ(transport_name, data_mus->transport_name);
|
|
|
| - mojo::Array<uint8_t> transport_value_mojo(nullptr);
|
| - if (transport_value) {
|
| - transport_value_mojo.resize(transport_value->size());
|
| - if (transport_value->size()) {
|
| - memcpy(&transport_value_mojo.front(), &(transport_value->front()),
|
| - transport_value->size());
|
| - }
|
| - }
|
| + base::Optional<std::vector<uint8_t>> transport_value_mojo;
|
| + if (transport_value)
|
| + transport_value_mojo.emplace(std::move(*transport_value));
|
| +
|
| const uint32_t change_id =
|
| ScheduleInFlightChange(base::MakeUnique<InFlightPropertyChange>(
|
| window, transport_name, std::move(data_mus->transport_value)));
|
| - tree_->SetWindowProperty(change_id, window->server_id(),
|
| - mojo::String(transport_name),
|
| - std::move(transport_value_mojo));
|
| + tree_->SetWindowProperty(change_id, window->server_id(), transport_name,
|
| + transport_value_mojo);
|
| }
|
|
|
| void WindowTreeClient::OnWmMoveLoopCompleted(uint32_t change_id,
|
| @@ -924,9 +912,7 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
|
|
|
| // There is currently no API to bulk set properties, so we iterate over each
|
| // property individually.
|
| - std::map<std::string, std::vector<uint8_t>> properties =
|
| - data->properties.To<std::map<std::string, std::vector<uint8_t>>>();
|
| - for (const auto& pair : properties) {
|
| + for (const auto& pair : data->properties) {
|
| std::unique_ptr<std::vector<uint8_t>> revert_value(
|
| base::MakeUnique<std::vector<uint8_t>>(pair.second));
|
| InFlightPropertyChange property_change(window, pair.first,
|
| @@ -961,7 +947,7 @@ void WindowTreeClient::OnWindowBoundsChanged(Id window_id,
|
| void WindowTreeClient::OnClientAreaChanged(
|
| uint32_t window_id,
|
| const gfx::Insets& new_client_area,
|
| - mojo::Array<gfx::Rect> new_additional_client_areas) {
|
| + const std::vector<gfx::Rect>& new_additional_client_areas) {
|
| // TODO: client area.
|
| // TODO(riajiang): Convert from pixel to DIP. (http://crbug.com/600815)
|
| /*
|
| @@ -969,7 +955,7 @@ void WindowTreeClient::OnClientAreaChanged(
|
| if (window) {
|
| WindowPrivate(window).LocalSetClientArea(
|
| new_client_area,
|
| - new_additional_client_areas.To<std::vector<gfx::Rect>>());
|
| + new_additional_client_areas);
|
| }
|
| */
|
| }
|
| @@ -998,7 +984,7 @@ void WindowTreeClient::OnWindowHierarchyChanged(
|
| Id window_id,
|
| Id old_parent_id,
|
| Id new_parent_id,
|
| - mojo::Array<ui::mojom::WindowDataPtr> windows) {
|
| + std::vector<ui::mojom::WindowDataPtr> windows) {
|
| const bool was_window_known = GetWindowByServerId(window_id) != nullptr;
|
|
|
| BuildWindowTree(windows);
|
| @@ -1073,26 +1059,22 @@ void WindowTreeClient::OnWindowParentDrawnStateChanged(Id window_id,
|
|
|
| void WindowTreeClient::OnWindowSharedPropertyChanged(
|
| Id window_id,
|
| - const mojo::String& name,
|
| - mojo::Array<uint8_t> transport_data) {
|
| + const std::string& name,
|
| + const base::Optional<std::vector<uint8_t>>& transport_data) {
|
| WindowMus* window = GetWindowByServerId(window_id);
|
| if (!window)
|
| return;
|
|
|
| std::unique_ptr<std::vector<uint8_t>> data;
|
| - if (!transport_data.is_null()) {
|
| - data = base::MakeUnique<std::vector<uint8_t>>(
|
| - transport_data.To<std::vector<uint8_t>>());
|
| - }
|
| + if (transport_data.has_value())
|
| + data = base::MakeUnique<std::vector<uint8_t>>(transport_data.value());
|
| +
|
| InFlightPropertyChange new_change(window, name, std::move(data));
|
| if (ApplyServerChangeToExistingInFlightChange(new_change))
|
| return;
|
|
|
| - if (!transport_data.is_null()) {
|
| - data = base::MakeUnique<std::vector<uint8_t>>(
|
| - transport_data.To<std::vector<uint8_t>>());
|
| - }
|
| - window->SetPropertyFromServer(name, data.get());
|
| + window->SetPropertyFromServer(
|
| + name, transport_data.has_value() ? &transport_data.value() : nullptr);
|
| }
|
|
|
| void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
|
| @@ -1203,9 +1185,8 @@ void WindowTreeClient::OnWindowSurfaceChanged(
|
| }
|
|
|
| void WindowTreeClient::OnDragDropStart(
|
| - mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) {
|
| - drag_drop_controller_->OnDragDropStart(
|
| - mime_data.To<std::map<std::string, std::vector<uint8_t>>>());
|
| + const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data) {
|
| + drag_drop_controller_->OnDragDropStart(mojo::UnorderedMapToMap(mime_data));
|
| }
|
|
|
| void WindowTreeClient::OnDragEnter(Id window_id,
|
| @@ -1344,19 +1325,19 @@ void WindowTreeClient::WmSetBounds(uint32_t change_id,
|
| window_manager_internal_client_->WmResponse(change_id, result);
|
| }
|
|
|
| -void WindowTreeClient::WmSetProperty(uint32_t change_id,
|
| - Id window_id,
|
| - const mojo::String& name,
|
| - mojo::Array<uint8_t> transit_data) {
|
| +void WindowTreeClient::WmSetProperty(
|
| + uint32_t change_id,
|
| + Id window_id,
|
| + const std::string& name,
|
| + const base::Optional<std::vector<uint8_t>>& transit_data) {
|
| WindowMus* window = GetWindowByServerId(window_id);
|
| bool result = false;
|
| if (window) {
|
| DCHECK(window_manager_delegate_);
|
| std::unique_ptr<std::vector<uint8_t>> data;
|
| - if (!transit_data.is_null()) {
|
| - data.reset(
|
| - new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>()));
|
| - }
|
| + if (transit_data.has_value())
|
| + data.reset(new std::vector<uint8_t>(transit_data.value()));
|
| +
|
| result = window_manager_delegate_->OnWmSetProperty(window->GetWindow(),
|
| name, &data);
|
| if (result) {
|
| @@ -1371,9 +1352,10 @@ void WindowTreeClient::WmSetProperty(uint32_t change_id,
|
| void WindowTreeClient::WmCreateTopLevelWindow(
|
| uint32_t change_id,
|
| ClientSpecificId requesting_client_id,
|
| - mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
|
| + const std::unordered_map<std::string, std::vector<uint8_t>>&
|
| + transport_properties) {
|
| std::map<std::string, std::vector<uint8_t>> properties =
|
| - transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
|
| + mojo::UnorderedMapToMap(transport_properties);
|
| Window* window =
|
| window_manager_delegate_->OnWmCreateTopLevelWindow(&properties);
|
| embedded_windows_[requesting_client_id].insert(window);
|
|
|