| 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 #ifndef ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_ | |
| 6 #define ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #include "ash/shelf/shelf_item_delegate.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/time/tick_clock.h" | |
| 14 #include "base/time/time.h" | |
| 15 #include "ui/events/event.h" | |
| 16 | |
| 17 namespace views { | |
| 18 class Button; | |
| 19 } // namespace views | |
| 20 | |
| 21 namespace ash { | |
| 22 | |
| 23 namespace test { | |
| 24 class ShelfButtonPressedMetricTrackerTestAPI; | |
| 25 } // namespace test | |
| 26 | |
| 27 // Tracks UMA metrics based on shelf button press actions. More specifically | |
| 28 // data is added to the following user actions and histograms: | |
| 29 // | |
| 30 // User Actions: | |
| 31 // - Launcher_ButtonPressed_Mouse | |
| 32 // - Launcher_ButtonPressed_Touch | |
| 33 // - Launcher_LaunchTask | |
| 34 // - Launcher_MinimizeTask | |
| 35 // - Launcher_SwitchTask | |
| 36 // Histograms: | |
| 37 // - Ash.Shelf.TimeBetweenWindowMinimizedAndActivatedActions | |
| 38 // | |
| 39 class ASH_EXPORT ShelfButtonPressedMetricTracker { | |
| 40 public: | |
| 41 static const char | |
| 42 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName[]; | |
| 43 | |
| 44 ShelfButtonPressedMetricTracker(); | |
| 45 ~ShelfButtonPressedMetricTracker(); | |
| 46 | |
| 47 // Records metrics based on the |event|, |sender|, and |performed_action|. | |
| 48 void ButtonPressed(const ui::Event& event, | |
| 49 const views::Button* sender, | |
| 50 ShelfAction performed_action); | |
| 51 | |
| 52 private: | |
| 53 friend class test::ShelfButtonPressedMetricTrackerTestAPI; | |
| 54 | |
| 55 // Records UMA metrics for the input source when a button is pressed. | |
| 56 void RecordButtonPressedSource(const ui::Event& event); | |
| 57 | |
| 58 // Records UMA metrics for the action performed when a button is pressed. | |
| 59 void RecordButtonPressedAction(ShelfAction performed_action); | |
| 60 | |
| 61 // Records UMA metrics for the elapsed time since the last window minimize | |
| 62 // action. | |
| 63 void RecordTimeBetweenMinimizedAndActivated(); | |
| 64 | |
| 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; | |
| 68 | |
| 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); | |
| 72 | |
| 73 // Resets the state data associated with the last window minimize action. | |
| 74 void ResetMinimizedData(); | |
| 75 | |
| 76 // Time source for performed action times. | |
| 77 std::unique_ptr<base::TickClock> tick_clock_; | |
| 78 | |
| 79 // Stores the time of the last window minimize action. | |
| 80 base::TimeTicks time_of_last_minimize_; | |
| 81 | |
| 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_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(ShelfButtonPressedMetricTracker); | |
| 87 }; | |
| 88 | |
| 89 } // namespace ash | |
| 90 | |
| 91 #endif // ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_ | |
| OLD | NEW |