Commit 41193401 authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Adding dropout reason for back button

This adds a new dropout reason for clicking the back button.

Bug: b/152954282
Change-Id: Id84e7d6bcdd0b76640157ba793be37d49ddc4db7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218122
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Cr-Commit-Position: refs/heads/master@{#773186}
parent 14f12b97
......@@ -96,8 +96,9 @@ class AssistantOnboardingCoordinator {
overlayModel.set(AssistantOverlayModel.STATE, AssistantOverlayState.FULL);
mContent = new AssistantBottomSheetContent(mContext, () -> {
callback.onResult(/* accept= */ false);
hide();
onUserAction(
/* accept= */ false, callback, OnBoarding.OB_NO_ANSWER,
DropOutReason.ONBOARDING_BACK_BUTTON_CLICKED);
return true;
});
initContent(callback);
......@@ -183,21 +184,27 @@ class AssistantOnboardingCoordinator {
initView.setFocusable(true);
initView.findViewById(R.id.button_init_ok)
.setOnClickListener(unusedView -> onClicked(true, callback));
.setOnClickListener(unusedView
-> onUserAction(
/* accept= */ true, callback, OnBoarding.OB_ACCEPTED,
DropOutReason.DECLINED));
initView.findViewById(R.id.button_init_not_ok)
.setOnClickListener(unusedView -> onClicked(false, callback));
.setOnClickListener(unusedView
-> onUserAction(
/* accept= */ false, callback, OnBoarding.OB_CANCELLED,
DropOutReason.DECLINED));
updateViewBasedOnIntent(initView);
mContent.setContent(initView, initView);
}
private void onClicked(boolean accept, Callback<Boolean> callback) {
private void onUserAction(boolean accept, Callback<Boolean> callback,
@OnBoarding int onboardingAnswer, @DropOutReason int dropoutReason) {
AutofillAssistantPreferencesUtil.setInitialPreferences(accept);
AutofillAssistantMetrics.recordOnBoarding(
accept ? OnBoarding.OB_ACCEPTED : OnBoarding.OB_CANCELLED);
AutofillAssistantMetrics.recordOnBoarding(onboardingAnswer);
if (!accept) {
AutofillAssistantMetrics.recordDropOut(DropOutReason.DECLINED);
AutofillAssistantMetrics.recordDropOut(dropoutReason);
}
callback.onResult(accept);
......
......@@ -359,7 +359,8 @@ bool ClientAndroid::PerformDirectAction(
// always available, even if no action was found and action_index == -1.
if (action_name == kCancelActionName && ui_controller_android_) {
ui_controller_android_->CloseOrCancel(action_index,
std::move(trigger_context));
std::move(trigger_context),
Metrics::DropOutReason::SHEET_CLOSED);
return true;
}
......
......@@ -716,9 +716,11 @@ void UiControllerAndroid::OnCancelButtonClicked(
// chip will be displayed right above the keyboard.
if (Java_AutofillAssistantUiController_isKeyboardShown(env, java_object_)) {
Java_AutofillAssistantUiController_hideKeyboard(env, java_object_);
} else {
CloseOrCancel(index, TriggerContext::CreateEmpty());
return;
}
CloseOrCancel(index, TriggerContext::CreateEmpty(),
Metrics::DropOutReason::SHEET_CLOSED);
}
void UiControllerAndroid::OnCloseButtonClicked(
......@@ -755,13 +757,15 @@ bool UiControllerAndroid::OnBackButtonClicked(
return false;
}
CloseOrCancel(-1, TriggerContext::CreateEmpty());
CloseOrCancel(-1, TriggerContext::CreateEmpty(),
Metrics::DropOutReason::BACK_BUTTON_CLICKED);
return true;
}
void UiControllerAndroid::CloseOrCancel(
int action_index,
std::unique_ptr<TriggerContext> trigger_context) {
std::unique_ptr<TriggerContext> trigger_context,
Metrics::DropOutReason dropout_reason) {
// Close immediately.
if (!ui_delegate_ ||
ui_delegate_->GetState() == AutofillAssistantState::STOPPED) {
......@@ -784,16 +788,17 @@ void UiControllerAndroid::CloseOrCancel(
l10n_util::GetStringUTF8(IDS_AUTOFILL_ASSISTANT_STOPPED),
base::BindOnce(&UiControllerAndroid::OnCancel,
weak_ptr_factory_.GetWeakPtr(), action_index,
std::move(trigger_context)));
std::move(trigger_context), dropout_reason));
}
void UiControllerAndroid::OnCancel(
int action_index,
std::unique_ptr<TriggerContext> trigger_context) {
std::unique_ptr<TriggerContext> trigger_context,
Metrics::DropOutReason dropout_reason) {
if (action_index == -1 || !ui_delegate_ ||
!ui_delegate_->PerformUserActionWithContext(action_index,
std::move(trigger_context))) {
Shutdown(Metrics::DropOutReason::SHEET_CLOSED);
Shutdown(dropout_reason);
}
}
......
......@@ -85,7 +85,8 @@ class UiControllerAndroid : public ControllerObserver {
// If action_index != -1, execute that action as close/cancel. Otherwise
// execute the default close or cancel action.
void CloseOrCancel(int action_index,
std::unique_ptr<TriggerContext> trigger_context);
std::unique_ptr<TriggerContext> trigger_context,
Metrics::DropOutReason dropout_reason);
// Overrides UiController:
void OnStateChanged(AutofillAssistantState new_state) override;
......@@ -237,7 +238,9 @@ class UiControllerAndroid : public ControllerObserver {
const std::string& message,
base::OnceCallback<void()> action);
void OnCancel(int action_index, std::unique_ptr<TriggerContext> context);
void OnCancel(int action_index,
std::unique_ptr<TriggerContext> context,
Metrics::DropOutReason dropout_reason);
// Updates the state of the UI to reflect the UIDelegate's state.
void SetupForState();
......
......@@ -45,8 +45,10 @@ class Metrics {
NO_INITIAL_SCRIPTS = 19,
DFM_INSTALL_FAILED = 20,
DOMAIN_CHANGE_DURING_BROWSE_MODE = 21,
BACK_BUTTON_CLICKED = 22,
ONBOARDING_BACK_BUTTON_CLICKED = 23,
kMaxValue = DOMAIN_CHANGE_DURING_BROWSE_MODE
kMaxValue = ONBOARDING_BACK_BUTTON_CLICKED
};
// The different ways that autofill assistant can stop.
......@@ -64,8 +66,9 @@ class Metrics {
OB_NOT_SHOWN = 1,
OB_ACCEPTED = 2,
OB_CANCELLED = 3,
OB_NO_ANSWER = 4,
kMaxValue = OB_CANCELLED
kMaxValue = OB_NO_ANSWER
};
// The different ways for payment request to succeed or fail, broken down by
......@@ -222,6 +225,12 @@ class Metrics {
case DropOutReason::DOMAIN_CHANGE_DURING_BROWSE_MODE:
out << "DOMAIN_CHANGE_DURING_BROWSE_MODE";
break;
case DropOutReason::BACK_BUTTON_CLICKED:
out << "BACK_BUTTON_CLICKED";
break;
case DropOutReason::ONBOARDING_BACK_BUTTON_CLICKED:
out << "ONBOARDING_BACK_BUTTON_CLICKED";
break;
// Do not add default case to force compilation error for new values.
}
return out;
......@@ -249,6 +258,9 @@ class Metrics {
case OnBoarding::OB_CANCELLED:
out << "OB_CANCELLED";
break;
case OnBoarding::OB_NO_ANSWER:
out << "OB_NO_ANSWER";
break;
// Do not add default case to force compilation error for new values.
}
return out;
......
......@@ -4145,6 +4145,8 @@ Unknown properties are collapsed to zero. -->
<int value="19" label="No initial scripts"/>
<int value="20" label="Installing the feature module failed"/>
<int value="21" label="User navigation to a different domain in BROWSE mode"/>
<int value="22" label="User clicked back button"/>
<int value="23" label="User clicked back button during onboarding"/>
</enum>
<enum name="AutofillAssistantFeatureModuleInstallation">
......@@ -4159,6 +4161,7 @@ Unknown properties are collapsed to zero. -->
<int value="1" label="Not shown (returning user)"/>
<int value="2" label="Accepted"/>
<int value="3" label="Cancelled"/>
<int value="4" label="No answer, defaults to not accepted"/>
</enum>
<enum name="AutofillAssistantPaymentRequestAutofillInfoChanged">
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