diff options
author | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-29 01:44:35 +0000 |
---|---|---|
committer | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-29 01:44:35 +0000 |
commit | c146a323f91c8376afe55c93c6a31df0075be62b (patch) | |
tree | ce354d74ecacdeaf81199bb5c6b8a8231d668284 /ash | |
parent | 9c1df29797fa40a1902b21435960710c16ec619c (diff) | |
download | chromium_src-c146a323f91c8376afe55c93c6a31df0075be62b.zip chromium_src-c146a323f91c8376afe55c93c6a31df0075be62b.tar.gz chromium_src-c146a323f91c8376afe55c93c6a31df0075be62b.tar.bz2 |
Add UMA metrics to measure the effectiveness of views fuzzing
Add new buckets to the Ash.GestureTarget histogram which
will be useful in measuring the effectiveness of views
fuzzing when it is implemented. The idea is to count taps
made on the different element types located on/near the
tab strip. A description of the new types added to
GestureActionType in touch_uma.cc:
GESTURE_TABSWITCH_TAP: A tap on a currently unselected
tab (i.e., the tap was responsible for selecting the tab).
GESTURE_TABNOSWITCH_TAP: A tap on a currently selected
tab (i.e, the tap had no visible effect).
GESTURE_TABCLOSE_TAP: A tap on a tab's close button.
GESTURE_NEWTAB_TAP: A tap on the new tab button.
GESTURE_FRAMEMAXIMIZE_TAP: A tap on the frame maximize
button.
GESTURE_FRAMEVIEW_TAP: A tap on the space to the right of
the tabstrip, left of the tabstrip, or in between tabs.
Such a tap has no visible effect.
GESTURE_ROOTVIEWTOP_TAP: A tap on the top edge of a browser
window. Such a tap has no visible effect.
GESTURE_MAXIMIZE_DOUBLETAP: A double-tap on the browser
window resulting in a maximize or restore action.
BUG=248230
Review URL: https://chromiumcodereview.appspot.com/16832003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209263 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/touch/touch_uma.cc | 186 | ||||
-rw-r--r-- | ash/touch/touch_uma.h | 45 | ||||
-rw-r--r-- | ash/wm/system_gesture_event_filter.cc | 4 | ||||
-rw-r--r-- | ash/wm/system_gesture_event_filter.h | 2 | ||||
-rw-r--r-- | ash/wm/workspace/frame_maximize_button.cc | 6 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_event_handler.cc | 22 |
6 files changed, 150 insertions, 115 deletions
diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc index 663a319..f8ab0f1 100644 --- a/ash/touch/touch_uma.cc +++ b/ash/touch/touch_uma.cc @@ -22,26 +22,6 @@ namespace { -enum GestureActionType { - GESTURE_UNKNOWN, - GESTURE_OMNIBOX_PINCH, - GESTURE_OMNIBOX_SCROLL, - GESTURE_TABSTRIP_PINCH, - GESTURE_TABSTRIP_SCROLL, - GESTURE_BEZEL_SCROLL, - GESTURE_DESKTOP_SCROLL, - GESTURE_DESKTOP_PINCH, - GESTURE_WEBPAGE_PINCH, - GESTURE_WEBPAGE_SCROLL, - GESTURE_WEBPAGE_TAP, - GESTURE_TABSTRIP_TAP, - GESTURE_BEZEL_DOWN, -// NOTE: Add new action types only immediately above this line. Also, make sure -// the enum list in tools/histogram/histograms.xml is updated with any change in -// here. - GESTURE_ACTION_COUNT -}; - enum UMAEventType { UMA_ET_UNKNOWN, UMA_ET_TOUCH_RELEASED, @@ -102,72 +82,6 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowTouchDetails, kWindowTouchDetails, NULL); -GestureActionType FindGestureActionType(aura::Window* window, - const ui::GestureEvent& event) { - if (!window || window->GetRootWindow() == window) { - if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) - return GESTURE_BEZEL_SCROLL; - if (event.type() == ui::ET_GESTURE_BEGIN) - return GESTURE_BEZEL_DOWN; - return GESTURE_UNKNOWN; - } - - std::string name = window ? window->name() : std::string(); - - const char kDesktopBackgroundView[] = "DesktopBackgroundView"; - if (name == kDesktopBackgroundView) { - if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) - return GESTURE_DESKTOP_SCROLL; - if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) - return GESTURE_DESKTOP_PINCH; - return GESTURE_UNKNOWN; - } - - const char kWebPage[] = "RenderWidgetHostViewAura"; - if (name == kWebPage) { - if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) - return GESTURE_WEBPAGE_PINCH; - if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) - return GESTURE_WEBPAGE_SCROLL; - if (event.type() == ui::ET_GESTURE_TAP) - return GESTURE_WEBPAGE_TAP; - return GESTURE_UNKNOWN; - } - - views::Widget* widget = views::Widget::GetWidgetForNativeView(window); - if (!widget) - return GESTURE_UNKNOWN; - - views::View* view = widget->GetRootView()-> - GetEventHandlerForPoint(event.location()); - if (!view) - return GESTURE_UNKNOWN; - - name = view->GetClassName(); - - const char kTabStrip[] = "TabStrip"; - const char kTab[] = "BrowserTab"; - if (name == kTabStrip || name == kTab) { - if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) - return GESTURE_TABSTRIP_SCROLL; - if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) - return GESTURE_TABSTRIP_PINCH; - if (event.type() == ui::ET_GESTURE_TAP) - return GESTURE_TABSTRIP_TAP; - return GESTURE_UNKNOWN; - } - - const char kOmnibox[] = "BrowserOmniboxViewViews"; - if (name == kOmnibox) { - if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) - return GESTURE_OMNIBOX_SCROLL; - if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) - return GESTURE_OMNIBOX_PINCH; - return GESTURE_UNKNOWN; - } - - return GESTURE_UNKNOWN; -} UMAEventType UMAEventTypeFromEvent(const ui::Event& event) { switch (event.type()) { @@ -257,14 +171,10 @@ UMAEventType UMAEventTypeFromEvent(const ui::Event& event) { } namespace ash { -namespace internal { -TouchUMA::TouchUMA() - : touch_in_progress_(false), - burst_length_(0) { -} - -TouchUMA::~TouchUMA() { +// static +TouchUMA* TouchUMA::GetInstance() { + return Singleton<TouchUMA>::get(); } void TouchUMA::RecordGestureEvent(aura::Window* target, @@ -274,11 +184,7 @@ void TouchUMA::RecordGestureEvent(aura::Window* target, UMA_ET_COUNT); GestureActionType action = FindGestureActionType(target, event); - if (action != GESTURE_UNKNOWN) { - UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget", - action, - GESTURE_ACTION_COUNT); - } + RecordGestureAction(action); if (event.type() == ui::ET_GESTURE_END && event.details().touch_points() == 2) { @@ -292,6 +198,13 @@ void TouchUMA::RecordGestureEvent(aura::Window* target, } } +void TouchUMA::RecordGestureAction(GestureActionType action) { + if (action == GESTURE_UNKNOWN || action >= GESTURE_ACTION_COUNT) + return; + UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget", action, + GESTURE_ACTION_COUNT); +} + void TouchUMA::RecordTouchEvent(aura::Window* target, const ui::TouchEvent& event) { UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchRadius", @@ -423,6 +336,14 @@ void TouchUMA::RecordTouchEvent(aura::Window* target, } } +TouchUMA::TouchUMA() + : touch_in_progress_(false), + burst_length_(0) { +} + +TouchUMA::~TouchUMA() { +} + void TouchUMA::UpdateBurstData(const ui::TouchEvent& event) { if (event.type() == ui::ET_TOUCH_PRESSED) { if (!touch_in_progress_) { @@ -445,5 +366,72 @@ void TouchUMA::UpdateBurstData(const ui::TouchEvent& event) { } } -} // namespace internal +TouchUMA::GestureActionType TouchUMA::FindGestureActionType( + aura::Window* window, + const ui::GestureEvent& event) { + if (!window || window->GetRootWindow() == window) { + if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) + return GESTURE_BEZEL_SCROLL; + if (event.type() == ui::ET_GESTURE_BEGIN) + return GESTURE_BEZEL_DOWN; + return GESTURE_UNKNOWN; + } + + std::string name = window ? window->name() : std::string(); + + const char kDesktopBackgroundView[] = "DesktopBackgroundView"; + if (name == kDesktopBackgroundView) { + if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) + return GESTURE_DESKTOP_SCROLL; + if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) + return GESTURE_DESKTOP_PINCH; + return GESTURE_UNKNOWN; + } + + const char kWebPage[] = "RenderWidgetHostViewAura"; + if (name == kWebPage) { + if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) + return GESTURE_WEBPAGE_PINCH; + if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) + return GESTURE_WEBPAGE_SCROLL; + if (event.type() == ui::ET_GESTURE_TAP) + return GESTURE_WEBPAGE_TAP; + return GESTURE_UNKNOWN; + } + + views::Widget* widget = views::Widget::GetWidgetForNativeView(window); + if (!widget) + return GESTURE_UNKNOWN; + + views::View* view = widget->GetRootView()-> + GetEventHandlerForPoint(event.location()); + if (!view) + return GESTURE_UNKNOWN; + + name = view->GetClassName(); + + const char kTabStrip[] = "TabStrip"; + const char kTab[] = "BrowserTab"; + if (name == kTabStrip || name == kTab) { + if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) + return GESTURE_TABSTRIP_SCROLL; + if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) + return GESTURE_TABSTRIP_PINCH; + if (event.type() == ui::ET_GESTURE_TAP) + return GESTURE_TABSTRIP_TAP; + return GESTURE_UNKNOWN; + } + + const char kOmnibox[] = "BrowserOmniboxViewViews"; + if (name == kOmnibox) { + if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) + return GESTURE_OMNIBOX_SCROLL; + if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) + return GESTURE_OMNIBOX_PINCH; + return GESTURE_UNKNOWN; + } + + return GESTURE_UNKNOWN; +} + } // namespace ash diff --git a/ash/touch/touch_uma.h b/ash/touch/touch_uma.h index 46805b1..3e2c7fd 100644 --- a/ash/touch/touch_uma.h +++ b/ash/touch/touch_uma.h @@ -8,6 +8,7 @@ #include <map> #include "ash/shell.h" +#include "base/memory/singleton.h" #include "ui/gfx/point.h" #include "ui/views/widget/widget.h" @@ -16,22 +17,57 @@ class Window; } namespace ash { -namespace internal { // Records some touch/gesture event specific details (e.g. what gestures are // targetted to which components etc.) -class TouchUMA { +class ASH_EXPORT TouchUMA { public: - TouchUMA(); - ~TouchUMA(); + enum GestureActionType { + GESTURE_UNKNOWN, + GESTURE_OMNIBOX_PINCH, + GESTURE_OMNIBOX_SCROLL, + GESTURE_TABSTRIP_PINCH, + GESTURE_TABSTRIP_SCROLL, + GESTURE_BEZEL_SCROLL, + GESTURE_DESKTOP_SCROLL, + GESTURE_DESKTOP_PINCH, + GESTURE_WEBPAGE_PINCH, + GESTURE_WEBPAGE_SCROLL, + GESTURE_WEBPAGE_TAP, + GESTURE_TABSTRIP_TAP, + GESTURE_BEZEL_DOWN, + GESTURE_TABSWITCH_TAP, + GESTURE_TABNOSWITCH_TAP, + GESTURE_TABCLOSE_TAP, + GESTURE_NEWTAB_TAP, + GESTURE_ROOTVIEWTOP_TAP, + GESTURE_FRAMEMAXIMIZE_TAP, + GESTURE_FRAMEVIEW_TAP, + GESTURE_MAXIMIZE_DOUBLETAP, + // NOTE: Add new action types only immediately above this line. Also, + // make sure the enum list in tools/histogram/histograms.xml is + // updated with any change in here. + GESTURE_ACTION_COUNT + }; + + // Returns the singleton instance. + static TouchUMA* GetInstance(); void RecordGestureEvent(aura::Window* target, const ui::GestureEvent& event); + void RecordGestureAction(GestureActionType action); void RecordTouchEvent(aura::Window* target, const ui::TouchEvent& event); private: + friend struct DefaultSingletonTraits<TouchUMA>; + + TouchUMA(); + ~TouchUMA(); + void UpdateBurstData(const ui::TouchEvent& event); + GestureActionType FindGestureActionType(aura::Window* window, + const ui::GestureEvent& event); // These are used to measure the number of touch-start events we receive in a // quick succession, regardless of the target window. @@ -42,7 +78,6 @@ class TouchUMA { DISALLOW_COPY_AND_ASSIGN(TouchUMA); }; -} // namespace internal } // namespace ash #endif // ASH_TOUCH_TOUCH_OBSERVER_UMA_H_ diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc index c20b082..b368822 100644 --- a/ash/wm/system_gesture_event_filter.cc +++ b/ash/wm/system_gesture_event_filter.cc @@ -64,13 +64,13 @@ void SystemGestureEventFilter::OnMouseEvent(ui::MouseEvent* event) { void SystemGestureEventFilter::OnTouchEvent(ui::TouchEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); - touch_uma_.RecordTouchEvent(target, *event); + ash::TouchUMA::GetInstance()->RecordTouchEvent(target, *event); long_press_affordance_->ProcessEvent(target, event, event->touch_id()); } void SystemGestureEventFilter::OnGestureEvent(ui::GestureEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); - touch_uma_.RecordGestureEvent(target, *event); + ash::TouchUMA::GetInstance()->RecordGestureEvent(target, *event); long_press_affordance_->ProcessEvent(target, event, event->GetLowestTouchId()); diff --git a/ash/wm/system_gesture_event_filter.h b/ash/wm/system_gesture_event_filter.h index 8aaabec..a2a5c73 100644 --- a/ash/wm/system_gesture_event_filter.h +++ b/ash/wm/system_gesture_event_filter.h @@ -69,8 +69,6 @@ class SystemGestureEventFilter : public ui::EventHandler, scoped_ptr<LongPressAffordanceHandler> long_press_affordance_; scoped_ptr<TwoFingerDragHandler> two_finger_drag_; - TouchUMA touch_uma_; - DISALLOW_COPY_AND_ASSIGN(SystemGestureEventFilter); }; diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc index 0329e3f..23ca750 100644 --- a/ash/wm/workspace/frame_maximize_button.cc +++ b/ash/wm/workspace/frame_maximize_button.cc @@ -9,6 +9,7 @@ #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/shell_delegate.h" +#include "ash/touch/touch_uma.h" #include "ash/wm/maximize_bubble_controller.h" #include "ash/wm/property_util.h" #include "ash/wm/window_properties.h" @@ -279,8 +280,11 @@ void FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) { // for TAP and SCROLL_END). So it is necessary to update the snap-state for // the current event. ProcessUpdateEvent(*event); - if (event->type() == ui::ET_GESTURE_TAP) + if (event->type() == ui::ET_GESTURE_TAP) { snap_type_ = SnapTypeForLocation(event->location()); + TouchUMA::GetInstance()->RecordGestureAction( + TouchUMA::GESTURE_FRAMEMAXIMIZE_TAP); + } ProcessEndEvent(*event); event->SetHandled(); return; diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc index 828f024..6bf384c 100644 --- a/ash/wm/workspace/workspace_event_handler.cc +++ b/ash/wm/workspace/workspace_event_handler.cc @@ -7,6 +7,7 @@ #include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_delegate.h" +#include "ash/touch/touch_uma.h" #include "ash/wm/coordinate_conversion.h" #include "ash/wm/property_util.h" #include "ash/wm/window_util.h" @@ -119,14 +120,23 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); if (event->type() == ui::ET_GESTURE_TAP && - event->details().tap_count() == 2 && target->delegate()->GetNonClientComponent(event->location()) == HTCAPTION) { - ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction( - ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); - ToggleMaximizedState(target); // |this| may be destroyed from here. - event->StopPropagation(); - return; + if (event->details().tap_count() == 2) { + ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction( + ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); + // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice each time + // TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP is counted once. + TouchUMA::GetInstance()->RecordGestureAction( + TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP); + ToggleMaximizedState(target); // |this| may be destroyed from here. + event->StopPropagation(); + return; + } else { + // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap. + TouchUMA::GetInstance()->RecordGestureAction( + TouchUMA::GESTURE_FRAMEVIEW_TAP); + } } ToplevelWindowEventHandler::OnGestureEvent(event); } |