OLD | NEW |
---|---|
(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 bool ArcVoiceInteractionFrameworkService::IsVoiceInteractionEnabled() { | |
Luis Héctor Chávez
2017/03/18 03:02:12
nit: add
// static
above
Muyuan
2017/03/19 00:24:15
Done.
| |
23 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
24 chromeos::switches::kEnableVoiceInteraction); | |
25 } | |
26 | |
27 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( | |
28 ArcBridgeService* bridge_service) | |
29 : ArcService(bridge_service), binding_(this) { | |
30 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); | |
31 } | |
32 | |
33 ArcVoiceInteractionFrameworkService::~ArcVoiceInteractionFrameworkService() { | |
34 arc_bridge_service()->voice_interaction_framework()->RemoveObserver(this); | |
35 } | |
36 | |
37 void ArcVoiceInteractionFrameworkService::OnInstanceReady() { | |
38 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
39 mojom::VoiceInteractionFrameworkInstance* framework_instance = | |
40 ARC_GET_INSTANCE_FOR_METHOD( | |
41 arc_bridge_service()->voice_interaction_framework(), Init); | |
42 DCHECK(framework_instance); | |
43 framework_instance->Init(binding_.CreateInterfacePtrAndBind()); | |
44 | |
45 ash::Shell::Get()->accelerator_controller()->Register( | |
46 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this); | |
47 } | |
48 | |
49 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() { | |
50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
51 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); | |
52 } | |
53 | |
54 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( | |
55 const ui::Accelerator& accelerator) { | |
56 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
57 mojom::VoiceInteractionFrameworkInstance* framework_instance = | |
58 ARC_GET_INSTANCE_FOR_METHOD( | |
59 arc_bridge_service()->voice_interaction_framework(), | |
60 StartVoiceInteractionSession); | |
61 DCHECK(framework_instance); | |
62 framework_instance->StartVoiceInteractionSession(); | |
63 return true; | |
64 } | |
65 | |
66 bool ArcVoiceInteractionFrameworkService::CanHandleAccelerators() const { | |
67 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
68 return true; | |
69 } | |
70 | |
71 void ArcVoiceInteractionFrameworkService::CaptureFocusedWindow( | |
72 const CaptureFocusedWindowCallback& callback) { | |
73 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
74 NOTIMPLEMENTED(); | |
75 // TODO(muyuanli): The logic below is only there to prevent blocking. | |
76 // details needs to be implemented in the future. | |
77 callback.Run({}); | |
78 } | |
79 | |
80 } // namespace arc | |
OLD | NEW |