David Black | f7f8d201 | 2018-04-25 19:48:02 | [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 | |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 5 | #ifndef ASH_ASSISTANT_ASSISTANT_UI_CONTROLLER_H_ |
| 6 | #define ASH_ASSISTANT_ASSISTANT_UI_CONTROLLER_H_ |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 7 | |
Xiaohui Chen | 6c60ed3 | 2018-09-05 17:55:35 | [diff] [blame] | 8 | #include <map> |
Meilin Wang | 88c15d0 | 2018-11-29 21:31:36 | [diff] [blame] | 9 | #include <memory> |
Xiaohui Chen | 6c60ed3 | 2018-09-05 17:55:35 | [diff] [blame] | 10 | #include <string> |
| 11 | |
Qiang Xu | 89e5fa5 | 2018-05-25 18:26:08 | [diff] [blame] | 12 | #include "ash/ash_export.h" |
David Black | e802d406 | 2018-06-29 01:59:05 | [diff] [blame] | 13 | #include "ash/assistant/assistant_controller_observer.h" |
David Black | 5318ec1 | 2018-05-02 01:54:32 | [diff] [blame] | 14 | #include "ash/assistant/model/assistant_interaction_model_observer.h" |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 15 | #include "ash/assistant/model/assistant_ui_model.h" |
David Black | ad1f2f59 | 2018-07-09 23:28:10 | [diff] [blame] | 16 | #include "ash/assistant/model/assistant_ui_model_observer.h" |
David Black | 4703d7b | 2018-06-22 00:16:39 | [diff] [blame] | 17 | #include "ash/highlighter/highlighter_controller.h" |
wutao | 12d9204 | 2020-03-23 02:25:32 | [diff] [blame] | 18 | #include "ash/wm/overview/overview_observer.h" |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 19 | #include "base/macros.h" |
Meilin Wang | 88c15d0 | 2018-11-29 21:31:36 | [diff] [blame] | 20 | #include "base/optional.h" |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 21 | |
David Black | 4703d7b | 2018-06-22 00:16:39 | [diff] [blame] | 22 | namespace chromeos { |
| 23 | namespace assistant { |
| 24 | namespace mojom { |
| 25 | class Assistant; |
| 26 | } // namespace mojom |
| 27 | } // namespace assistant |
| 28 | } // namespace chromeos |
| 29 | |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 30 | namespace ash { |
| 31 | |
David Black | ec4cbcd | 2020-04-15 20:35:25 | [diff] [blame^] | 32 | class AssistantControllerImpl; |
David Black | e0ac6ee | 2019-09-06 00:58:01 | [diff] [blame] | 33 | |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 34 | class ASH_EXPORT AssistantUiController |
David Black | 08e64c80 | 2020-02-01 03:23:59 | [diff] [blame] | 35 | : public AssistantControllerObserver, |
David Black | e4b8cc1b | 2018-06-06 17:45:26 | [diff] [blame] | 36 | public AssistantInteractionModelObserver, |
David Black | ad1f2f59 | 2018-07-09 23:28:10 | [diff] [blame] | 37 | public AssistantUiModelObserver, |
wutao | 12d9204 | 2020-03-23 02:25:32 | [diff] [blame] | 38 | public HighlighterController::Observer, |
| 39 | public OverviewObserver { |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 40 | public: |
David Black | ec4cbcd | 2020-04-15 20:35:25 | [diff] [blame^] | 41 | explicit AssistantUiController(AssistantControllerImpl* assistant_controller); |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 42 | ~AssistantUiController() override; |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 43 | |
David Black | 4703d7b | 2018-06-22 00:16:39 | [diff] [blame] | 44 | // Provides a pointer to the |assistant| owned by AssistantController. |
| 45 | void SetAssistant(chromeos::assistant::mojom::Assistant* assistant); |
| 46 | |
David Black | 9531544b | 2018-06-05 22:44:24 | [diff] [blame] | 47 | // Returns the underlying model. |
David Black | cdc2b97 | 2018-09-14 01:18:27 | [diff] [blame] | 48 | const AssistantUiModel* model() const { return &model_; } |
David Black | 9531544b | 2018-06-05 22:44:24 | [diff] [blame] | 49 | |
| 50 | // Adds/removes the specified model |observer|. |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 51 | void AddModelObserver(AssistantUiModelObserver* observer); |
| 52 | void RemoveModelObserver(AssistantUiModelObserver* observer); |
David Black | 9531544b | 2018-06-05 22:44:24 | [diff] [blame] | 53 | |
David Black | 5318ec1 | 2018-05-02 01:54:32 | [diff] [blame] | 54 | // AssistantInteractionModelObserver: |
David Black | 9531544b | 2018-06-05 22:44:24 | [diff] [blame] | 55 | void OnInputModalityChanged(InputModality input_modality) override; |
David Black | 5318ec1 | 2018-05-02 01:54:32 | [diff] [blame] | 56 | void OnInteractionStateChanged(InteractionState interaction_state) override; |
David Black | e4b8cc1b | 2018-06-06 17:45:26 | [diff] [blame] | 57 | void OnMicStateChanged(MicState mic_state) override; |
| 58 | |
David Black | 4703d7b | 2018-06-22 00:16:39 | [diff] [blame] | 59 | // HighlighterController::Observer: |
| 60 | void OnHighlighterEnabledChanged(HighlighterEnabledState state) override; |
| 61 | |
David Black | e802d406 | 2018-06-29 01:59:05 | [diff] [blame] | 62 | // AssistantControllerObserver: |
David Black | 1f58bcc | 2018-07-12 17:59:40 | [diff] [blame] | 63 | void OnAssistantControllerConstructed() override; |
| 64 | void OnAssistantControllerDestroying() override; |
Xiao Yang | e7202fd4 | 2019-06-11 19:56:33 | [diff] [blame] | 65 | void OnOpeningUrl(const GURL& url, |
| 66 | bool in_background, |
| 67 | bool from_server) override; |
David Black | e802d406 | 2018-06-29 01:59:05 | [diff] [blame] | 68 | |
David Black | ad1f2f59 | 2018-07-09 23:28:10 | [diff] [blame] | 69 | // AssistantUiModelObserver: |
Meilin Wang | 88c15d0 | 2018-11-29 21:31:36 | [diff] [blame] | 70 | void OnUiVisibilityChanged( |
| 71 | AssistantVisibility new_visibility, |
| 72 | AssistantVisibility old_visibility, |
| 73 | base::Optional<AssistantEntryPoint> entry_point, |
| 74 | base::Optional<AssistantExitPoint> exit_point) override; |
David Black | ad1f2f59 | 2018-07-09 23:28:10 | [diff] [blame] | 75 | |
wutao | 12d9204 | 2020-03-23 02:25:32 | [diff] [blame] | 76 | // OverviewObserver: |
| 77 | void OnOverviewModeWillStart() override; |
| 78 | |
Meilin Wang | 88c15d0 | 2018-11-29 21:31:36 | [diff] [blame] | 79 | void ShowUi(AssistantEntryPoint entry_point); |
Meilin Wang | 88c15d0 | 2018-11-29 21:31:36 | [diff] [blame] | 80 | void CloseUi(AssistantExitPoint exit_point); |
| 81 | void ToggleUi(base::Optional<AssistantEntryPoint> entry_point, |
| 82 | base::Optional<AssistantExitPoint> exit_point); |
Qiang Xu | 89e5fa5 | 2018-05-25 18:26:08 | [diff] [blame] | 83 | |
David Black | 5318ec1 | 2018-05-02 01:54:32 | [diff] [blame] | 84 | private: |
David Black | e4b8cc1b | 2018-06-06 17:45:26 | [diff] [blame] | 85 | // Updates UI mode to |ui_mode| if specified. Otherwise UI mode is updated on |
David Black | e90ce07 | 2019-04-19 23:17:28 | [diff] [blame] | 86 | // the basis of interaction/widget visibility state. If |due_to_interaction| |
| 87 | // is true, the UI mode changed because of an Assistant interaction. |
| 88 | void UpdateUiMode(base::Optional<AssistantUiMode> ui_mode = base::nullopt, |
| 89 | bool due_to_interaction = false); |
David Black | e4b8cc1b | 2018-06-06 17:45:26 | [diff] [blame] | 90 | |
David Black | ec4cbcd | 2020-04-15 20:35:25 | [diff] [blame^] | 91 | AssistantControllerImpl* const assistant_controller_; // Owned by Shell. |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 92 | |
David Black | 4703d7b | 2018-06-22 00:16:39 | [diff] [blame] | 93 | // Owned by AssistantController. |
| 94 | chromeos::assistant::mojom::Assistant* assistant_ = nullptr; |
| 95 | |
David Black | cdc2b97 | 2018-09-14 01:18:27 | [diff] [blame] | 96 | AssistantUiModel model_; |
David Black | 9766ecd | 2018-06-20 18:29:11 | [diff] [blame] | 97 | |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 98 | DISALLOW_COPY_AND_ASSIGN(AssistantUiController); |
David Black | f7f8d201 | 2018-04-25 19:48:02 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | } // namespace ash |
| 102 | |
David Black | 1d1b1b67 | 2018-06-20 21:41:57 | [diff] [blame] | 103 | #endif // ASH_ASSISTANT_ASSISTANT_UI_CONTROLLER_H_ |