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

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2511883006: Mojo C++ bindings: switch services/ui/public/interfaces mojom target to use STL types. (Closed)
Patch Set: . Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const InFlightChange& change) { 337 const InFlightChange& change) {
338 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change); 338 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change);
339 if (!existing_change) 339 if (!existing_change)
340 return false; 340 return false;
341 341
342 existing_change->SetRevertValueFrom(change); 342 existing_change->SetRevertValueFrom(change);
343 return true; 343 return true;
344 } 344 }
345 345
346 void WindowTreeClient::BuildWindowTree( 346 void WindowTreeClient::BuildWindowTree(
347 const mojo::Array<ui::mojom::WindowDataPtr>& windows) { 347 const std::vector<ui::mojom::WindowDataPtr>& windows) {
348 for (const auto& window_data : windows) { 348 for (const auto& window_data : windows) {
349 WindowMus* parent = window_data->parent_id == kInvalidServerId 349 WindowMus* parent = window_data->parent_id == kInvalidServerId
350 ? nullptr 350 ? nullptr
351 : GetWindowByServerId(window_data->parent_id); 351 : GetWindowByServerId(window_data->parent_id);
352 WindowMus* existing_window = GetWindowByServerId(window_data->window_id); 352 WindowMus* existing_window = GetWindowByServerId(window_data->window_id);
353 if (!existing_window) 353 if (!existing_window)
354 NewWindowFromWindowData(parent, window_data); 354 NewWindowFromWindowData(parent, window_data);
355 else if (parent) 355 else if (parent)
356 parent->AddChildFromServer(existing_window); 356 parent->AddChildFromServer(existing_window);
357 } 357 }
358 } 358 }
359 359
360 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus( 360 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus(
361 const ui::mojom::WindowDataPtr& window_data, 361 const ui::mojom::WindowDataPtr& window_data,
362 WindowMusType window_mus_type) { 362 WindowMusType window_mus_type) {
363 std::unique_ptr<WindowPortMus> window_port_mus( 363 std::unique_ptr<WindowPortMus> window_port_mus(
364 base::MakeUnique<WindowPortMus>(this, window_mus_type)); 364 base::MakeUnique<WindowPortMus>(this, window_mus_type));
365 window_port_mus->set_server_id(window_data->window_id); 365 window_port_mus->set_server_id(window_data->window_id);
366 RegisterWindowMus(window_port_mus.get()); 366 RegisterWindowMus(window_port_mus.get());
367 return window_port_mus; 367 return window_port_mus;
368 } 368 }
369 369
370 void WindowTreeClient::SetLocalPropertiesFromServerProperties( 370 void WindowTreeClient::SetLocalPropertiesFromServerProperties(
371 WindowMus* window, 371 WindowMus* window,
372 const ui::mojom::WindowDataPtr& window_data) { 372 const ui::mojom::WindowDataPtr& window_data) {
373 for (auto& pair : window_data->properties) { 373 for (auto& pair : window_data->properties)
374 if (pair.second.is_null()) { 374 window->SetPropertyFromServer(pair.first, &pair.second);
375 window->SetPropertyFromServer(pair.first, nullptr);
376 } else {
377 std::vector<uint8_t> stl_value = pair.second.To<std::vector<uint8_t>>();
378 window->SetPropertyFromServer(pair.first, &stl_value);
379 }
380 }
381 } 375 }
382 376
383 std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost( 377 std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
384 WindowMusType window_mus_type, 378 WindowMusType window_mus_type,
385 const ui::mojom::WindowDataPtr& window_data, 379 const ui::mojom::WindowDataPtr& window_data,
386 int64_t display_id) { 380 int64_t display_id) {
387 std::unique_ptr<WindowPortMus> window_port = 381 std::unique_ptr<WindowPortMus> window_port =
388 CreateWindowPortMus(window_data, window_mus_type); 382 CreateWindowPortMus(window_data, window_mus_type);
389 roots_.insert(window_port.get()); 383 roots_.insert(window_port.get());
390 std::unique_ptr<WindowTreeHostMus> window_tree_host = 384 std::unique_ptr<WindowTreeHostMus> window_tree_host =
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 547
554 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { 548 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
555 if (window->server_id() != kInvalidServerId) 549 if (window->server_id() != kInvalidServerId)
556 return; 550 return;
557 551
558 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); 552 window->set_server_id(MakeTransportId(client_id_, next_window_id_++));
559 RegisterWindowMus(window); 553 RegisterWindowMus(window);
560 554
561 const bool create_top_level = !window_manager_delegate_ && IsRoot(window); 555 const bool create_top_level = !window_manager_delegate_ && IsRoot(window);
562 556
563 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties; 557 std::unordered_map<std::string, std::vector<uint8_t>> transport_properties;
564 std::set<const void*> property_keys = 558 std::set<const void*> property_keys =
565 window->GetWindow()->GetAllPropertKeys(); 559 window->GetWindow()->GetAllPropertKeys();
566 PropertyConverter* property_converter = delegate_->GetPropertyConverter(); 560 PropertyConverter* property_converter = delegate_->GetPropertyConverter();
567 for (const void* key : property_keys) { 561 for (const void* key : property_keys) {
568 std::string transport_name; 562 std::string transport_name;
569 std::unique_ptr<std::vector<uint8_t>> transport_value; 563 std::unique_ptr<std::vector<uint8_t>> transport_value;
570 if (!property_converter->ConvertPropertyForTransport( 564 if (!property_converter->ConvertPropertyForTransport(
571 window->GetWindow(), key, &transport_name, &transport_value)) { 565 window->GetWindow(), key, &transport_name, &transport_value)) {
572 continue; 566 continue;
573 } 567 }
574 if (!transport_value) { 568 if (!transport_value) {
575 transport_properties[transport_name] = mojo::Array<uint8_t>(nullptr); 569 transport_properties[transport_name] = std::vector<uint8_t>();
576 } else { 570 } else {
577 transport_properties[transport_name] = 571 transport_properties[transport_name] = std::move(*transport_value);
578 mojo::Array<uint8_t>::From(*transport_value);
579 } 572 }
580 } 573 }
581 574
582 const uint32_t change_id = 575 const uint32_t change_id =
583 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( 576 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
584 window, create_top_level ? ChangeType::NEW_TOP_LEVEL_WINDOW 577 window, create_top_level ? ChangeType::NEW_TOP_LEVEL_WINDOW
585 : ChangeType::NEW_WINDOW)); 578 : ChangeType::NEW_WINDOW));
586 if (create_top_level) { 579 if (create_top_level) {
587 tree_->NewTopLevelWindow(change_id, window->server_id(), 580 tree_->NewTopLevelWindow(change_id, window->server_id(),
588 std::move(transport_properties)); 581 transport_properties);
589 } else { 582 } else {
590 tree_->NewWindow(change_id, window->server_id(), 583 tree_->NewWindow(change_id, window->server_id(),
591 std::move(transport_properties)); 584 std::move(transport_properties));
592 } 585 }
593 } 586 }
594 587
595 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window) { 588 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window) {
596 if (focus_synchronizer_->focused_window() == window) 589 if (focus_synchronizer_->focused_window() == window)
597 focus_synchronizer_->OnFocusedWindowDestroyed(); 590 focus_synchronizer_->OnFocusedWindowDestroyed();
598 591
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 static_cast<WindowPortPropertyDataMus*>(data.get()); 707 static_cast<WindowPortPropertyDataMus*>(data.get());
715 708
716 std::string transport_name; 709 std::string transport_name;
717 std::unique_ptr<std::vector<uint8_t>> transport_value; 710 std::unique_ptr<std::vector<uint8_t>> transport_value;
718 if (!delegate_->GetPropertyConverter()->ConvertPropertyForTransport( 711 if (!delegate_->GetPropertyConverter()->ConvertPropertyForTransport(
719 window->GetWindow(), key, &transport_name, &transport_value)) { 712 window->GetWindow(), key, &transport_name, &transport_value)) {
720 return; 713 return;
721 } 714 }
722 DCHECK_EQ(transport_name, data_mus->transport_name); 715 DCHECK_EQ(transport_name, data_mus->transport_name);
723 716
724 mojo::Array<uint8_t> transport_value_mojo(nullptr); 717 base::Optional<std::vector<uint8_t>> transport_value_mojo;
725 if (transport_value) { 718 if (transport_value)
726 transport_value_mojo.resize(transport_value->size()); 719 transport_value_mojo.emplace(std::move(*transport_value));
727 if (transport_value->size()) { 720
728 memcpy(&transport_value_mojo.front(), &(transport_value->front()),
729 transport_value->size());
730 }
731 }
732 const uint32_t change_id = 721 const uint32_t change_id =
733 ScheduleInFlightChange(base::MakeUnique<InFlightPropertyChange>( 722 ScheduleInFlightChange(base::MakeUnique<InFlightPropertyChange>(
734 window, transport_name, std::move(data_mus->transport_value))); 723 window, transport_name, std::move(data_mus->transport_value)));
735 tree_->SetWindowProperty(change_id, window->server_id(), 724 tree_->SetWindowProperty(change_id, window->server_id(), transport_name,
736 mojo::String(transport_name), 725 transport_value_mojo);
737 std::move(transport_value_mojo));
738 } 726 }
739 727
740 void WindowTreeClient::OnWmMoveLoopCompleted(uint32_t change_id, 728 void WindowTreeClient::OnWmMoveLoopCompleted(uint32_t change_id,
741 bool completed) { 729 bool completed) {
742 if (window_manager_internal_client_) 730 if (window_manager_internal_client_)
743 window_manager_internal_client_->WmResponse(change_id, completed); 731 window_manager_internal_client_->WmResponse(change_id, completed);
744 732
745 if (change_id == current_wm_move_loop_change_) { 733 if (change_id == current_wm_move_loop_change_) {
746 current_wm_move_loop_change_ = 0; 734 current_wm_move_loop_change_ = 0;
747 current_wm_move_loop_window_id_ = 0; 735 current_wm_move_loop_window_id_ = 0;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 InFlightChange* current_change = 905 InFlightChange* current_change =
918 GetOldestInFlightChangeMatching(bounds_change); 906 GetOldestInFlightChangeMatching(bounds_change);
919 if (current_change) 907 if (current_change)
920 current_change->SetRevertValueFrom(bounds_change); 908 current_change->SetRevertValueFrom(bounds_change);
921 else if (window->GetWindow()->bounds() != bounds) 909 else if (window->GetWindow()->bounds() != bounds)
922 SetWindowBoundsFromServer(window, bounds); 910 SetWindowBoundsFromServer(window, bounds);
923 } 911 }
924 912
925 // There is currently no API to bulk set properties, so we iterate over each 913 // There is currently no API to bulk set properties, so we iterate over each
926 // property individually. 914 // property individually.
927 std::map<std::string, std::vector<uint8_t>> properties = 915 for (const auto& pair : data->properties) {
928 data->properties.To<std::map<std::string, std::vector<uint8_t>>>();
929 for (const auto& pair : properties) {
930 std::unique_ptr<std::vector<uint8_t>> revert_value( 916 std::unique_ptr<std::vector<uint8_t>> revert_value(
931 base::MakeUnique<std::vector<uint8_t>>(pair.second)); 917 base::MakeUnique<std::vector<uint8_t>>(pair.second));
932 InFlightPropertyChange property_change(window, pair.first, 918 InFlightPropertyChange property_change(window, pair.first,
933 std::move(revert_value)); 919 std::move(revert_value));
934 InFlightChange* current_change = 920 InFlightChange* current_change =
935 GetOldestInFlightChangeMatching(property_change); 921 GetOldestInFlightChangeMatching(property_change);
936 if (current_change) { 922 if (current_change) {
937 current_change->SetRevertValueFrom(property_change); 923 current_change->SetRevertValueFrom(property_change);
938 } else { 924 } else {
939 window->SetPropertyFromServer(pair.first, &pair.second); 925 window->SetPropertyFromServer(pair.first, &pair.second);
(...skipping 14 matching lines...) Expand all
954 InFlightBoundsChange new_change(this, window, new_bounds); 940 InFlightBoundsChange new_change(this, window, new_bounds);
955 if (ApplyServerChangeToExistingInFlightChange(new_change)) 941 if (ApplyServerChangeToExistingInFlightChange(new_change))
956 return; 942 return;
957 943
958 SetWindowBoundsFromServer(window, new_bounds); 944 SetWindowBoundsFromServer(window, new_bounds);
959 } 945 }
960 946
961 void WindowTreeClient::OnClientAreaChanged( 947 void WindowTreeClient::OnClientAreaChanged(
962 uint32_t window_id, 948 uint32_t window_id,
963 const gfx::Insets& new_client_area, 949 const gfx::Insets& new_client_area,
964 mojo::Array<gfx::Rect> new_additional_client_areas) { 950 const std::vector<gfx::Rect>& new_additional_client_areas) {
965 // TODO: client area. 951 // TODO: client area.
966 // TODO(riajiang): Convert from pixel to DIP. (http://crbug.com/600815) 952 // TODO(riajiang): Convert from pixel to DIP. (http://crbug.com/600815)
967 /* 953 /*
968 Window* window = GetWindowByServerId(window_id); 954 Window* window = GetWindowByServerId(window_id);
969 if (window) { 955 if (window) {
970 WindowPrivate(window).LocalSetClientArea( 956 WindowPrivate(window).LocalSetClientArea(
971 new_client_area, 957 new_client_area,
972 new_additional_client_areas.To<std::vector<gfx::Rect>>()); 958 new_additional_client_areas);
973 } 959 }
974 */ 960 */
975 } 961 }
976 962
977 void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id, 963 void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id,
978 uint32_t transient_window_id) { 964 uint32_t transient_window_id) {
979 WindowMus* window = GetWindowByServerId(window_id); 965 WindowMus* window = GetWindowByServerId(window_id);
980 WindowMus* transient_window = GetWindowByServerId(transient_window_id); 966 WindowMus* transient_window = GetWindowByServerId(transient_window_id);
981 // window or transient_window or both may be null if a local delete occurs 967 // window or transient_window or both may be null if a local delete occurs
982 // with an in flight add from the server. 968 // with an in flight add from the server.
983 if (window && transient_window) 969 if (window && transient_window)
984 window->AddTransientChildFromServer(transient_window); 970 window->AddTransientChildFromServer(transient_window);
985 } 971 }
986 972
987 void WindowTreeClient::OnTransientWindowRemoved(uint32_t window_id, 973 void WindowTreeClient::OnTransientWindowRemoved(uint32_t window_id,
988 uint32_t transient_window_id) { 974 uint32_t transient_window_id) {
989 WindowMus* window = GetWindowByServerId(window_id); 975 WindowMus* window = GetWindowByServerId(window_id);
990 WindowMus* transient_window = GetWindowByServerId(transient_window_id); 976 WindowMus* transient_window = GetWindowByServerId(transient_window_id);
991 // window or transient_window or both may be null if a local delete occurs 977 // window or transient_window or both may be null if a local delete occurs
992 // with an in flight delete from the server. 978 // with an in flight delete from the server.
993 if (window && transient_window) 979 if (window && transient_window)
994 window->RemoveTransientChildFromServer(transient_window); 980 window->RemoveTransientChildFromServer(transient_window);
995 } 981 }
996 982
997 void WindowTreeClient::OnWindowHierarchyChanged( 983 void WindowTreeClient::OnWindowHierarchyChanged(
998 Id window_id, 984 Id window_id,
999 Id old_parent_id, 985 Id old_parent_id,
1000 Id new_parent_id, 986 Id new_parent_id,
1001 mojo::Array<ui::mojom::WindowDataPtr> windows) { 987 std::vector<ui::mojom::WindowDataPtr> windows) {
1002 const bool was_window_known = GetWindowByServerId(window_id) != nullptr; 988 const bool was_window_known = GetWindowByServerId(window_id) != nullptr;
1003 989
1004 BuildWindowTree(windows); 990 BuildWindowTree(windows);
1005 991
1006 // If the window was not known, then BuildWindowTree() will have created it 992 // If the window was not known, then BuildWindowTree() will have created it
1007 // and parented the window. 993 // and parented the window.
1008 if (!was_window_known) 994 if (!was_window_known)
1009 return; 995 return;
1010 996
1011 WindowMus* new_parent = GetWindowByServerId(new_parent_id); 997 WindowMus* new_parent = GetWindowByServerId(new_parent_id);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // TODO: route to WindowTreeHost. 1052 // TODO: route to WindowTreeHost.
1067 /* 1053 /*
1068 Window* window = GetWindowByServerId(window_id); 1054 Window* window = GetWindowByServerId(window_id);
1069 if (window) 1055 if (window)
1070 WindowPrivate(window).LocalSetParentDrawn(drawn); 1056 WindowPrivate(window).LocalSetParentDrawn(drawn);
1071 */ 1057 */
1072 } 1058 }
1073 1059
1074 void WindowTreeClient::OnWindowSharedPropertyChanged( 1060 void WindowTreeClient::OnWindowSharedPropertyChanged(
1075 Id window_id, 1061 Id window_id,
1076 const mojo::String& name, 1062 const std::string& name,
1077 mojo::Array<uint8_t> transport_data) { 1063 const base::Optional<std::vector<uint8_t>>& transport_data) {
1078 WindowMus* window = GetWindowByServerId(window_id); 1064 WindowMus* window = GetWindowByServerId(window_id);
1079 if (!window) 1065 if (!window)
1080 return; 1066 return;
1081 1067
1082 std::unique_ptr<std::vector<uint8_t>> data; 1068 std::unique_ptr<std::vector<uint8_t>> data;
1083 if (!transport_data.is_null()) { 1069 if (transport_data.has_value())
1084 data = base::MakeUnique<std::vector<uint8_t>>( 1070 data = base::MakeUnique<std::vector<uint8_t>>(transport_data.value());
1085 transport_data.To<std::vector<uint8_t>>()); 1071
1086 }
1087 InFlightPropertyChange new_change(window, name, std::move(data)); 1072 InFlightPropertyChange new_change(window, name, std::move(data));
1088 if (ApplyServerChangeToExistingInFlightChange(new_change)) 1073 if (ApplyServerChangeToExistingInFlightChange(new_change))
1089 return; 1074 return;
1090 1075
1091 if (!transport_data.is_null()) { 1076 window->SetPropertyFromServer(
1092 data = base::MakeUnique<std::vector<uint8_t>>( 1077 name, transport_data.has_value() ? &transport_data.value() : nullptr);
1093 transport_data.To<std::vector<uint8_t>>());
1094 }
1095 window->SetPropertyFromServer(name, data.get());
1096 } 1078 }
1097 1079
1098 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, 1080 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
1099 Id window_id, 1081 Id window_id,
1100 std::unique_ptr<ui::Event> event, 1082 std::unique_ptr<ui::Event> event,
1101 bool matches_pointer_watcher) { 1083 bool matches_pointer_watcher) {
1102 DCHECK(event); 1084 DCHECK(event);
1103 1085
1104 WindowMus* window = GetWindowByServerId(window_id); // May be null. 1086 WindowMus* window = GetWindowByServerId(window_id); // May be null.
1105 1087
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 if (!window) 1178 if (!window)
1197 return; 1179 return;
1198 std::unique_ptr<SurfaceInfo> surface_info(base::MakeUnique<SurfaceInfo>()); 1180 std::unique_ptr<SurfaceInfo> surface_info(base::MakeUnique<SurfaceInfo>());
1199 surface_info->surface_id = surface_id; 1181 surface_info->surface_id = surface_id;
1200 surface_info->frame_size = frame_size; 1182 surface_info->frame_size = frame_size;
1201 surface_info->device_scale_factor = device_scale_factor; 1183 surface_info->device_scale_factor = device_scale_factor;
1202 window->SetSurfaceIdFromServer(std::move(surface_info)); 1184 window->SetSurfaceIdFromServer(std::move(surface_info));
1203 } 1185 }
1204 1186
1205 void WindowTreeClient::OnDragDropStart( 1187 void WindowTreeClient::OnDragDropStart(
1206 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) { 1188 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data) {
1207 drag_drop_controller_->OnDragDropStart( 1189 drag_drop_controller_->OnDragDropStart(mojo::UnorderedMapToMap(mime_data));
1208 mime_data.To<std::map<std::string, std::vector<uint8_t>>>());
1209 } 1190 }
1210 1191
1211 void WindowTreeClient::OnDragEnter(Id window_id, 1192 void WindowTreeClient::OnDragEnter(Id window_id,
1212 uint32_t key_state, 1193 uint32_t key_state,
1213 const gfx::Point& position, 1194 const gfx::Point& position,
1214 uint32_t effect_bitmask, 1195 uint32_t effect_bitmask,
1215 const OnDragEnterCallback& callback) { 1196 const OnDragEnterCallback& callback) {
1216 callback.Run(drag_drop_controller_->OnDragEnter( 1197 callback.Run(drag_drop_controller_->OnDragEnter(
1217 GetWindowByServerId(window_id), key_state, position, effect_bitmask)); 1198 GetWindowByServerId(window_id), key_state, position, effect_bitmask));
1218 } 1199 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 // If the resulting bounds differ return false. Returning false ensures 1318 // If the resulting bounds differ return false. Returning false ensures
1338 // the client applies the bounds we set below. 1319 // the client applies the bounds we set below.
1339 result = bounds == transit_bounds; 1320 result = bounds == transit_bounds;
1340 window->SetBoundsFromServer(bounds); 1321 window->SetBoundsFromServer(bounds);
1341 } 1322 }
1342 } 1323 }
1343 if (window_manager_internal_client_) 1324 if (window_manager_internal_client_)
1344 window_manager_internal_client_->WmResponse(change_id, result); 1325 window_manager_internal_client_->WmResponse(change_id, result);
1345 } 1326 }
1346 1327
1347 void WindowTreeClient::WmSetProperty(uint32_t change_id, 1328 void WindowTreeClient::WmSetProperty(
1348 Id window_id, 1329 uint32_t change_id,
1349 const mojo::String& name, 1330 Id window_id,
1350 mojo::Array<uint8_t> transit_data) { 1331 const std::string& name,
1332 const base::Optional<std::vector<uint8_t>>& transit_data) {
1351 WindowMus* window = GetWindowByServerId(window_id); 1333 WindowMus* window = GetWindowByServerId(window_id);
1352 bool result = false; 1334 bool result = false;
1353 if (window) { 1335 if (window) {
1354 DCHECK(window_manager_delegate_); 1336 DCHECK(window_manager_delegate_);
1355 std::unique_ptr<std::vector<uint8_t>> data; 1337 std::unique_ptr<std::vector<uint8_t>> data;
1356 if (!transit_data.is_null()) { 1338 if (transit_data.has_value())
1357 data.reset( 1339 data.reset(new std::vector<uint8_t>(transit_data.value()));
1358 new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>())); 1340
1359 }
1360 result = window_manager_delegate_->OnWmSetProperty(window->GetWindow(), 1341 result = window_manager_delegate_->OnWmSetProperty(window->GetWindow(),
1361 name, &data); 1342 name, &data);
1362 if (result) { 1343 if (result) {
1363 delegate_->GetPropertyConverter()->SetPropertyFromTransportValue( 1344 delegate_->GetPropertyConverter()->SetPropertyFromTransportValue(
1364 window->GetWindow(), name, data.get()); 1345 window->GetWindow(), name, data.get());
1365 } 1346 }
1366 } 1347 }
1367 if (window_manager_internal_client_) 1348 if (window_manager_internal_client_)
1368 window_manager_internal_client_->WmResponse(change_id, result); 1349 window_manager_internal_client_->WmResponse(change_id, result);
1369 } 1350 }
1370 1351
1371 void WindowTreeClient::WmCreateTopLevelWindow( 1352 void WindowTreeClient::WmCreateTopLevelWindow(
1372 uint32_t change_id, 1353 uint32_t change_id,
1373 ClientSpecificId requesting_client_id, 1354 ClientSpecificId requesting_client_id,
1374 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 1355 const std::unordered_map<std::string, std::vector<uint8_t>>&
1356 transport_properties) {
1375 std::map<std::string, std::vector<uint8_t>> properties = 1357 std::map<std::string, std::vector<uint8_t>> properties =
1376 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 1358 mojo::UnorderedMapToMap(transport_properties);
1377 Window* window = 1359 Window* window =
1378 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties); 1360 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties);
1379 embedded_windows_[requesting_client_id].insert(window); 1361 embedded_windows_[requesting_client_id].insert(window);
1380 if (window_manager_internal_client_) { 1362 if (window_manager_internal_client_) {
1381 window_manager_internal_client_->OnWmCreatedTopLevelWindow( 1363 window_manager_internal_client_->OnWmCreatedTopLevelWindow(
1382 change_id, WindowMus::Get(window)->server_id()); 1364 change_id, WindowMus::Get(window)->server_id());
1383 } 1365 }
1384 } 1366 }
1385 1367
1386 void WindowTreeClient::WmClientJankinessChanged(ClientSpecificId client_id, 1368 void WindowTreeClient::WmClientJankinessChanged(ClientSpecificId client_id,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1540 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1559 this, capture_synchronizer_.get(), window)); 1541 this, capture_synchronizer_.get(), window));
1560 } 1542 }
1561 1543
1562 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1544 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1563 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1545 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1564 this, focus_synchronizer_.get(), window)); 1546 this, focus_synchronizer_.get(), window));
1565 } 1547 }
1566 1548
1567 } // namespace aura 1549 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698