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

Unified Diff: ash/common/accelerators/accelerator_router.cc

Issue 2683233008: Add "Search" key press/hold UMA metrics. (Closed)
Patch Set: add zalcorn@ to histogram owner Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/accelerators/accelerator_router.cc
diff --git a/ash/common/accelerators/accelerator_router.cc b/ash/common/accelerators/accelerator_router.cc
index 9b47ee68d08d725cff3ddfa46463910a69e6a51b..fa3fbf122a59667021b82efa8a16fc893d72694a 100644
--- a/ash/common/accelerators/accelerator_router.cc
+++ b/ash/common/accelerators/accelerator_router.cc
@@ -8,6 +8,7 @@
#include "ash/common/wm/window_state.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/events/event.h"
@@ -49,6 +50,7 @@ bool AcceleratorRouter::ProcessAccelerator(WmWindow* target,
const ui::Accelerator& accelerator) {
// Callers should never supply null.
DCHECK(target);
+ RecordSearchKeyStats(accelerator);
// Special hardware keys like brightness and volume are handled in
// special way. However, some windows can override this behavior
// (e.g. Chrome v1 apps by default and Chrome v2 apps with
@@ -65,6 +67,27 @@ bool AcceleratorRouter::ProcessAccelerator(WmWindow* target,
return WmShell::Get()->accelerator_controller()->Process(accelerator);
}
+void AcceleratorRouter::RecordSearchKeyStats(
+ const ui::Accelerator& accelerator) {
+ if (accelerator.IsCmdDown()) {
+ if (!search_key_pressed_) {
+ search_key_pressed_ = true;
+ search_key_pressed_recorded_ = false;
+ search_key_pressed_timestamp_ = base::TimeTicks::Now();
+ }
+
+ if (accelerator.key_code() != ui::KeyboardCode::VKEY_COMMAND &&
+ !search_key_pressed_recorded_) {
+ search_key_pressed_recorded_ = true;
+ UMA_HISTOGRAM_TIMES(
+ "Keyboard.Shortcuts.CrosSearchKeyDelay",
+ base::TimeTicks::Now() - search_key_pressed_timestamp_);
+ }
+ } else {
+ search_key_pressed_ = false;
+ }
+}
+
bool AcceleratorRouter::CanConsumeSystemKeys(WmWindow* target,
const ui::KeyEvent& event) {
// Uses the top level window so if the target is a web contents window the

Powered by Google App Engine
This is Rietveld 408576698