OLD | NEW |
---|---|
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" |
11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/containers/flat_set.h" | 15 #include "base/containers/flat_set.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/metrics/user_metrics.h" | |
19 #include "base/metrics/user_metrics_action.h" | |
18 #include "base/task_scheduler/post_task.h" | 20 #include "base/task_scheduler/post_task.h" |
19 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
22 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
23 #include "components/arc/arc_bridge_service.h" | 25 #include "components/arc/arc_bridge_service.h" |
24 #include "components/arc/instance_holder.h" | 26 #include "components/arc/instance_holder.h" |
25 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
26 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
27 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 base::Bind( | 117 base::Bind( |
116 [](const gfx::Image& image) -> std::vector<uint8_t> { | 118 [](const gfx::Image& image) -> std::vector<uint8_t> { |
117 std::vector<uint8_t> res; | 119 std::vector<uint8_t> res; |
118 gfx::JPEG1xEncodedDataFromImage(image, 100, &res); | 120 gfx::JPEG1xEncodedDataFromImage(image, 100, &res); |
119 return res; | 121 return res; |
120 }, | 122 }, |
121 image), | 123 image), |
122 callback); | 124 callback); |
123 } | 125 } |
124 | 126 |
127 void RecordShortcutAction(const ui::Accelerator& accelerator) { | |
128 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_A) { | |
129 if (accelerator.IsShiftDown()) { | |
130 base::RecordAction(base::UserMetricsAction( | |
131 "VoiceInteraction.MetaLayerEntry.Search_Shift_A")); | |
Daniel Erat
2017/05/24 13:07:55
oh, i thought "meta" was referring to the meta key
Muyuan
2017/05/24 17:48:57
Done.
| |
132 return; | |
133 } | |
134 base::RecordAction( | |
135 base::UserMetricsAction("VoiceInteraction.Entry.Search_A")); | |
136 return; | |
137 } | |
138 | |
139 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_SPACE) { | |
140 base::RecordAction( | |
141 base::UserMetricsAction("VoiceInteraction.Entry.Search_Space")); | |
Daniel Erat
2017/05/24 13:07:55
return here to match the rest of the method and to
Muyuan
2017/05/24 17:48:57
Done.
| |
142 } | |
143 } | |
144 | |
125 } // namespace | 145 } // namespace |
126 | 146 |
127 // static | 147 // static |
128 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = | 148 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = |
129 "arc::ArcVoiceInteractionFrameworkService"; | 149 "arc::ArcVoiceInteractionFrameworkService"; |
130 | 150 |
131 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( | 151 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( |
132 ArcBridgeService* bridge_service) | 152 ArcBridgeService* bridge_service) |
133 : ArcService(bridge_service), binding_(this) { | 153 : ArcService(bridge_service), binding_(this) { |
134 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); | 154 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); |
(...skipping 29 matching lines...) Expand all Loading... | |
164 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); | 184 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); |
165 if (!metalayer_closed_callback_.is_null()) | 185 if (!metalayer_closed_callback_.is_null()) |
166 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 186 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
167 metalayer_enabled_ = false; | 187 metalayer_enabled_ = false; |
168 } | 188 } |
169 | 189 |
170 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( | 190 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( |
171 const ui::Accelerator& accelerator) { | 191 const ui::Accelerator& accelerator) { |
172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 192 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
173 | 193 |
194 RecordShortcutAction(accelerator); | |
195 | |
174 if (accelerator.IsShiftDown()) { | 196 if (accelerator.IsShiftDown()) { |
175 // Temporary, used for debugging. | 197 // Temporary, used for debugging. |
176 // Does not take into account or update the palette state. | 198 // Does not take into account or update the palette state. |
177 mojom::VoiceInteractionFrameworkInstance* framework_instance = | 199 mojom::VoiceInteractionFrameworkInstance* framework_instance = |
178 ARC_GET_INSTANCE_FOR_METHOD( | 200 ARC_GET_INSTANCE_FOR_METHOD( |
179 arc_bridge_service()->voice_interaction_framework(), | 201 arc_bridge_service()->voice_interaction_framework(), |
180 SetMetalayerVisibility); | 202 SetMetalayerVisibility); |
181 DCHECK(framework_instance); | 203 DCHECK(framework_instance); |
182 framework_instance->SetMetalayerVisibility(true); | 204 framework_instance->SetMetalayerVisibility(true); |
183 } else { | 205 } else { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 SetMetalayerVisibility); | 298 SetMetalayerVisibility); |
277 if (!framework_instance) { | 299 if (!framework_instance) { |
278 if (!metalayer_closed_callback_.is_null()) | 300 if (!metalayer_closed_callback_.is_null()) |
279 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 301 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
280 return; | 302 return; |
281 } | 303 } |
282 framework_instance->SetMetalayerVisibility(visible); | 304 framework_instance->SetMetalayerVisibility(visible); |
283 } | 305 } |
284 | 306 |
285 } // namespace arc | 307 } // namespace arc |
OLD | NEW |