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

Side by Side Diff: ash/metrics/screen_event_task_switch_metric_recorder.cc

Issue 1153633006: Added UMA statistics for changing the active window via click or touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/metrics/screen_event_task_switch_metric_recorder.h"
6
7 #include "ash/metrics/user_metrics_recorder.h"
8 #include "ash/shell.h"
9 #include "ash/wm/mru_window_tracker.h"
10 #include "ui/wm/public/activation_client.h"
11
12 namespace ash {
13
14 namespace {
15
16 // Returns true if |window| is considered a task window.
17 bool IsATaskWindow(aura::Window* window) {
18 return Shell::GetInstance()
19 ->metrics()
20 ->task_switch_metrics_recorder()
21 .IsATaskWindow(window);
22 }
23
24 // Returns the last active task window if one exists or nullptr otherwise.
25 aura::Window* GetLastActiveTaskWindow() {
26 MruWindowTracker::WindowList window_list =
27 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList();
28 return window_list.empty() ? nullptr : window_list[0];
29 }
30
31 } // namespace
32
33 ScreenEventTaskSwitchMetricRecorder::ScreenEventTaskSwitchMetricRecorder(
34 UserMetricsRecorder* user_metrics_recorder)
35 : user_metrics_recorder_(user_metrics_recorder) {
36 }
37
38 ScreenEventTaskSwitchMetricRecorder::~ScreenEventTaskSwitchMetricRecorder() {
39 }
40
41 void ScreenEventTaskSwitchMetricRecorder::
42 BeforeWindowActivatedByPreTargetHandler() {
43 active_window_before_activation_ = GetLastActiveTaskWindow();
44 }
45
46 void ScreenEventTaskSwitchMetricRecorder::OnWindowActivatedByPreTargetHandler(
47 aura::Window* gained_active,
48 aura::Window* lost_active) {
49 if (IsATaskWindow(gained_active) &&
50 active_window_before_activation_ != gained_active) {
51 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
52 UMA_SCREEN_EVENT_SWITCH_TASK);
53 }
54 }
55
56 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698