Commit 2e2e0bfb authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

back nudge: add back nudge dimiss specific metrics.

Bug: 1061144
Change-Id: I1977fceb66746a6d56913b3cbb2b7c0551760681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135012Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756078}
parent d568e2f3
......@@ -31,7 +31,11 @@ enum class DismissNudgeReason {
kSwitchToClamshell = 3,
kExitToHomeScreen = 4,
kTimeout = 5,
kMaxValue = kTimeout,
kActiveWindowChanged = 6, // dismisses back gesture nudge
kNavigationEntryChanged = 7, // dismisses back gesture nudge
kBackGestureStarted = 8, // dismisses back gesture nudge
kUserSessionInactive = 9, // dismisses back gesture nudge
kMaxValue = kUserSessionInactive,
};
// Maximum number of times a user can be shown a contextual nudge if the user
......
......@@ -36,8 +36,12 @@ BackGestureContextualNudgeControllerImpl::
}
void BackGestureContextualNudgeControllerImpl::OnBackGestureStarted() {
if (nudge_)
if (nudge_) {
nudge_->CancelAnimationOrFadeOutToHide();
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kBackGestureStarted);
}
}
void BackGestureContextualNudgeControllerImpl::OnActiveUserSessionChanged(
......@@ -71,8 +75,12 @@ void BackGestureContextualNudgeControllerImpl::OnWindowActivated(
// If another window is activated when the nudge is waiting to be shown or
// is currently being shown, cancel the animation.
if (nudge_)
if (nudge_) {
nudge_->CancelAnimationOrFadeOutToHide();
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kActiveWindowChanged);
}
if (!nudge_ || !nudge_->ShouldNudgeCountAsShown()) {
// Start tracking |gained_active|'s navigation status and show the
......@@ -85,8 +93,12 @@ void BackGestureContextualNudgeControllerImpl::NavigationEntryChanged(
aura::Window* window) {
// If navigation entry changed when the nudge is waiting to be shown or is
// currently being shown, cancel the animation.
if (nudge_)
if (nudge_) {
nudge_->CancelAnimationOrFadeOutToHide();
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kNavigationEntryChanged);
}
MaybeShowNudgeUi(window);
}
......@@ -161,8 +173,24 @@ void BackGestureContextualNudgeControllerImpl::UpdateWindowMonitoring(
nudge_delegate_.reset();
Shell::Get()->activation_client()->RemoveObserver(this);
// Cancel any in-waiting animation or in-progress animation.
if (nudge_)
if (nudge_) {
nudge_->CancelAnimationOrFadeOutToHide();
if (!Shell::Get()->IsInTabletMode()) {
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kSwitchToClamshell);
} else if (Shell::Get()->session_controller()->GetSessionState() !=
session_manager::SessionState::ACTIVE) {
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kUserSessionInactive);
} else {
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kOther);
}
}
}
void BackGestureContextualNudgeControllerImpl::OnNudgeAnimationFinished() {
......@@ -177,6 +205,9 @@ void BackGestureContextualNudgeControllerImpl::OnNudgeAnimationFinished() {
if (count_as_shown) {
contextual_tooltip::HandleNudgeShown(
GetActivePrefService(), contextual_tooltip::TooltipType::kBackGesture);
contextual_tooltip::LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kBackGesture,
contextual_tooltip::DismissNudgeReason::kTimeout);
UpdateWindowMonitoring(/*can_show_nudge_immediately=*/false);
// Set a timer to monitoring windows and show nudge ui again.
......
......@@ -11148,6 +11148,10 @@ Called by update_net_error_codes.py.-->
<int value="3" label="kSwitchToClamshell"/>
<int value="4" label="kExitToHomeScreen"/>
<int value="5" label="kTimeout"/>
<int value="6" label="kActiveWindowChanged"/>
<int value="7" label="kNavigationEntryChanged"/>
<int value="8" label="kBackGestureStarted"/>
<int value="9" label="kUserSessionInactive"/>
</enum>
<enum name="ContextualSearchBarOverlapSeen">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment