1// Copyright (c) 2012 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_TOUCH_TOUCH_OBSERVER_UMA_H_ 6#define ASH_TOUCH_TOUCH_OBSERVER_UMA_H_ 7 8#include <map> 9 10#include "ash/shell.h" 11#include "base/memory/singleton.h" 12#include "ui/gfx/point.h" 13#include "ui/views/widget/widget.h" 14 15namespace aura { 16class Window; 17} 18 19namespace ash { 20 21// Records some touch/gesture event specific details (e.g. what gestures are 22// targetted to which components etc.) 23class ASH_EXPORT TouchUMA { 24 public: 25 enum GestureActionType { 26 GESTURE_UNKNOWN, 27 GESTURE_OMNIBOX_PINCH, 28 GESTURE_OMNIBOX_SCROLL, 29 GESTURE_TABSTRIP_PINCH, 30 GESTURE_TABSTRIP_SCROLL, 31 GESTURE_BEZEL_SCROLL, 32 GESTURE_DESKTOP_SCROLL, 33 GESTURE_DESKTOP_PINCH, 34 GESTURE_WEBPAGE_PINCH, 35 GESTURE_WEBPAGE_SCROLL, 36 GESTURE_WEBPAGE_TAP, 37 GESTURE_TABSTRIP_TAP, 38 GESTURE_BEZEL_DOWN, 39 GESTURE_TABSWITCH_TAP, 40 GESTURE_TABNOSWITCH_TAP, 41 GESTURE_TABCLOSE_TAP, 42 GESTURE_NEWTAB_TAP, 43 GESTURE_ROOTVIEWTOP_TAP, 44 GESTURE_FRAMEMAXIMIZE_TAP, 45 GESTURE_FRAMEVIEW_TAP, 46 GESTURE_MAXIMIZE_DOUBLETAP, 47 // NOTE: Add new action types only immediately above this line. Also, 48 // make sure the enum list in tools/histogram/histograms.xml is 49 // updated with any change in here. 50 GESTURE_ACTION_COUNT 51 }; 52 53 // Returns the singleton instance. 54 static TouchUMA* GetInstance(); 55 56 void RecordGestureEvent(aura::Window* target, 57 const ui::GestureEvent& event); 58 void RecordGestureAction(GestureActionType action); 59 void RecordTouchEvent(aura::Window* target, 60 const ui::TouchEvent& event); 61 62 private: 63 friend struct DefaultSingletonTraits<TouchUMA>; 64 65 TouchUMA(); 66 ~TouchUMA(); 67 68 void UpdateTouchState(const ui::TouchEvent& event); 69 GestureActionType FindGestureActionType(aura::Window* window, 70 const ui::GestureEvent& event); 71 72 bool is_single_finger_gesture_; 73 // These are used to measure the number of touch-start events we receive in a 74 // quick succession, regardless of the target window. 75 bool touch_in_progress_; 76 int burst_length_; 77 base::TimeDelta last_touch_down_time_; 78 79 DISALLOW_COPY_AND_ASSIGN(TouchUMA); 80}; 81 82} // namespace ash 83 84#endif // ASH_TOUCH_TOUCH_OBSERVER_UMA_H_ 85