1 // Copyright 2020 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 CHROMEOS_SERVICES_ASSISTANT_PUBLIC_CPP_ASSISTANT_NOTIFICATION_H_
6 #define CHROMEOS_SERVICES_ASSISTANT_PUBLIC_CPP_ASSISTANT_NOTIFICATION_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/optional.h"
12 #include "base/time/time.h"
13 #include "url/gurl.h"
14 
15 namespace chromeos {
16 namespace assistant {
17 
18 // Models a notification button.
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC)19 struct COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) AssistantNotificationButton {
20   // Display text of the button.
21   std::string label;
22 
23   // Optional URL to open when the tap action is invoked on the button.
24   GURL action_url;
25 
26   // If |true|, the associated notification will be removed on button click.
27   bool remove_notification_on_click = true;
28 };
29 
30 // Enumeration of possible notification priorities.
31 // NOTE: This enum maps to a subset of message_center::NotificationPriority.
32 enum class AssistantNotificationPriority {
33   kLow,      // See message_center::NotificationPriority::LOW_PRIORITY.
34   kDefault,  // See message_center::NotificationPriority::DEFAULT_PRIORITY.
35   kHigh,     // See message_center::NotificationPriority::HIGH_PRIORITY.
36 };
37 
38 // Models an Assistant notification.
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC)39 struct COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) AssistantNotification {
40   AssistantNotification();
41   AssistantNotification(const AssistantNotification&);
42   AssistantNotification& operator=(const AssistantNotification&);
43   AssistantNotification(AssistantNotification&&);
44   AssistantNotification& operator=(AssistantNotification&&);
45   virtual ~AssistantNotification();
46 
47   // Title of the notification.
48   std::string title;
49 
50   // Body text of the notification.
51   std::string message;
52 
53   // Optional URL to open when the tap action is invoked on the notification
54   // main UI.
55   GURL action_url;
56 
57   // List of buttons in the notification.
58   std::vector<AssistantNotificationButton> buttons;
59 
60   // An id that uniquely identifies a notification on the client.
61   std::string client_id;
62 
63   // An id that uniquely identifies a notification on the server.
64   std::string server_id;
65 
66   // Used to fetch notification contents.
67   std::string consistency_token;
68   std::string opaque_token;
69 
70   // Key that can be used to group multiple notifications together.
71   std::string grouping_key;
72 
73   // Obfuscated Gaia id of the intended recipient of the user.
74   std::string obfuscated_gaia_id;
75 
76   // Priority for the notification. This affects whether or not the notification
77   // will pop up and/or have the capability to wake the display if it was off.
78   AssistantNotificationPriority priority{
79       AssistantNotificationPriority::kDefault};
80 
81   // When the notification should expire.
82   // Expressed as milliseconds since Unix Epoch.
83   base::Optional<base::Time> expiry_time;
84 
85   // If |true|, the notification will be removed on click.
86   bool remove_on_click = true;
87 
88   // If |true|, the notification state (e.g. its popup and read status) will be
89   // reset so as to renotify the user of this notification.
90   // See `message_center::Notification::renotify()`.
91   bool renotify = false;
92 
93   // If |true|, the user can't remove the notification.
94   bool is_pinned = false;
95 
96   // If |true|, this notification was sent from the server. Clicking a
97   // notification that was sent from the server may result in a request to the
98   // server to retrieve the notification payload. One example of this would be
99   // notifications triggered by an Assistant reminder.
100   bool from_server = false;
101 };
102 
103 }  // namespace assistant
104 }  // namespace chromeos
105 
106 #endif  // CHROMEOS_SERVICES_ASSISTANT_PUBLIC_CPP_ASSISTANT_NOTIFICATION_H_
107