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

Unified Diff: ash/mus/accelerators/accelerator_controller_registrar.cc

Issue 2520093003: WindowManagerClient::AddAccelerator() should take an array (Closed)
Patch Set: Create anonymous namespace helper for AcceleratorTransport mojom struct. Cleanup/format codes. 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 side-by-side diff with in-line comments
Download patch
Index: ash/mus/accelerators/accelerator_controller_registrar.cc
diff --git a/ash/mus/accelerators/accelerator_controller_registrar.cc b/ash/mus/accelerators/accelerator_controller_registrar.cc
index 79d7ea794ccaf9247c1c76c5187e4a1abfe8b742..9b73dbd349b0224701fac20da2d5388f844f93a5 100644
--- a/ash/mus/accelerators/accelerator_controller_registrar.cc
+++ b/ash/mus/accelerators/accelerator_controller_registrar.cc
@@ -18,6 +18,19 @@
#include "services/ui/public/cpp/window_tree_client.h"
#include "ui/base/accelerators/accelerator_history.h"
+namespace {
mfomitchev 2016/11/24 19:56:13 Just use the existing anonymous namespace in ash::
thanhph 2016/11/29 00:08:29 I put this helper in different file accelerator_tr
+
+struct AcceleratorTransportWrapper {
+ ui::mojom::AcceleratorTransportPtr accelerator_transport_ptr;
+ AcceleratorTransportWrapper(uint32_t id,
+ ui::mojom::EventMatcherPtr event_matcher) {
+ accelerator_transport_ptr = ui::mojom::AcceleratorTransport::New();
+ accelerator_transport_ptr->id = id;
+ accelerator_transport_ptr->event_matcher = event_matcher.Clone();
+ }
+};
+}
+
namespace ash {
namespace mus {
namespace {
@@ -126,12 +139,28 @@ void AcceleratorControllerRegistrar::OnAcceleratorRegistered(
post_event_matcher->accelerator_phase =
ui::mojom::AcceleratorPhase::POST_TARGET;
- window_manager_->window_manager_client()->AddAccelerator(
- ComputeAcceleratorId(id_namespace_, ids.pre_id), std::move(event_matcher),
+ AcceleratorTransportWrapper pre_accelerator_transport_wrapper(
mfomitchev 2016/11/24 19:56:13 I don't think this struct helps us much. Why not j
thanhph 2016/11/29 00:08:29 Done. Please review the accelerator_transport_util
+ ComputeAcceleratorId(id_namespace_, ids.pre_id),
+ std::move(event_matcher));
+
+ std::vector<ui::mojom::AcceleratorTransportPtr> pre_multi_accelerators;
+ pre_multi_accelerators.push_back(
+ std::move(pre_accelerator_transport_wrapper.accelerator_transport_ptr));
+
+ window_manager_->window_manager_client()->AddAccelerators(
+ std::move(pre_multi_accelerators),
base::Bind(OnAcceleratorAdded, accelerator));
- window_manager_->window_manager_client()->AddAccelerator(
+
+ AcceleratorTransportWrapper post_accelerator_transport_wrapper(
ComputeAcceleratorId(id_namespace_, ids.post_id),
- std::move(post_event_matcher),
+ std::move(post_event_matcher));
+
+ std::vector<ui::mojom::AcceleratorTransportPtr> post_multi_accelerators;
+ post_multi_accelerators.push_back(
+ std::move(post_accelerator_transport_wrapper.accelerator_transport_ptr));
+
+ window_manager_->window_manager_client()->AddAccelerators(
+ std::move(post_multi_accelerators),
base::Bind(OnAcceleratorAdded, accelerator));
}
« no previous file with comments | « no previous file | services/ui/public/cpp/window_manager_delegate.h » ('j') | services/ui/public/cpp/window_manager_delegate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698