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

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: Addressed comments 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::OnMetalayerComplete() {
Luis Héctor Chávez 2017/04/20 16:03:26 nit: DCHECK_CURRENTLY_ON(content::BrowserThread::U
Vladislav Kaznacheev 2017/04/20 17:54:55 Done.
148 if (!metalayer_closed_callback_.is_null())
149 base::ResetAndReturn(&metalayer_closed_callback_).Run();
150 }
151
152 bool ArcVoiceInteractionFrameworkService::HasMetalayer() {
Luis Héctor Chávez 2017/04/20 16:03:26 nit: DCHECK_CURRENTLY_ON(content::BrowserThread::U
Vladislav Kaznacheev 2017/04/20 17:54:55 Done.
153 mojom::VoiceInteractionFrameworkInstance* framework_instance =
154 ARC_GET_INSTANCE_FOR_METHOD(
155 arc_bridge_service()->voice_interaction_framework(),
156 SetMetalayerVisibility);
157 return framework_instance;
158 }
159
160 void ArcVoiceInteractionFrameworkService::ShowMetalayer(
161 const base::Closure& done) {
Luis Héctor Chávez 2017/04/20 16:03:26 nit: DCHECK_CURRENTLY_ON(content::BrowserThread::U
Vladislav Kaznacheev 2017/04/20 17:54:55 Done.
162 if (!metalayer_closed_callback_.is_null()) {
163 LOG(ERROR) << "Metalayer is already enabled";
164 return;
165 }
166 metalayer_closed_callback_ = done;
167 SetMetalayerVisibility(true);
168 }
169
170 void ArcVoiceInteractionFrameworkService::HideMetalayer() {
Luis Héctor Chávez 2017/04/20 16:03:26 nit: DCHECK_CURRENTLY_ON(content::BrowserThread::U
Vladislav Kaznacheev 2017/04/20 17:54:55 Done.
171 if (metalayer_closed_callback_.is_null()) {
172 LOG(ERROR) << "Metalayer is already hidden";
173 return;
174 }
175 metalayer_closed_callback_ = base::Closure();
176 SetMetalayerVisibility(false);
177 }
178
179 void ArcVoiceInteractionFrameworkService::SetMetalayerVisibility(bool visible) {
Luis Héctor Chávez 2017/04/20 16:03:26 nit: DCHECK_CURRENTLY_ON(content::BrowserThread::U
Vladislav Kaznacheev 2017/04/20 17:54:55 Done.
180 mojom::VoiceInteractionFrameworkInstance* framework_instance =
181 ARC_GET_INSTANCE_FOR_METHOD(
182 arc_bridge_service()->voice_interaction_framework(),
183 SetMetalayerVisibility);
184 if (!framework_instance) {
185 if (!metalayer_closed_callback_.is_null())
186 base::ResetAndReturn(&metalayer_closed_callback_).Run();
187 return;
188 }
189 framework_instance->SetMetalayerVisibility(visible);
190 }
191
139 } // namespace arc 192 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698