Commit 46b99990 authored by David Black's avatar David Black Committed by Commit Bot

Handle unbound service.

Previously, Assistant UI could only be launched via hotword. This meant
it was impossible to see Assistant UI if the underlying service was
not started.

Now, there are non-hotword entry points wired up and it is possible to
launch Assistant UI with the underlying service in an unready state.
This can happen if the underlying service fails to get a token and bind
itself to AssistantController, as happens when logging in without a
network connection.

Now we will show a toast. Just a generic message for now, need to get
final text from UX.

Bug: b:79752950
Change-Id: I48ae014e257db0012ac791be40f1245e5c3316b0
Reviewed-on: https://chromium-review.googlesource.com/1060603
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559243}
parent 9da91cfc
...@@ -11,13 +11,37 @@ ...@@ -11,13 +11,37 @@
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/system/toast/toast_data.h"
#include "ash/system/toast/toast_manager.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "ui/snapshot/snapshot.h" #include "ui/snapshot/snapshot.h"
namespace ash { namespace ash {
namespace {
// Toast -----------------------------------------------------------------------
constexpr int kToastDurationMs = 2500;
constexpr char kUnboundServiceToastId[] =
"assistant_controller_unbound_service";
// TODO(b/77638210): Localize string.
constexpr char kSomethingWentWrong[] =
"Something went wrong. Try again in a few seconds.";
void ShowToast(const std::string& id, const std::string& text) {
ToastData toast(id, base::UTF8ToUTF16(text), kToastDurationMs, base::nullopt);
Shell::Get()->toast_manager()->Show(toast);
}
} // namespace
// AssistantController ---------------------------------------------------------
AssistantController::AssistantController() AssistantController::AssistantController()
: assistant_controller_binding_(this), : assistant_controller_binding_(this),
assistant_event_subscriber_binding_(this), assistant_event_subscriber_binding_(this),
...@@ -114,6 +138,10 @@ void AssistantController::RemoveInteractionModelObserver( ...@@ -114,6 +138,10 @@ void AssistantController::RemoveInteractionModelObserver(
} }
void AssistantController::StartInteraction() { void AssistantController::StartInteraction() {
if (!assistant_) {
ShowToast(kUnboundServiceToastId, kSomethingWentWrong);
return;
}
OnInteractionStarted(); OnInteractionStarted();
} }
......
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