Commit f59de9fb authored by David Black's avatar David Black Committed by Commit Bot

Support disabling timeout for proactive suggestions.

Timeout may not make sense w/ show-on-scroll enabled. In the chance
that timeout may need to be disabled, we'll treat a timeout of zero as
indicating desire to disable timeout.

Bug: b:139199620
Change-Id: I14c79620542320148e31942fe8c4ae447c74ab65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1939841Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#721110}
parent 9dffda5d
......@@ -173,6 +173,13 @@ void AssistantProactiveSuggestionsController::
void AssistantProactiveSuggestionsController::
OnProactiveSuggestionsViewHoverChanged(bool is_hovering) {
// If no timeout threshold is specified, we don't need to handle hover change
// events as such events are only used to pause/resume timeout.
if (chromeos::assistant::features::GetProactiveSuggestionsTimeoutThreshold()
.is_zero()) {
return;
}
// Hover changed events may occur during the proactive suggestion view's
// closing sequence. When this occurs, no further action is necessary.
if (!view_ || !view_->GetWidget() || view_->GetWidget()->IsClosed())
......@@ -320,14 +327,18 @@ void AssistantProactiveSuggestionsController::MaybeShowUi() {
view_->proactive_suggestions()->hash());
}
// The proactive suggestions view will automatically be closed if the user
// doesn't interact with it within a fixed time interval.
auto_close_timer_.Start(
FROM_HERE,
chromeos::assistant::features::GetProactiveSuggestionsTimeoutThreshold(),
base::BindRepeating(&AssistantProactiveSuggestionsController::CloseUi,
weak_factory_.GetWeakPtr(),
ProactiveSuggestionsShowResult::kCloseByTimeout));
// When a |timeout_threshold| is specified, the proactive suggestions view
// will automatically be closed if the user doesn't interact with it within a
// fixed time interval.
const base::TimeDelta timeout_threshold =
chromeos::assistant::features::GetProactiveSuggestionsTimeoutThreshold();
if (!timeout_threshold.is_zero()) {
auto_close_timer_.Start(
FROM_HERE, timeout_threshold,
base::BindRepeating(&AssistantProactiveSuggestionsController::CloseUi,
weak_factory_.GetWeakPtr(),
ProactiveSuggestionsShowResult::kCloseByTimeout));
}
}
void AssistantProactiveSuggestionsController::CloseUi(
......
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