1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
ash / assistant / ui / assistant_view_delegate.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_ASSISTANT_UI_ASSISTANT_VIEW_DELEGATE_H_
#define ASH_ASSISTANT_UI_ASSISTANT_VIEW_DELEGATE_H_
#include <map>
#include <string>
#include "ash/public/cpp/assistant/assistant_state.h"
#include "ash/public/cpp/image_downloader.h"
#include "base/component_export.h"
#include "base/observer_list_types.h"
#include "chromeos/ash/services/libassistant/public/cpp/assistant_suggestion.h"
#include "ui/wm/core/cursor_manager.h"
namespace ash {
class AssistantNotificationModel;
enum class AssistantButtonId;
namespace assistant {
namespace util {
enum class DeepLinkType;
} // namespace util
} // namespace assistant
class COMPONENT_EXPORT(ASSISTANT_UI) AssistantViewDelegateObserver
: public base::CheckedObserver {
public:
using AssistantSuggestion = assistant::AssistantSuggestion;
// Invoked when the dialog plate button identified by |id| is pressed.
virtual void OnDialogPlateButtonPressed(AssistantButtonId id) {}
// Invoked when the dialog plate contents have been committed.
virtual void OnDialogPlateContentsCommitted(const std::string& text) {}
// Invoked when Assistant onboarding is shown.
virtual void OnOnboardingShown() {}
// Invoked when the opt in button is pressed.
virtual void OnOptInButtonPressed() {}
// Invoked when a suggestion UI element is pressed.
virtual void OnSuggestionPressed(
const base::UnguessableToken& suggestion_id) {}
// Invoked when a launcher search chip is pressed.
virtual void OnLauncherSearchChipPressed(const std::u16string& query) {}
};
// A delegate of views in assistant/ui that handles views related actions e.g.
// get models for the views, adding observers, closing the views, opening urls,
// etc.
class COMPONENT_EXPORT(ASSISTANT_UI) AssistantViewDelegate {
public:
using AssistantSuggestion = assistant::AssistantSuggestion;
virtual ~AssistantViewDelegate() = default;
// Gets the notification model.
virtual const AssistantNotificationModel* GetNotificationModel() const = 0;
// Adds/removes the specified view delegate observer.
virtual void AddObserver(AssistantViewDelegateObserver* observer) = 0;
virtual void RemoveObserver(AssistantViewDelegateObserver* observer) = 0;
// Downloads the image found at the specified |url|. On completion, the
// supplied |callback| will be run with the downloaded image. If the download
// attempt is unsuccessful, a NULL image is returned.
virtual void DownloadImage(const GURL& url,
ImageDownloader::DownloadCallback callback) = 0;
// Returns the cursor_manager.
virtual ::wm::CursorManager* GetCursorManager() = 0;
// Returns the given name of the primary user.
virtual std::string GetPrimaryUserGivenName() const = 0;
// Returns the root window for the specified |display_id|.
virtual aura::Window* GetRootWindowForDisplayId(int64_t display_id) = 0;
// Returns the root window that newly created windows should be added to.
virtual aura::Window* GetRootWindowForNewWindows() = 0;
// Returns true if in tablet mode.
virtual bool IsTabletMode() const = 0;
// Invoked when the dialog plate button identified by |id| is pressed.
virtual void OnDialogPlateButtonPressed(AssistantButtonId id) = 0;
// Invoked when the dialog plate contents have been committed.
virtual void OnDialogPlateContentsCommitted(const std::string& text) = 0;
// Invoked when an in-Assistant notification button is pressed.
virtual void OnNotificationButtonPressed(const std::string& notification_id,
int notification_button_index) = 0;
// Invoked when Assistant onboarding is shown.
virtual void OnOnboardingShown() = 0;
// Invoked when the opt in button is pressed.
virtual void OnOptInButtonPressed() = 0;
// Invoked when suggestion UI is pressed.
virtual void OnSuggestionPressed(
const base::UnguessableToken& suggestion_id) = 0;
// Returns true if Assistant onboarding should be shown.
virtual bool ShouldShowOnboarding() const = 0;
// Invoked when a launcher search chip is pressed.
virtual void OnLauncherSearchChipPressed(const std::u16string& query) = 0;
};
} // namespace ash
#endif // ASH_ASSISTANT_UI_ASSISTANT_VIEW_DELEGATE_H_