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

Side by Side Diff: chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.cc

Issue 2731403007: add voice interaction shortcut. (Closed)
Patch Set: rebased 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 "base/optional.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 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService(
23 ArcBridgeService* bridge_service)
24 : ArcService(bridge_service), binding_(this) {
25 arc_bridge_service()->voice_interaction_framework()->AddObserver(this);
26 }
27
28 ArcVoiceInteractionFrameworkService::~ArcVoiceInteractionFrameworkService() {
29 arc_bridge_service()->voice_interaction_framework()->RemoveObserver(this);
30 }
31
32 void ArcVoiceInteractionFrameworkService::OnInstanceReady() {
33 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
34 mojom::VoiceInteractionFrameworkInstance* framework_instance =
35 ARC_GET_INSTANCE_FOR_METHOD(
36 arc_bridge_service()->voice_interaction_framework(), Init);
37 DCHECK(framework_instance);
38 framework_instance->Init(binding_.CreateInterfacePtrAndBind());
39
40 ash::WmShell::Get()->accelerator_controller()->Register(
41 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this);
42 }
43
44 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() {
45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
46 ash::WmShell::Get()->accelerator_controller()->UnregisterAll(this);
47 }
48
49 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed(
50 const ui::Accelerator& accelerator) {
51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
52 mojom::VoiceInteractionFrameworkInstance* framework_instance =
53 ARC_GET_INSTANCE_FOR_METHOD(
54 arc_bridge_service()->voice_interaction_framework(),
55 StartVoiceInteractionSession);
56 DCHECK(framework_instance);
57 framework_instance->StartVoiceInteractionSession();
58 return true;
59 }
60
61 bool ArcVoiceInteractionFrameworkService::CanHandleAccelerators() const {
62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
63 return true;
64 }
65
66 void ArcVoiceInteractionFrameworkService::CaptureFocusedWindow(
67 const CaptureFocusedWindowCallback& callback) {
68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
69 NOTIMPLEMENTED();
70 // TODO(muyuanli): The logic below is only there to prevent blocking.
71 // details needs to be implemented in the future.
dcheng 2017/03/17 22:55:16 I don't think this is likely to have a security im
Muyuan 2017/03/17 23:39:29 Acknowledged.
72 callback.Run({});
73 }
74
75 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698