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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_fr amework_service.h"
6
7 #include <utility>
8 #include <vector>
9
10 #include "ash/common/accelerators/accelerator_controller.h"
11 #include "ash/common/wm_shell.h"
12 #include "ash/shell.h"
13 #include "base/command_line.h"
14 #include "base/logging.h"
15 #include "chromeos/chromeos_switches.h"
16 #include "components/arc/arc_bridge_service.h"
17 #include "components/arc/instance_holder.h"
18 #include "content/public/browser/browser_thread.h"
19
20 namespace arc {
21
22 // static
23 bool ArcVoiceInteractionFrameworkService::IsVoiceInteractionEnabled() {
24 return base::CommandLine::ForCurrentProcess()->HasSwitch(
25 chromeos::switches::kEnableVoiceInteraction);
26 }
27
28 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService(
29 ArcBridgeService* bridge_service)
30 : ArcService(bridge_service), binding_(this) {
31 arc_bridge_service()->voice_interaction_framework()->AddObserver(this);
32 }
33
34 ArcVoiceInteractionFrameworkService::~ArcVoiceInteractionFrameworkService() {
35 arc_bridge_service()->voice_interaction_framework()->RemoveObserver(this);
36 }
37
38 void ArcVoiceInteractionFrameworkService::OnInstanceReady() {
39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
40 mojom::VoiceInteractionFrameworkInstance* framework_instance =
41 ARC_GET_INSTANCE_FOR_METHOD(
42 arc_bridge_service()->voice_interaction_framework(), Init);
43 DCHECK(framework_instance);
44 framework_instance->Init(binding_.CreateInterfacePtrAndBind());
45
46 ash::Shell::Get()->accelerator_controller()->Register(
47 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this);
48 }
49
50 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() {
51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
52 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this);
53 }
54
55 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed(
56 const ui::Accelerator& accelerator) {
57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
58 mojom::VoiceInteractionFrameworkInstance* framework_instance =
59 ARC_GET_INSTANCE_FOR_METHOD(
60 arc_bridge_service()->voice_interaction_framework(),
61 StartVoiceInteractionSession);
62 DCHECK(framework_instance);
63 framework_instance->StartVoiceInteractionSession();
64 return true;
65 }
66
67 bool ArcVoiceInteractionFrameworkService::CanHandleAccelerators() const {
68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
69 return true;
70 }
71
72 void ArcVoiceInteractionFrameworkService::CaptureFocusedWindow(
73 const CaptureFocusedWindowCallback& callback) {
74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
75 NOTIMPLEMENTED();
76 // TODO(muyuanli): The logic below is only there to prevent blocking.
77 // details needs to be implemented in the future.
78 callback.Run(std::vector<uint8_t>{});
79 }
80
81 } // namespace arc
OLDNEW
« 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