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

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

Issue 2824703006: Add MetalayerMode to the palette. (Closed)
Patch Set: Fixed copyright year Created 3 years, 8 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_fr amework_service.h" 5 #include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_fr amework_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/accelerators/accelerator_controller.h" 10 #include "ash/accelerators/accelerator_controller.h"
(...skipping 23 matching lines...) Expand all
34 return; 34 return;
35 } 35 }
36 std::vector<uint8_t> result(png_data->front(), 36 std::vector<uint8_t> result(png_data->front(),
37 png_data->front() + png_data->size()); 37 png_data->front() + png_data->size());
38 callback.Run(result); 38 callback.Run(result);
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 // static 43 // static
44 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] =
45 "arc::ArcVoiceInteractionFrameworkService";
46
47 // static
44 bool ArcVoiceInteractionFrameworkService::IsVoiceInteractionEnabled() { 48 bool ArcVoiceInteractionFrameworkService::IsVoiceInteractionEnabled() {
45 return base::CommandLine::ForCurrentProcess()->HasSwitch( 49 return base::CommandLine::ForCurrentProcess()->HasSwitch(
46 chromeos::switches::kEnableVoiceInteraction); 50 chromeos::switches::kEnableVoiceInteraction);
47 } 51 }
48 52
49 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( 53 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService(
50 ArcBridgeService* bridge_service) 54 ArcBridgeService* bridge_service)
51 : ArcService(bridge_service), binding_(this) { 55 : ArcService(bridge_service), binding_(this) {
52 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); 56 arc_bridge_service()->voice_interaction_framework()->AddObserver(this);
53 } 57 }
(...skipping 14 matching lines...) Expand all
68 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this); 72 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this);
69 // Temporary shortcut added to enable the metalayer experiment. 73 // Temporary shortcut added to enable the metalayer experiment.
70 ash::Shell::Get()->accelerator_controller()->Register( 74 ash::Shell::Get()->accelerator_controller()->Register(
71 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN)}, 75 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN)},
72 this); 76 this);
73 } 77 }
74 78
75 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() { 79 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() {
76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 80 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
77 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); 81 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this);
82 if (!metalayer_closed_callback_.is_null())
83 base::ResetAndReturn(&metalayer_closed_callback_).Run();
78 } 84 }
79 85
80 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( 86 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed(
81 const ui::Accelerator& accelerator) { 87 const ui::Accelerator& accelerator) {
82 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 88 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
83 89
84 if (accelerator.IsShiftDown()) { 90 if (accelerator.IsShiftDown()) {
91 // Temporary, used for debugging.
92 // Does not take into account or update the palette state.
85 mojom::VoiceInteractionFrameworkInstance* framework_instance = 93 mojom::VoiceInteractionFrameworkInstance* framework_instance =
86 ARC_GET_INSTANCE_FOR_METHOD( 94 ARC_GET_INSTANCE_FOR_METHOD(
87 arc_bridge_service()->voice_interaction_framework(), 95 arc_bridge_service()->voice_interaction_framework(),
88 ToggleMetalayer); 96 SetMetalayerVisibility);
89 DCHECK(framework_instance); 97 DCHECK(framework_instance);
90 framework_instance->ToggleMetalayer(); 98 framework_instance->SetMetalayerVisibility(true);
91 } else { 99 } else {
92 mojom::VoiceInteractionFrameworkInstance* framework_instance = 100 mojom::VoiceInteractionFrameworkInstance* framework_instance =
93 ARC_GET_INSTANCE_FOR_METHOD( 101 ARC_GET_INSTANCE_FOR_METHOD(
94 arc_bridge_service()->voice_interaction_framework(), 102 arc_bridge_service()->voice_interaction_framework(),
95 StartVoiceInteractionSession); 103 StartVoiceInteractionSession);
96 DCHECK(framework_instance); 104 DCHECK(framework_instance);
97 framework_instance->StartVoiceInteractionSession(); 105 framework_instance->StartVoiceInteractionSession();
98 } 106 }
99 107
100 return true; 108 return true;
(...skipping 28 matching lines...) Expand all
129 // the screenshot to it. 137 // the screenshot to it.
130 aura::Window* window = ash::Shell::GetPrimaryRootWindow(); 138 aura::Window* window = ash::Shell::GetPrimaryRootWindow();
131 DCHECK(window); 139 DCHECK(window);
132 ui::GrabWindowSnapshotAsyncPNG(window, gfx::Rect(window->bounds().size()), 140 ui::GrabWindowSnapshotAsyncPNG(window, gfx::Rect(window->bounds().size()),
133 base::CreateTaskRunnerWithTraits( 141 base::CreateTaskRunnerWithTraits(
134 base::TaskTraits().MayBlock().WithPriority( 142 base::TaskTraits().MayBlock().WithPriority(
135 base::TaskPriority::USER_BLOCKING)), 143 base::TaskPriority::USER_BLOCKING)),
136 base::Bind(&ScreenshotCallback, callback)); 144 base::Bind(&ScreenshotCallback, callback));
137 } 145 }
138 146
147 void ArcVoiceInteractionFrameworkService::OnMetalayerClosed() {
148 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
149 if (!metalayer_closed_callback_.is_null())
150 base::ResetAndReturn(&metalayer_closed_callback_).Run();
151 }
152
153 bool ArcVoiceInteractionFrameworkService::IsMetalayerSupported() {
154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
155 mojom::VoiceInteractionFrameworkInstance* framework_instance =
156 ARC_GET_INSTANCE_FOR_METHOD(
157 arc_bridge_service()->voice_interaction_framework(),
158 SetMetalayerVisibility);
159 return framework_instance;
160 }
161
162 void ArcVoiceInteractionFrameworkService::ShowMetalayer(
163 const base::Closure& closed) {
164 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
165 if (!metalayer_closed_callback_.is_null()) {
166 LOG(ERROR) << "Metalayer is already enabled";
167 return;
168 }
169 metalayer_closed_callback_ = closed;
170 SetMetalayerVisibility(true);
171 }
172
173 void ArcVoiceInteractionFrameworkService::HideMetalayer() {
174 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
175 if (metalayer_closed_callback_.is_null()) {
176 LOG(ERROR) << "Metalayer is already hidden";
177 return;
178 }
179 metalayer_closed_callback_ = base::Closure();
180 SetMetalayerVisibility(false);
181 }
182
183 void ArcVoiceInteractionFrameworkService::SetMetalayerVisibility(bool visible) {
184 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
185 mojom::VoiceInteractionFrameworkInstance* framework_instance =
186 ARC_GET_INSTANCE_FOR_METHOD(
187 arc_bridge_service()->voice_interaction_framework(),
188 SetMetalayerVisibility);
189 if (!framework_instance) {
190 if (!metalayer_closed_callback_.is_null())
191 base::ResetAndReturn(&metalayer_closed_callback_).Run();
192 return;
193 }
194 framework_instance->SetMetalayerVisibility(visible);
195 }
196
139 } // namespace arc 197 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698