Index: chrome/browser/chromeos/arc/arc_voice_interaction_service.h |
diff --git a/chrome/browser/chromeos/arc/arc_voice_interaction_service.h b/chrome/browser/chromeos/arc/arc_voice_interaction_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c7bf18a5c8e09c542a1944bb2a33f93ce4d1c221 |
--- /dev/null |
+++ b/chrome/browser/chromeos/arc/arc_voice_interaction_service.h |
@@ -0,0 +1,81 @@ |
+// Copyright 2017 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 CHROME_BROWSER_CHROMEOS_ARC_ARC_VOICE_INTERACTION_SERVICE_H_ |
+#define CHROME_BROWSER_CHROMEOS_ARC_ARC_VOICE_INTERACTION_SERVICE_H_ |
+ |
+#include "base/macros.h" |
+#include "components/arc/arc_service.h" |
+#include "components/arc/common/voice_interaction.mojom.h" |
+#include "components/arc/instance_holder.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+#include "ui/base/accelerators/accelerator.h" |
+ |
+namespace arc { |
+ |
+class ArcVoiceInteractionService; |
+ |
+class ArcHomeObserver |
Luis Héctor Chávez
2017/03/08 15:22:40
This can be forward-declared in the private sectio
Muyuan
2017/03/09 00:41:03
Done.
|
+ : public InstanceHolder<mojom::VoiceInteractionArcHomeInstance>::Observer { |
+ ArcVoiceInteractionService* service_; |
+ |
+ public: |
Luis Héctor Chávez
2017/03/08 15:22:40
in Chromium/Google, the order is public, protected
Muyuan
2017/03/09 00:41:03
Done.
|
+ explicit ArcHomeObserver(ArcVoiceInteractionService* service) |
+ : service_(service) {} |
+ void OnInstanceReady() override; |
+ void OnInstanceClosed() override; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ArcHomeObserver); |
+}; |
+ |
+class CaptureObserver |
+ : public InstanceHolder<mojom::VoiceInteractionCaptureInstance>::Observer { |
+ ArcVoiceInteractionService* service_; |
+ |
+ public: |
+ explicit CaptureObserver(ArcVoiceInteractionService* service) |
+ : service_(service) {} |
+ void OnInstanceReady() override; |
+ void OnInstanceClosed() override; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CaptureObserver); |
+}; |
+ |
+// Lives on the UI thread. |
+class ArcVoiceInteractionService : public ArcService, |
+ public mojom::VoiceInteractionHost, |
+ public ui::AcceleratorTarget { |
+ public: |
+ explicit ArcVoiceInteractionService(ArcBridgeService* bridge_service); |
+ ~ArcVoiceInteractionService() override; |
+ |
+ void OnCaptureInstanceReady(); |
+ void OnCaptureInstanceClosed(); |
+ |
+ void OnArcHomeInstanceReady(); |
+ void OnArcHomeInstanceClosed(); |
+ |
+ // ui::AcceleratorTarget overrides. |
+ bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
+ bool CanHandleAccelerators() const override; |
+ |
+ // mojom::VoiceInteractionHost overrides. |
+ void GetVoiceInteractionStructure( |
+ const GetVoiceInteractionStructureCallback& callback) override; |
+ void CaptureFocusedWindow( |
+ const CaptureFocusedWindowCallback& callback) override; |
+ |
+ private: |
+ std::unique_ptr<ArcHomeObserver> home_observer_; |
+ std::unique_ptr<CaptureObserver> capture_observer_; |
+ |
+ mojo::Binding<mojom::VoiceInteractionHost> home_binding_; |
+ mojo::Binding<mojom::VoiceInteractionHost> capture_binding_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ArcVoiceInteractionService); |
+}; |
+ |
+} // namespace arc |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_VOICE_INTERACTION_SERVICE_H_ |