| OLD | NEW |
| (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/desktop_task_switch_metric_recorder.h" | |
| 6 | |
| 7 #include "ash/metrics/user_metrics_recorder.h" | |
| 8 #include "ash/shell.h" | |
| 9 #include "ash/wm/window_util.h" | |
| 10 #include "ui/wm/public/activation_client.h" | |
| 11 | |
| 12 namespace ash { | |
| 13 | |
| 14 DesktopTaskSwitchMetricRecorder::DesktopTaskSwitchMetricRecorder() | |
| 15 : last_active_task_window_(nullptr) { | |
| 16 Shell::GetInstance()->activation_client()->AddObserver(this); | |
| 17 } | |
| 18 | |
| 19 DesktopTaskSwitchMetricRecorder::~DesktopTaskSwitchMetricRecorder() { | |
| 20 Shell::GetInstance()->activation_client()->RemoveObserver(this); | |
| 21 } | |
| 22 | |
| 23 void DesktopTaskSwitchMetricRecorder::OnWindowActivated( | |
| 24 aura::client::ActivationChangeObserver::ActivationReason reason, | |
| 25 aura::Window* gained_active, | |
| 26 aura::Window* lost_active) { | |
| 27 if (gained_active && wm::IsWindowUserPositionable(gained_active)) { | |
| 28 if (last_active_task_window_ != gained_active && | |
| 29 reason == aura::client::ActivationChangeObserver::ActivationReason:: | |
| 30 INPUT_EVENT) { | |
| 31 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | |
| 32 UMA_DESKTOP_SWITCH_TASK); | |
| 33 } | |
| 34 last_active_task_window_ = gained_active; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 } // namespace ash | |
| OLD | NEW |