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

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

Issue 2900913002: add UMA metrics for voice interaction entries. (Closed)
Patch Set: address review comments Created 3 years, 7 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
« no previous file with comments | « ash/shelf/app_list_button.cc ('k') | tools/metrics/actions/actions.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
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.MetalayerStarted.Search_Shift_A"));
132 return;
133 }
134 base::RecordAction(
135 base::UserMetricsAction("VoiceInteraction.Started.Search_A"));
136 return;
137 }
138
139 if (accelerator.IsCmdDown() && accelerator.key_code() == ui::VKEY_SPACE) {
140 base::RecordAction(
141 base::UserMetricsAction("VoiceInteraction.Started.Search_Space"));
142 return;
143 }
144 }
145
125 } // namespace 146 } // namespace
126 147
127 // static 148 // static
128 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] = 149 const char ArcVoiceInteractionFrameworkService::kArcServiceName[] =
129 "arc::ArcVoiceInteractionFrameworkService"; 150 "arc::ArcVoiceInteractionFrameworkService";
130 151
131 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService( 152 ArcVoiceInteractionFrameworkService::ArcVoiceInteractionFrameworkService(
132 ArcBridgeService* bridge_service) 153 ArcBridgeService* bridge_service)
133 : ArcService(bridge_service), binding_(this) { 154 : ArcService(bridge_service), binding_(this) {
134 arc_bridge_service()->voice_interaction_framework()->AddObserver(this); 155 arc_bridge_service()->voice_interaction_framework()->AddObserver(this);
(...skipping 29 matching lines...) Expand all
164 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); 185 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this);
165 if (!metalayer_closed_callback_.is_null()) 186 if (!metalayer_closed_callback_.is_null())
166 base::ResetAndReturn(&metalayer_closed_callback_).Run(); 187 base::ResetAndReturn(&metalayer_closed_callback_).Run();
167 metalayer_enabled_ = false; 188 metalayer_enabled_ = false;
168 } 189 }
169 190
170 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( 191 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed(
171 const ui::Accelerator& accelerator) { 192 const ui::Accelerator& accelerator) {
172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 193 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
173 194
195 RecordShortcutAction(accelerator);
196
174 if (accelerator.IsShiftDown()) { 197 if (accelerator.IsShiftDown()) {
175 // Temporary, used for debugging. 198 // Temporary, used for debugging.
176 // Does not take into account or update the palette state. 199 // Does not take into account or update the palette state.
177 mojom::VoiceInteractionFrameworkInstance* framework_instance = 200 mojom::VoiceInteractionFrameworkInstance* framework_instance =
178 ARC_GET_INSTANCE_FOR_METHOD( 201 ARC_GET_INSTANCE_FOR_METHOD(
179 arc_bridge_service()->voice_interaction_framework(), 202 arc_bridge_service()->voice_interaction_framework(),
180 SetMetalayerVisibility); 203 SetMetalayerVisibility);
181 DCHECK(framework_instance); 204 DCHECK(framework_instance);
182 framework_instance->SetMetalayerVisibility(true); 205 framework_instance->SetMetalayerVisibility(true);
183 } else { 206 } else {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 SetMetalayerVisibility); 299 SetMetalayerVisibility);
277 if (!framework_instance) { 300 if (!framework_instance) {
278 if (!metalayer_closed_callback_.is_null()) 301 if (!metalayer_closed_callback_.is_null())
279 base::ResetAndReturn(&metalayer_closed_callback_).Run(); 302 base::ResetAndReturn(&metalayer_closed_callback_).Run();
280 return; 303 return;
281 } 304 }
282 framework_instance->SetMetalayerVisibility(visible); 305 framework_instance->SetMetalayerVisibility(visible);
283 } 306 }
284 307
285 } // namespace arc 308 } // namespace arc
OLDNEW
« no previous file with comments | « ash/shelf/app_list_button.cc ('k') | tools/metrics/actions/actions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698