| Index: ash/touch/touch_uma.cc
|
| diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc
|
| index 663a319961a1b784956c24b9ee6c202bb979f57f..473124413a1d0886eee998ce8092efed9d772708 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()) {
|
| @@ -267,6 +181,11 @@ TouchUMA::TouchUMA()
|
| TouchUMA::~TouchUMA() {
|
| }
|
|
|
| +// static
|
| +TouchUMA* TouchUMA::GetInstance() {
|
| + return Singleton<TouchUMA>::get();
|
| +}
|
| +
|
| void TouchUMA::RecordGestureEvent(aura::Window* target,
|
| const ui::GestureEvent& event) {
|
| UMA_HISTOGRAM_ENUMERATION("Ash.GestureCreated",
|
| @@ -274,11 +193,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 +207,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",
|
| @@ -445,5 +367,73 @@ void TouchUMA::UpdateBurstData(const ui::TouchEvent& event) {
|
| }
|
| }
|
|
|
| +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 internal
|
| } // namespace ash
|
|
|