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

Unified Diff: mash/wm/accelerator_registrar_impl.h

Issue 1488713002: mus: Introduce AcceleratorRegistrar and AcceleratorHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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: mash/wm/accelerator_registrar_impl.h
diff --git a/mash/wm/accelerator_registrar_impl.h b/mash/wm/accelerator_registrar_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..9852ea5ac788ca83ff007e36f56be81c48c3baf8
--- /dev/null
+++ b/mash/wm/accelerator_registrar_impl.h
@@ -0,0 +1,64 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_
+#define MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_
+
+#include <map>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "components/mus/public/interfaces/accelerator_registrar.mojom.h"
+#include "mojo/common/weak_binding_set.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace mus {
+namespace mojom {
+class WindowTreeHost;
+}
+}
+
+namespace mash {
+namespace wm {
+
+class WindowManagerApplication;
+
+class AcceleratorRegistrarImpl : public mus::mojom::AcceleratorRegistrar {
+ public:
+ using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>;
+ AcceleratorRegistrarImpl(mus::mojom::WindowTreeHost* host,
+ uint32_t accelerator_namespace,
+ mojo::InterfaceRequest<AcceleratorRegistrar> request,
+ const DestroyCallback& destroy_callback);
+
+ bool OwnsAccelerator(uint32_t accelerator_id) const;
+ void ProcessAccelerator(uint32_t accelerator_id, mus::mojom::EventPtr event);
+
+ private:
+ ~AcceleratorRegistrarImpl() override;
+
+ uint32_t ComputeAcceleratorId(uint32_t accelerator_id) const;
+ void OnBindingGone();
+ void OnHandlerGone(uint32_t accelerator_id);
+
+ // mus::mojom::AcceleratorRegistrar:
+ void AddAccelerator(uint32_t accelerator_id,
+ mus::mojom::EventMatcherPtr matcher,
+ mus::mojom::AcceleratorHandlerPtr handler,
+ const AddAcceleratorCallback& callback) override;
+ void RemoveAccelerator(uint32_t accelerator_id) override;
+
+ mus::mojom::WindowTreeHost* host_;
+ uint32_t accelerator_namespace_;
+ mojo::Binding<AcceleratorRegistrar> binding_;
+ std::map<uint32_t, mus::mojom::AcceleratorHandlerPtr> accelerator_handlers_;
+ DestroyCallback destroy_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl);
+};
+
+} // namespace wm
+} // namespace mash
+
+#endif // MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698