Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / shelf / shelf_button_pressed_metric_tracker.h
blobf64d8511a582688bd1486a84d5a7f6559b891f89
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.
5 #ifndef ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
6 #define ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
8 #include "ash/ash_export.h"
9 #include "ash/shelf/shelf_item_delegate.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/tick_clock.h"
13 #include "base/time/time.h"
14 #include "ui/events/event.h"
16 namespace views {
17 class Button;
18 } // namespace views
20 namespace ash {
22 namespace test {
23 class ShelfButtonPressedMetricTrackerTestAPI;
24 } // namespace test
26 // Tracks UMA metrics based on shelf button press actions. More specifically
27 // data is added to the following user actions and histograms:
29 // User Actions:
30 // - Launcher_ButtonPressed_Mouse
31 // - Launcher_ButtonPressed_Touch
32 // - Launcher_LaunchTask
33 // - Launcher_MinimizeTask
34 // - Launcher_SwitchTask
35 // Histograms:
36 // - Ash.Shelf.TimeBetweenWindowMinimizedAndActivatedActions
38 class ASH_EXPORT ShelfButtonPressedMetricTracker {
39 public:
40 static const char
41 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName[];
43 ShelfButtonPressedMetricTracker();
44 ~ShelfButtonPressedMetricTracker();
46 // Records metrics based on the |event|, |sender|, and |performed_action|.
47 void ButtonPressed(const ui::Event& event,
48 const views::Button* sender,
49 ShelfItemDelegate::PerformedAction performed_action);
51 private:
52 friend class test::ShelfButtonPressedMetricTrackerTestAPI;
54 // Records UMA metrics for the input source when a button is pressed.
55 void RecordButtonPressedSource(const ui::Event& event);
57 // Records UMA metrics for the action performed when a button is pressed.
58 void RecordButtonPressedAction(
59 ShelfItemDelegate::PerformedAction performed_action);
61 // Records UMA metrics for the elapsed time since the last window minimize
62 // action.
63 void RecordTimeBetweenMinimizedAndActivated();
65 // Returns true if a window activation action triggered by |sender| would
66 // be subsequent to the last minimize window action.
67 bool IsSubsequentActivationEvent(const views::Button* sender) const;
69 // Caches state data for a window minimized action. The |sender| is the button
70 // that caused the action.
71 void SetMinimizedData(const views::Button* sender);
73 // Resets the state data associated with the last window minimize action.
74 void ResetMinimizedData();
76 // Time source for performed action times.
77 scoped_ptr<base::TickClock> tick_clock_;
79 // Stores the time of the last window minimize action.
80 base::TimeTicks time_of_last_minimize_;
82 // Stores the source button of the last window minimize action.
83 // NOTE: This may become stale and should not be operated on. Not owned.
84 const views::Button* last_minimized_source_button_;
86 DISALLOW_COPY_AND_ASSIGN(ShelfButtonPressedMetricTracker);
89 } // namespace ash
91 #endif // ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_