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

[Autofill Assistant] Delay showing first message

If we catch a navigation while starting, we delay showing the message
until after the navigation is over.

Before this change, the delayed start was gated behind the
|kAutofillAssistantChromeEntry|. With other features relying on this
behaviour as well, the requirement has been lifted.

Bug: b/148844097
Change-Id: I34ac12b7f2d4ff9bd71f6e2145846634fbb6fbb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050275Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Cr-Commit-Position: refs/heads/master@{#741006}
parent d5f7eb30
......@@ -544,10 +544,6 @@ void Controller::EnterStoppedState() {
EnterState(AutofillAssistantState::STOPPED);
}
void Controller::EnterStateSilent(AutofillAssistantState state) {
EnterState(state);
}
bool Controller::EnterState(AutofillAssistantState state) {
if (state_ == state)
return false;
......@@ -944,21 +940,23 @@ bool Controller::Start(const GURL& deeplink_url,
if (state_ == AutofillAssistantState::TRACKING)
script_tracker_->ClearRunnableScripts();
SetStatusMessage(l10n_util::GetStringFUTF8(
IDS_AUTOFILL_ASSISTANT_LOADING, base::UTF8ToUTF16(deeplink_url_.host())));
SetProgress(kAutostartInitialProgress);
if (base::FeatureList::IsEnabled(features::kAutofillAssistantChromeEntry) &&
IsNavigatingToNewDocument()) {
start_after_navigation_ = base::BindOnce(&Controller::EnterStateSilent,
weak_ptr_factory_.GetWeakPtr(),
AutofillAssistantState::STARTING);
if (IsNavigatingToNewDocument()) {
start_after_navigation_ = base::BindOnce(
&Controller::ShowFirstMessageAndStart, weak_ptr_factory_.GetWeakPtr());
} else {
EnterState(AutofillAssistantState::STARTING);
ShowFirstMessageAndStart();
}
return true;
}
void Controller::ShowFirstMessageAndStart() {
SetStatusMessage(
l10n_util::GetStringFUTF8(IDS_AUTOFILL_ASSISTANT_LOADING,
base::UTF8ToUTF16(GetCurrentURL().host())));
SetProgress(kAutostartInitialProgress);
EnterState(AutofillAssistantState::STARTING);
}
AutofillAssistantState Controller::GetState() {
return state_;
}
......
......@@ -292,8 +292,8 @@ class Controller : public ScriptExecutorDelegate,
UserData::FieldChange field_change,
std::unique_ptr<autofill::AutofillProfile> profile);
// Enter step while ignoring the return value.
void EnterStateSilent(AutofillAssistantState state);
// Show the first "Opening..." message and enter START state.
void ShowFirstMessageAndStart();
// Clear out visible state and enter the stopped state.
void EnterStoppedState();
......
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