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/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/histogram_macros.h" | |
| 18 #include "base/task_scheduler/post_task.h" | 19 #include "base/task_scheduler/post_task.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chromeos/chromeos_switches.h" | 23 #include "chromeos/chromeos_switches.h" |
| 23 #include "components/arc/arc_bridge_service.h" | 24 #include "components/arc/arc_bridge_service.h" |
| 24 #include "components/arc/instance_holder.h" | 25 #include "components/arc/instance_holder.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 27 #include "ui/compositor/layer.h" | 28 #include "ui/compositor/layer.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 base::Bind( | 116 base::Bind( |
| 116 [](const gfx::Image& image) -> std::vector<uint8_t> { | 117 [](const gfx::Image& image) -> std::vector<uint8_t> { |
| 117 std::vector<uint8_t> res; | 118 std::vector<uint8_t> res; |
| 118 gfx::JPEG1xEncodedDataFromImage(image, 100, &res); | 119 gfx::JPEG1xEncodedDataFromImage(image, 100, &res); |
| 119 return res; | 120 return res; |
| 120 }, | 121 }, |
| 121 image), | 122 image), |
| 122 callback); | 123 callback); |
| 123 } | 124 } |
| 124 | 125 |
| 126 void RecordAcceleratorUmaMetrics(const ui::Accelerator& accelerator) { | |
| 127 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_A) { | |
| 128 if (accelerator.IsShiftDown()) { | |
| 129 UMA_HISTOGRAM_BOOLEAN("Keyboard.Shortcuts.CrosMetaLayerEntryMetaShiftA", | |
| 130 true); | |
| 131 return; | |
| 132 } | |
| 133 UMA_HISTOGRAM_BOOLEAN("Keyboard.Shortcuts.CrosVoiceInteractionEntryMetaA", | |
| 134 true); | |
| 135 return; | |
| 136 } | |
| 137 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_SPACE) | |
|
Luis Héctor Chávez
2017/05/23 15:24:44
nit: you cannot elide braces since the body is not
Muyuan
2017/05/23 21:58:42
Done.
| |
| 138 UMA_HISTOGRAM_BOOLEAN( | |
| 139 "Keyboard.Shortcuts.CrosVoiceInteractionEntryMetaSpace", true); | |
| 140 } | |
| 141 | |
| 125 } // namespace | 142 } // namespace |
| 126 | 143 |
| 127 // static | 144 // static |
| 128 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = | 145 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = |
| 129 "arc::ArcVoiceInteractionFrameworkService"; | 146 "arc::ArcVoiceInteractionFrameworkService"; |
| 130 | 147 |
| 131 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( | 148 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( |
| 132 ArcBridgeService* bridge_service) | 149 ArcBridgeService* bridge_service) |
| 133 : ArcService(bridge_service), binding_(this) { | 150 : ArcService(bridge_service), binding_(this) { |
| 134 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); | 151 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 164 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); | 181 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); |
| 165 if (!metalayer_closed_callback_.is_null()) | 182 if (!metalayer_closed_callback_.is_null()) |
| 166 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 183 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
| 167 metalayer_enabled_ = false; | 184 metalayer_enabled_ = false; |
| 168 } | 185 } |
| 169 | 186 |
| 170 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( | 187 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( |
| 171 const ui::Accelerator& accelerator) { | 188 const ui::Accelerator& accelerator) { |
| 172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 189 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 173 | 190 |
| 191 RecordAcceleratorUmaMetrics(accelerator); | |
| 192 | |
| 174 if (accelerator.IsShiftDown()) { | 193 if (accelerator.IsShiftDown()) { |
| 175 // Temporary, used for debugging. | 194 // Temporary, used for debugging. |
| 176 // Does not take into account or update the palette state. | 195 // Does not take into account or update the palette state. |
| 177 mojom::VoiceInteractionFrameworkInstance* framework_instance = | 196 mojom::VoiceInteractionFrameworkInstance* framework_instance = |
| 178 ARC_GET_INSTANCE_FOR_METHOD( | 197 ARC_GET_INSTANCE_FOR_METHOD( |
| 179 arc_bridge_service()->voice_interaction_framework(), | 198 arc_bridge_service()->voice_interaction_framework(), |
| 180 SetMetalayerVisibility); | 199 SetMetalayerVisibility); |
| 181 DCHECK(framework_instance); | 200 DCHECK(framework_instance); |
| 182 framework_instance->SetMetalayerVisibility(true); | 201 framework_instance->SetMetalayerVisibility(true); |
| 183 } else { | 202 } else { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 SetMetalayerVisibility); | 295 SetMetalayerVisibility); |
| 277 if (!framework_instance) { | 296 if (!framework_instance) { |
| 278 if (!metalayer_closed_callback_.is_null()) | 297 if (!metalayer_closed_callback_.is_null()) |
| 279 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 298 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
| 280 return; | 299 return; |
| 281 } | 300 } |
| 282 framework_instance->SetMetalayerVisibility(visible); | 301 framework_instance->SetMetalayerVisibility(visible); |
| 283 } | 302 } |
| 284 | 303 |
| 285 } // namespace arc | 304 } // namespace arc |
| OLD | NEW |