Commit 461b1ae3 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Commit Bot

Do not flash Assistant prompt when Assistant pen selection is complete

This is a temporary fix for b/66168241. A cleaner fix requires
multiple changes in ash/highlighter and ash/system/palette/tools
which are planned in crbug/761120.

Bug: b/66168241
Test: manual
Change-Id: I4311d24bd4e1899088f3c2d857fdf84f2ad5af95
Reviewed-on: https://chromium-review.googlesource.com/676225Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Vladislav Kaznacheev <kaznacheev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#503627}
parent 8b97e93a
......@@ -47,8 +47,11 @@ class VoiceInteractionSelectionObserver
void set_on_selection_done(base::OnceClosure done) {
on_selection_done_ = std::move(done);
delay_timer_.reset();
}
bool start_session_pending() const { return delay_timer_.get(); }
private:
void HandleSelection(const gfx::Rect& rect) override {
// Delay the actual voice interaction service invocation for better
......@@ -62,6 +65,8 @@ class VoiceInteractionSelectionObserver
delay_timer_->Reset();
DCHECK(on_selection_done_);
// This will disable the metalayer tool, which will result in a synchronous
// call to PaletteDelegateChromeOS::HideMetalayer.
std::move(on_selection_done_).Run();
}
......@@ -234,7 +239,23 @@ void PaletteDelegateChromeOS::HideMetalayer() {
arc::ArcVoiceInteractionFrameworkService::GetForBrowserContext(profile_);
if (!service)
return;
service->HideMetalayer();
// ArcVoiceInteractionFrameworkService::HideMetalayer() causes the container
// to show a toast-like prompt. This toast is redundant and causes unnecessary
// flicker if the full voice interaction UI is about to be displayed soon.
// |start_session_pending| is a good signal that the session is about to
// start, but it is not guaranteed:
// 1) The user might re-enter the metalayer mode before the timer fires.
// In this case the container will keep showing the prompt for the
// metalayer mode.
// 2) The session might fail to start due to a peculiar combination of
// failures on the way to the voice interaction UI. This is an open
// problem.
// TODO(kaznacheev) Move this logic under ash when fixing crbug/761120.
DCHECK(highlighter_selection_observer_);
if (!highlighter_selection_observer_->start_session_pending())
service->HideMetalayer();
ash::Shell::Get()->highlighter_controller()->SetEnabled(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