Commit 1538787e authored by David Black's avatar David Black Committed by Commit Bot

Automatically close proactive suggestions after a fixed interval.

Per UX requirement, if the user doesn't interact with proactive
suggestions within 15sec, the widget should automatically be closed.

Bug: b:139199754
Change-Id: I77d398a4d6d376b2ee3aadf4888da3fb764ee77a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772481
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690960}
parent 13462f0b
......@@ -17,6 +17,7 @@
#include "ash/multi_user/multi_user_window_manager_impl.h"
#include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/assistant/assistant_setup.h"
#include "ash/public/cpp/assistant/proactive_suggestions.h"
#include "ash/public/cpp/toast_data.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
......@@ -35,6 +36,11 @@ namespace {
// When hidden, Assistant will automatically close after |kAutoCloseThreshold|.
constexpr base::TimeDelta kAutoCloseThreshold = base::TimeDelta::FromMinutes(5);
// When shown, the proactive suggestions widget will automatically close if the
// user doesn't interact with it within a fixed interval.
constexpr base::TimeDelta kAutoCloseProactiveSuggestionsThreshold =
base::TimeDelta::FromSeconds(15);
// Toast -----------------------------------------------------------------------
constexpr int kToastDurationMs = 2500;
......@@ -153,6 +159,13 @@ void AssistantUiController::OnProactiveSuggestionsChanged(
CreateProactiveSuggestionsView();
proactive_suggestions_view_->GetWidget()->ShowInactive();
}
// The proactive suggestions widget will automatically be closed if the user
// doesn't interact with it within a fixed interval.
auto_close_proactive_suggestions_timer_.Start(
FROM_HERE, kAutoCloseProactiveSuggestionsThreshold,
base::BindRepeating(
&AssistantUiController::ResetProactiveSuggestionsView,
weak_factory_.GetWeakPtr()));
return;
}
// When proactive suggestions are absent, we need to ensure that the
......@@ -659,6 +672,8 @@ void AssistantUiController::CreateProactiveSuggestionsView() {
void AssistantUiController::ResetProactiveSuggestionsView() {
DCHECK(proactive_suggestions_view_);
auto_close_proactive_suggestions_timer_.Stop();
proactive_suggestions_view_->GetWidget()->Close();
proactive_suggestions_view_ = nullptr;
......
......@@ -184,6 +184,10 @@ class ASH_EXPORT AssistantUiController
// session. We delay this behavior to allow the user an opportunity to resume.
base::OneShotTimer auto_close_timer_;
// When shown, the proactive suggestions widget will automatically be closed
// if the user doesn't interact with it within a fixed interval.
base::OneShotTimer auto_close_proactive_suggestions_timer_;
// Whether the UI controller is observing changes to the usable work area.
bool is_observing_usable_work_area_ = false;
......
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