David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ASH_ASSISTANT_ASSISTANT_CACHE_CONTROLLER_H_ |
| 6 | #define ASH_ASSISTANT_ASSISTANT_CACHE_CONTROLLER_H_ |
| 7 | |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 8 | #include "ash/assistant/assistant_controller_observer.h" |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 9 | #include "ash/assistant/model/assistant_cache_model.h" |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 10 | #include "ash/assistant/model/assistant_ui_model_observer.h" |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 11 | #include "ash/public/interfaces/voice_interaction_controller.mojom.h" |
| 12 | #include "base/macros.h" |
| 13 | #include "mojo/public/cpp/bindings/binding.h" |
| 14 | |
| 15 | namespace ash { |
| 16 | |
| 17 | class AssistantCacheModelObserver; |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 18 | class AssistantController; |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 19 | |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 20 | class AssistantCacheController : public AssistantControllerObserver, |
| 21 | public AssistantUiModelObserver, |
| 22 | public mojom::VoiceInteractionObserver { |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 23 | public: |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 24 | explicit AssistantCacheController(AssistantController* assistant_controller); |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 25 | ~AssistantCacheController() override; |
| 26 | |
| 27 | // Returns a reference to the underlying model. |
| 28 | const AssistantCacheModel* model() const { return &model_; } |
| 29 | |
| 30 | // Adds/removes the specified cache model |observer|. |
| 31 | void AddModelObserver(AssistantCacheModelObserver* observer); |
| 32 | void RemoveModelObserver(AssistantCacheModelObserver* observer); |
| 33 | |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 34 | // AssistantControllerObserver: |
| 35 | void OnAssistantControllerConstructed() override; |
| 36 | void OnAssistantControllerDestroying() override; |
| 37 | |
| 38 | // AssistantUiModelObserver: |
David Black | 4c6b9e2 | 2018-08-27 20:31:31 | [diff] [blame] | 39 | void OnUiVisibilityChanged(AssistantVisibility new_visibility, |
| 40 | AssistantVisibility old_visibility, |
| 41 | AssistantSource source) override; |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 42 | |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 43 | private: |
| 44 | // mojom::VoiceInteractionObserver: |
| 45 | void OnVoiceInteractionStatusChanged( |
| 46 | mojom::VoiceInteractionState state) override {} |
| 47 | void OnVoiceInteractionSettingsEnabled(bool enabled) override {} |
| 48 | void OnVoiceInteractionContextEnabled(bool enabled) override; |
| 49 | void OnVoiceInteractionHotwordEnabled(bool enabled) override {} |
| 50 | void OnVoiceInteractionSetupCompleted(bool completed) override {} |
| 51 | void OnAssistantFeatureAllowedChanged( |
| 52 | mojom::AssistantAllowedState state) override {} |
Muyuan Li | 999dcf6 | 2018-08-22 18:12:12 | [diff] [blame] | 53 | void OnLocaleChanged(const std::string& locale) override {} |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 54 | |
| 55 | void UpdateConversationStarters(); |
| 56 | |
David Black | 02974f8 | 2018-08-21 22:56:05 | [diff] [blame] | 57 | AssistantController* const assistant_controller_; // Owned by Shell. |
| 58 | |
David Black | 6b4b1ad2 | 2018-08-21 02:45:08 | [diff] [blame] | 59 | mojo::Binding<mojom::VoiceInteractionObserver> voice_interaction_binding_; |
| 60 | |
| 61 | AssistantCacheModel model_; |
| 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(AssistantCacheController); |
| 64 | }; |
| 65 | |
| 66 | } // namespace ash |
| 67 | |
| 68 | #endif // ASH_ASSISTANT_ASSISTANT_CACHE_CONTROLLER_H_ |