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

Unified Diff: chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.cc

Issue 2760773002: Reland: add voice interaction shortcut. (Closed)
Patch Set: modified CL Created 3 years, 9 months 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: chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.cc
diff --git a/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.cc b/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd535d9b85a8d69b4a75eed3ae2a007b9c30d361
--- /dev/null
+++ b/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.cc
@@ -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.
+
+#include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.h"
+
+#include <utility>
+#include <vector>
+
+#include "ash/common/accelerators/accelerator_controller.h"
+#include "ash/common/wm_shell.h"
+#include "ash/shell.h"
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "chromeos/chromeos_switches.h"
+#include "components/arc/arc_bridge_service.h"
+#include "components/arc/instance_holder.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace arc {
+
+// static
+bool ArcVoiceInteractionFrameworkService::IsVoiceInteractionEnabled() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableVoiceInteraction);
+}
+
+ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService(
+ ArcBridgeService* bridge_service)
+ : ArcService(bridge_service), binding_(this) {
+ arc_bridge_service()->voice_interaction_framework()->AddObserver(this);
+}
+
+ArcVoiceInteractionFrameworkService::~ArcVoiceInteractionFrameworkService() {
+ arc_bridge_service()->voice_interaction_framework()->RemoveObserver(this);
+}
+
+void ArcVoiceInteractionFrameworkService::OnInstanceReady() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ mojom::VoiceInteractionFrameworkInstance* framework_instance =
+ ARC_GET_INSTANCE_FOR_METHOD(
+ arc_bridge_service()->voice_interaction_framework(), Init);
+ DCHECK(framework_instance);
+ framework_instance->Init(binding_.CreateInterfacePtrAndBind());
+
+ ash::Shell::Get()->accelerator_controller()->Register(
+ {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this);
+}
+
+void ArcVoiceInteractionFrameworkService::OnInstanceClosed() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ ash::Shell::Get()->accelerator_controller()->UnregisterAll(this);
+}
+
+bool ArcVoiceInteractionFrameworkService::AcceleratorPressed(
+ const ui::Accelerator& accelerator) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ mojom::VoiceInteractionFrameworkInstance* framework_instance =
+ ARC_GET_INSTANCE_FOR_METHOD(
+ arc_bridge_service()->voice_interaction_framework(),
+ StartVoiceInteractionSession);
+ DCHECK(framework_instance);
+ framework_instance->StartVoiceInteractionSession();
+ return true;
+}
+
+bool ArcVoiceInteractionFrameworkService::CanHandleAccelerators() const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return true;
+}
+
+void ArcVoiceInteractionFrameworkService::CaptureFocusedWindow(
+ const CaptureFocusedWindowCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ NOTIMPLEMENTED();
+ // TODO(muyuanli): The logic below is only there to prevent blocking.
+ // details needs to be implemented in the future.
+ callback.Run(std::vector<uint8_t>{});
+}
+
+} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.h ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698