Commit 39a9f59c authored by wutao's avatar wutao Committed by Commit Bot

Assistant: Add observer to voice interaction mojom

This patch add the AddObserver method to voice interaction controller
mojom.

Bug: b/110094434, b/80431063
Test: manual.
Change-Id: I15853b1cea5cc11c3228f59f80df2bd634616c60
Reviewed-on: https://chromium-review.googlesource.com/1111645Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Tao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569677}
parent 3d570716
......@@ -88,4 +88,7 @@ interface VoiceInteractionController {
// Return the voice interaction setup complete status.
IsSetupCompleted() => (bool completed);
// Add an observer.
AddObserver(VoiceInteractionObserver observer);
};
......@@ -71,8 +71,7 @@ AppListButton::AppListButton(InkDropButtonListener* listener,
mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_binding_.Bind(mojo::MakeRequest(&ptr));
Shell::Get()->voice_interaction_controller()->AddVoiceInteractionObserver(
std::move(ptr));
Shell::Get()->voice_interaction_controller()->AddObserver(std::move(ptr));
SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
set_ink_drop_base_color(kShelfInkDropBaseColor);
set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
......
......@@ -42,8 +42,7 @@ MetalayerMode::MetalayerMode(Delegate* delegate)
mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_binding_.Bind(mojo::MakeRequest(&ptr));
Shell::Get()->voice_interaction_controller()->AddVoiceInteractionObserver(
std::move(ptr));
Shell::Get()->voice_interaction_controller()->AddObserver(std::move(ptr));
Shell::Get()->highlighter_controller()->AddObserver(this);
}
......
......@@ -17,11 +17,6 @@ void VoiceInteractionController::BindRequest(
binding_.Bind(std::move(request));
}
void VoiceInteractionController::AddVoiceInteractionObserver(
mojom::VoiceInteractionObserverPtr observer) {
observers_.AddPtr(std::move(observer));
}
void VoiceInteractionController::NotifyStatusChanged(
mojom::VoiceInteractionState state) {
voice_interaction_state_ = state;
......@@ -68,6 +63,11 @@ void VoiceInteractionController::IsSetupCompleted(
std::move(callback).Run(setup_completed_);
}
void VoiceInteractionController::AddObserver(
mojom::VoiceInteractionObserverPtr observer) {
observers_.AddPtr(std::move(observer));
}
void VoiceInteractionController::FlushForTesting() {
observers_.FlushForTesting();
}
......
......@@ -22,8 +22,6 @@ class ASH_EXPORT VoiceInteractionController
void BindRequest(mojom::VoiceInteractionControllerRequest request);
void AddVoiceInteractionObserver(mojom::VoiceInteractionObserverPtr observer);
// ash::mojom::VoiceInteractionController:
void NotifyStatusChanged(mojom::VoiceInteractionState state) override;
void NotifySettingsEnabled(bool enabled) override;
......@@ -32,6 +30,7 @@ class ASH_EXPORT VoiceInteractionController
void NotifyFeatureAllowed(mojom::AssistantAllowedState state) override;
void IsSettingEnabled(IsSettingEnabledCallback callback) override;
void IsSetupCompleted(IsSetupCompletedCallback callback) override;
void AddObserver(mojom::VoiceInteractionObserverPtr observer) override;
mojom::VoiceInteractionState voice_interaction_state() const {
return voice_interaction_state_;
......
......@@ -47,7 +47,7 @@ class TestVoiceInteractionObserver : public mojom::VoiceInteractionObserver {
void SetVoiceInteractionController(VoiceInteractionController* controller) {
mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_binding_.Bind(mojo::MakeRequest(&ptr));
controller->AddVoiceInteractionObserver(std::move(ptr));
controller->AddObserver(std::move(ptr));
}
private:
......
......@@ -26,6 +26,7 @@ class FakeVoiceInteractionController
void NotifyFeatureAllowed(ash::mojom::AssistantAllowedState state) override;
void IsSettingEnabled(IsSettingEnabledCallback callback) override;
void IsSetupCompleted(IsSetupCompletedCallback callback) override;
void AddObserver(ash::mojom::VoiceInteractionObserverPtr observer) override {}
ash::mojom::VoiceInteractionState voice_interaction_state() const {
return voice_interaction_state_;
......
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