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

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

Issue 2683233008: Add "Search" key press/hold UMA metrics. (Closed)
Patch Set: use enum 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
« no previous file with comments | « ash/common/accelerators/accelerator_router.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/accelerators/accelerator_router.cc
diff --git a/ash/common/accelerators/accelerator_router.cc b/ash/common/accelerators/accelerator_router.cc
index 7abd92d24f1b67b1c52fa1763f9f40e7701b0dd5..2a42383b1303c82731b130494c55bb375f6076ca 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_macros.h"
#include "base/stl_util.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/events/event.h"
@@ -46,6 +47,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
@@ -62,6 +64,26 @@ 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_state_ == RELEASED) {
+ search_key_state_ = PRESSED;
+ search_key_pressed_timestamp_ = base::TimeTicks::Now();
+ }
+
+ if (accelerator.key_code() != ui::KeyboardCode::VKEY_COMMAND &&
+ search_key_state_ == PRESSED) {
+ search_key_state_ = RECORDED;
+ UMA_HISTOGRAM_TIMES(
+ "Keyboard.Shortcuts.CrosSearchKeyDelay",
+ base::TimeTicks::Now() - search_key_pressed_timestamp_);
+ }
+ } else {
+ search_key_state_ = RELEASED;
+ }
+}
+
bool AcceleratorRouter::CanConsumeSystemKeys(WmWindow* target,
const ui::KeyEvent& event) {
// Uses the top level window so if the target is a web contents window the
« no previous file with comments | « ash/common/accelerators/accelerator_router.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698