Commit 4845b47a authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Avoid showing error message in lite scripts.

Bug: b/166429363
Change-Id: Ib20ad349a2f1e5efe5e1d6171ddee9563c7cb125
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377491Reviewed-by: default avatarLuca Hunkeler <hluca@google.com>
Commit-Queue: Luca Hunkeler <hluca@google.com>
Auto-Submit: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#801807}
parent bdd9ecc4
......@@ -1527,9 +1527,14 @@ void Controller::OnScriptError(const std::string& error_message,
if (state_ == AutofillAssistantState::STOPPED)
return;
RequireUI();
SetStatusMessage(error_message);
SetProgressBarErrorState(true);
// For lite scripts, don't attach the UI on error, and don't show an error
// while shutting down.
if (!IsRunningLiteScript()) {
RequireUI();
SetStatusMessage(error_message);
SetProgressBarErrorState(true);
}
EnterStoppedState();
if (tracking_) {
......@@ -1570,7 +1575,8 @@ void Controller::OnFatalError(const std::string& error_message,
void Controller::RecordDropOutOrShutdown(Metrics::DropOutReason reason) {
// If there is an UI, we wait for it to be closed before shutting down (the UI
// will call |ShutdownIfNecessary|).
if (client_->HasHadUI()) {
// Lite scripts go away immediately, even if UI is currently being shown.
if (client_->HasHadUI() && !IsRunningLiteScript()) {
// We report right away to make sure we don't lose this reason if the client
// is unexpectedly destroyed while the error message is showing (for example
// if the tab is closed).
......@@ -1933,6 +1939,10 @@ bool Controller::StateNeedsUI(AutofillAssistantState state) {
return StateNeedsUiInLiteScript(state);
}
bool Controller::IsRunningLiteScript() const {
return trigger_context_ ? trigger_context_->is_lite_script() : false;
}
ElementArea* Controller::touchable_element_area() {
if (!touchable_element_area_) {
touchable_element_area_ = std::make_unique<ElementArea>(this);
......
......@@ -341,6 +341,7 @@ class Controller : public ScriptExecutorDelegate,
void PerformDelayedShutdownIfNecessary();
bool StateNeedsUI(AutofillAssistantState state);
bool IsRunningLiteScript() const;
ClientSettings settings_;
Client* const client_;
......
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