assistant_view_delegate.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #ifndef ASH_ASSISTANT_UI_ASSISTANT_VIEW_DELEGATE_H_
  5. #define ASH_ASSISTANT_UI_ASSISTANT_VIEW_DELEGATE_H_
  6. #include <map>
  7. #include <string>
  8. #include "ash/public/cpp/assistant/assistant_state.h"
  9. #include "ash/public/cpp/image_downloader.h"
  10. #include "base/component_export.h"
  11. #include "base/observer_list_types.h"
  12. #include "chromeos/services/libassistant/public/cpp/assistant_suggestion.h"
  13. #include "ui/wm/core/cursor_manager.h"
  14. namespace ash {
  15. class AssistantNotificationModel;
  16. enum class AssistantButtonId;
  17. namespace assistant {
  18. namespace util {
  19. enum class DeepLinkType;
  20. } // namespace util
  21. } // namespace assistant
  22. class COMPONENT_EXPORT(ASSISTANT_UI) AssistantViewDelegateObserver
  23. : public base::CheckedObserver {
  24. public:
  25. using AssistantSuggestion = chromeos::assistant::AssistantSuggestion;
  26. // Invoked when the dialog plate button identified by |id| is pressed.
  27. virtual void OnDialogPlateButtonPressed(AssistantButtonId id) {}
  28. // Invoked when the dialog plate contents have been committed.
  29. virtual void OnDialogPlateContentsCommitted(const std::string& text) {}
  30. // Invoked when Assistant onboarding is shown.
  31. virtual void OnOnboardingShown() {}
  32. // Invoked when the opt in button is pressed.
  33. virtual void OnOptInButtonPressed() {}
  34. // Invoked when a suggestion UI element is pressed.
  35. virtual void OnSuggestionPressed(
  36. const base::UnguessableToken& suggestion_id) {}
  37. };
  38. // A delegate of views in assistant/ui that handles views related actions e.g.
  39. // get models for the views, adding observers, closing the views, opening urls,
  40. // etc.
  41. class COMPONENT_EXPORT(ASSISTANT_UI) AssistantViewDelegate {
  42. public:
  43. using AssistantSuggestion = chromeos::assistant::AssistantSuggestion;
  44. virtual ~AssistantViewDelegate() = default;
  45. // Gets the notification model.
  46. virtual const AssistantNotificationModel* GetNotificationModel() const = 0;
  47. // Adds/removes the specified view delegate observer.
  48. virtual void AddObserver(AssistantViewDelegateObserver* observer) = 0;
  49. virtual void RemoveObserver(AssistantViewDelegateObserver* observer) = 0;
  50. // Downloads the image found at the specified |url|. On completion, the
  51. // supplied |callback| will be run with the downloaded image. If the download
  52. // attempt is unsuccessful, a NULL image is returned.
  53. virtual void DownloadImage(const GURL& url,
  54. ImageDownloader::DownloadCallback callback) = 0;
  55. // Returns the cursor_manager.
  56. virtual ::wm::CursorManager* GetCursorManager() = 0;
  57. // Returns the given name of the primary user.
  58. virtual std::string GetPrimaryUserGivenName() const = 0;
  59. // Returns the root window for the specified |display_id|.
  60. virtual aura::Window* GetRootWindowForDisplayId(int64_t display_id) = 0;
  61. // Returns the root window that newly created windows should be added to.
  62. virtual aura::Window* GetRootWindowForNewWindows() = 0;
  63. // Returns true if in tablet mode.
  64. virtual bool IsTabletMode() const = 0;
  65. // Invoked when the dialog plate button identified by |id| is pressed.
  66. virtual void OnDialogPlateButtonPressed(AssistantButtonId id) = 0;
  67. // Invoked when the dialog plate contents have been committed.
  68. virtual void OnDialogPlateContentsCommitted(const std::string& text) = 0;
  69. // Invoked when an in-Assistant notification button is pressed.
  70. virtual void OnNotificationButtonPressed(const std::string& notification_id,
  71. int notification_button_index) = 0;
  72. // Invoked when Assistant onboarding is shown.
  73. virtual void OnOnboardingShown() = 0;
  74. // Invoked when the opt in button is pressed.
  75. virtual void OnOptInButtonPressed() = 0;
  76. // Invoked when suggestion UI is pressed.
  77. virtual void OnSuggestionPressed(
  78. const base::UnguessableToken& suggestion_id) = 0;
  79. // Returns true if Assistant onboarding should be shown.
  80. virtual bool ShouldShowOnboarding() const = 0;
  81. };
  82. } // namespace ash
  83. #endif // ASH_ASSISTANT_UI_ASSISTANT_VIEW_DELEGATE_H_