Chromium Code Reviews| 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/metrics/voice_interaction_metrics.h" | |
| 11 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 13 #include "base/bind.h" | 14 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "base/containers/flat_set.h" | 16 #include "base/containers/flat_set.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/metrics/histogram_macros.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 RecordAcceleratorUmaMetrics(const ui::Accelerator& accelerator) { | |
| 128 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_A) { | |
| 129 if (accelerator.IsShiftDown()) { | |
| 130 UMA_HISTOGRAM_ENUMERATION( | |
| 131 "VoiceInteraction.MetaLayer.EntryPoints", | |
| 132 ash::VoiceInteractionMetaLayerEntry::META_SHIFT_A, | |
|
Daniel Erat
2017/05/23 22:32:18
does "meta" here correspond to the search key? if
Muyuan
2017/05/24 00:24:54
Acknowledged.
| |
| 133 ash::VoiceInteractionMetaLayerEntry::COUNT); | |
| 134 return; | |
| 135 } | |
| 136 UMA_HISTOGRAM_ENUMERATION("VoiceInteraction.EntryPoints", | |
| 137 ash::VoiceInteractionEntry::META_A, | |
| 138 ash::VoiceInteractionEntry::COUNT); | |
| 139 return; | |
| 140 } | |
| 141 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_SPACE) { | |
| 142 UMA_HISTOGRAM_ENUMERATION("VoiceInteraction.EntryPoints", | |
| 143 ash::VoiceInteractionEntry::META_SPACE, | |
| 144 ash::VoiceInteractionEntry::COUNT); | |
| 145 } | |
| 146 } | |
| 147 | |
| 125 } // namespace | 148 } // namespace |
| 126 | 149 |
| 127 // static | 150 // static |
| 128 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = | 151 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = |
| 129 "arc::ArcVoiceInteractionFrameworkService"; | 152 "arc::ArcVoiceInteractionFrameworkService"; |
| 130 | 153 |
| 131 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( | 154 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( |
| 132 ArcBridgeService* bridge_service) | 155 ArcBridgeService* bridge_service) |
| 133 : ArcService(bridge_service), binding_(this) { | 156 : ArcService(bridge_service), binding_(this) { |
| 134 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); | 157 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 164 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); | 187 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); |
| 165 if (!metalayer_closed_callback_.is_null()) | 188 if (!metalayer_closed_callback_.is_null()) |
| 166 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 189 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
| 167 metalayer_enabled_ = false; | 190 metalayer_enabled_ = false; |
| 168 } | 191 } |
| 169 | 192 |
| 170 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( | 193 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( |
| 171 const ui::Accelerator& accelerator) { | 194 const ui::Accelerator& accelerator) { |
| 172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 195 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 173 | 196 |
| 197 RecordAcceleratorUmaMetrics(accelerator); | |
| 198 | |
| 174 if (accelerator.IsShiftDown()) { | 199 if (accelerator.IsShiftDown()) { |
| 175 // Temporary, used for debugging. | 200 // Temporary, used for debugging. |
| 176 // Does not take into account or update the palette state. | 201 // Does not take into account or update the palette state. |
| 177 mojom::VoiceInteractionFrameworkInstance* framework_instance = | 202 mojom::VoiceInteractionFrameworkInstance* framework_instance = |
| 178 ARC_GET_INSTANCE_FOR_METHOD( | 203 ARC_GET_INSTANCE_FOR_METHOD( |
| 179 arc_bridge_service()->voice_interaction_framework(), | 204 arc_bridge_service()->voice_interaction_framework(), |
| 180 SetMetalayerVisibility); | 205 SetMetalayerVisibility); |
| 181 DCHECK(framework_instance); | 206 DCHECK(framework_instance); |
| 182 framework_instance->SetMetalayerVisibility(true); | 207 framework_instance->SetMetalayerVisibility(true); |
| 183 } else { | 208 } else { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 SetMetalayerVisibility); | 301 SetMetalayerVisibility); |
| 277 if (!framework_instance) { | 302 if (!framework_instance) { |
| 278 if (!metalayer_closed_callback_.is_null()) | 303 if (!metalayer_closed_callback_.is_null()) |
| 279 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 304 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
| 280 return; | 305 return; |
| 281 } | 306 } |
| 282 framework_instance->SetMetalayerVisibility(visible); | 307 framework_instance->SetMetalayerVisibility(visible); |
| 283 } | 308 } |
| 284 | 309 |
| 285 } // namespace arc | 310 } // namespace arc |
| OLD | NEW |