Index: content/browser/web_contents/aura/gesture_nav_simple.cc |
diff --git a/content/browser/web_contents/aura/gesture_nav_simple.cc b/content/browser/web_contents/aura/gesture_nav_simple.cc |
index ef727276f381b452bd1050fb611a6bfc64eac8b8..0ed4576a5d0417dc6d72df3db4e8c4453766c6f9 100644 |
--- a/content/browser/web_contents/aura/gesture_nav_simple.cc |
+++ b/content/browser/web_contents/aura/gesture_nav_simple.cc |
@@ -7,6 +7,8 @@ |
#include <utility> |
#include "base/macros.h" |
+#include "base/metrics/histogram_macros.h" |
+#include "base/metrics/user_metrics.h" |
#include "cc/paint/paint_flags.h" |
#include "components/vector_icons/vector_icons.h" |
#include "content/browser/frame_host/navigation_controller_impl.h" |
@@ -80,6 +82,17 @@ bool ShouldNavigateBack(const NavigationController& controller, |
controller.CanGoBack(); |
} |
+// Records UMA historgram and also user action for the cancelled overscroll. |
+void RecordCancelled(NavigationDirection direction, OverscrollSource source) { |
+ UMA_HISTOGRAM_ENUMERATION("Overscroll.Cancelled3", |
+ GetUmaNavigationType(direction, source), |
+ NAVIGATION_TYPE_COUNT); |
+ if (direction == NavigationDirection::BACK) |
+ RecordAction(base::UserMetricsAction("Overscroll_Cancelled.Back")); |
+ else |
+ RecordAction(base::UserMetricsAction("Overscroll_Cancelled.Forward")); |
+} |
+ |
} // namespace |
// This class is responsible for creating, painting, and positioning the layer |
@@ -391,23 +404,56 @@ void GestureNavSimple::OnOverscrollComplete(OverscrollMode overscroll_mode) { |
CompleteGestureAnimation(); |
NavigationControllerImpl& controller = web_contents_->GetController(); |
- if (ShouldNavigateForward(controller, overscroll_mode)) |
+ bool navigated = false; |
+ if (ShouldNavigateForward(controller, overscroll_mode)) { |
controller.GoForward(); |
- else if (ShouldNavigateBack(controller, overscroll_mode)) |
+ navigated = true; |
+ } else if (ShouldNavigateBack(controller, overscroll_mode)) { |
controller.GoBack(); |
+ navigated = true; |
+ } |
+ |
+ if (navigated) { |
+ UMA_HISTOGRAM_ENUMERATION("Overscroll.Navigated3", |
+ GetUmaNavigationType(direction_, source_), |
+ UmaNavigationType::NAVIGATION_TYPE_COUNT); |
+ if (direction_ == NavigationDirection::BACK) |
+ RecordAction(base::UserMetricsAction("Overscroll_Navigated.Back")); |
+ else |
+ RecordAction(base::UserMetricsAction("Overscroll_Navigated.Forward")); |
+ } else { |
+ RecordCancelled(direction_, source_); |
+ } |
+ |
+ direction_ = NavigationDirection::NONE; |
+ source_ = OverscrollSource::NONE; |
} |
void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode, |
OverscrollMode new_mode, |
OverscrollSource source) { |
NavigationControllerImpl& controller = web_contents_->GetController(); |
- if (!ShouldNavigateForward(controller, new_mode) && |
- !ShouldNavigateBack(controller, new_mode)) { |
+ if (ShouldNavigateForward(controller, new_mode)) { |
+ direction_ = NavigationDirection::FORWARD; |
+ } else if (ShouldNavigateBack(controller, new_mode)) { |
+ direction_ = NavigationDirection::BACK; |
+ } else { |
+ // If there is an overscoll in progress - record its cancellation. |
+ if (direction_ != NavigationDirection::NONE) |
+ RecordCancelled(direction_, source_); |
+ direction_ = NavigationDirection::NONE; |
+ source_ = OverscrollSource::NONE; |
AbortGestureAnimation(); |
return; |
} |
DCHECK_NE(source, OverscrollSource::NONE); |
+ source_ = source; |
+ |
+ UMA_HISTOGRAM_ENUMERATION("Overscroll.Started3", |
+ GetUmaNavigationType(direction_, source_), |
+ UmaNavigationType::NAVIGATION_TYPE_COUNT); |
+ |
const float start_threshold = GetOverscrollConfig( |
source == OverscrollSource::TOUCHPAD |
? OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD |