Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / notification_provider / notification_provider_api.h
blob012e06812eeedf26f08f1377593ef9f36e7d34e6
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/extensions/api/notification_provider.h"
14 #include "extensions/browser/extension_function.h"
15 #include "ui/message_center/notification_types.h"
17 namespace extensions {
19 // Send events to the client. This will send events onCreated, onUpdated and
20 // onCleared to extensions/apps using this API.
21 class NotificationProviderEventRouter {
22 public:
23 explicit NotificationProviderEventRouter(Profile* profile);
24 virtual ~NotificationProviderEventRouter();
26 void CreateNotification(
27 const std::string& notification_provider_id,
28 const std::string& sender_id,
29 const std::string& notification_id,
30 const api::notifications::NotificationOptions& options);
31 void UpdateNotification(
32 const std::string& notification_provider_id,
33 const std::string& sender_id,
34 const std::string& notificaiton_id,
35 const api::notifications::NotificationOptions& options);
36 void ClearNotification(const std::string& notification_provider_id,
37 const std::string& sender_id,
38 const std::string& notification_id);
40 private:
41 void Create(const std::string& notification_provider_id,
42 const std::string& sender_id,
43 const std::string& notification_id,
44 const api::notifications::NotificationOptions& options);
45 void Update(const std::string& notification_provider_id,
46 const std::string& sender_id,
47 const std::string& notification_id,
48 const api::notifications::NotificationOptions& options);
49 void Clear(const std::string& notification_provider_id,
50 const std::string& sender_id,
51 const std::string& notification_id);
53 Profile* profile_;
55 DISALLOW_COPY_AND_ASSIGN(NotificationProviderEventRouter);
58 // Implememtation of NotifyOnCleared function of the API. It will inform the
59 // notifier that the user cleared a notification sent from that notifier.
60 class NotificationProviderNotifyOnClearedFunction
61 : public ChromeUIThreadExtensionFunction {
62 public:
63 NotificationProviderNotifyOnClearedFunction();
65 protected:
66 ~NotificationProviderNotifyOnClearedFunction() override;
68 private:
69 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared",
70 NOTIFICATIONPROVIDER_NOTIFYONCLEARED);
72 // UIThreadExtensionFunction implementation.
73 ExtensionFunction::ResponseAction Run() override;
76 // Implememtation of NotifyOnClicked function of the API. It will inform the
77 // notifier that the user clicked in a non-button area of a notification sent
78 // from that notifier.
79 class NotificationProviderNotifyOnClickedFunction
80 : public ChromeUIThreadExtensionFunction {
81 public:
82 NotificationProviderNotifyOnClickedFunction();
84 protected:
85 ~NotificationProviderNotifyOnClickedFunction() override;
87 private:
88 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked",
89 NOTIFICATIONPROVIDER_NOTIFYONCLICKED);
91 // UIThreadExtensionFunction implementation.
92 ExtensionFunction::ResponseAction Run() override;
95 // Implememtation of NotifyOnButtonClicked function of the API. It will inform
96 // the
97 // notifier that the user pressed a button in the notification sent from that
98 // notifier.
99 class NotificationProviderNotifyOnButtonClickedFunction
100 : public ChromeUIThreadExtensionFunction {
101 public:
102 NotificationProviderNotifyOnButtonClickedFunction();
104 protected:
105 ~NotificationProviderNotifyOnButtonClickedFunction() override;
107 private:
108 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnButtonClicked",
109 NOTIFICATIONPROVIDER_NOTIFYONBUTTONCLICKED);
111 // UIThreadExtensionFunction implementation.
112 ExtensionFunction::ResponseAction Run() override;
115 // Implememtation of NotifyOnPermissionLevelChanged function of the API. It will
116 // inform the notifier that the user changed the permission level of that
117 // notifier.
118 class NotificationProviderNotifyOnPermissionLevelChangedFunction
119 : public ChromeUIThreadExtensionFunction {
120 public:
121 NotificationProviderNotifyOnPermissionLevelChangedFunction();
123 protected:
124 ~NotificationProviderNotifyOnPermissionLevelChangedFunction() override;
126 private:
127 DECLARE_EXTENSION_FUNCTION(
128 "notificationProvider.notifyOnPermissionLevelChanged",
129 NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED);
131 // UIThreadExtensionFunction implementation.
132 ExtensionFunction::ResponseAction Run() override;
135 // Implememtation of NotifyOnShowSettings function of the API. It will inform
136 // the notifier that the user clicked on advanced settings of that notifier.
137 class NotificationProviderNotifyOnShowSettingsFunction
138 : public ChromeUIThreadExtensionFunction {
139 public:
140 NotificationProviderNotifyOnShowSettingsFunction();
142 protected:
143 ~NotificationProviderNotifyOnShowSettingsFunction() override;
145 private:
146 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings",
147 NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS);
149 // UIThreadExtensionFunction implementation.
150 ExtensionFunction::ResponseAction Run() override;
153 // Implememtation of GetNotifier function of the API. It will get the notifier
154 // object that corresponds to the notifier ID.
155 class NotificationProviderGetNotifierFunction
156 : public ChromeUIThreadExtensionFunction {
157 public:
158 NotificationProviderGetNotifierFunction();
160 protected:
161 ~NotificationProviderGetNotifierFunction() override;
163 private:
164 DECLARE_EXTENSION_FUNCTION("notificationProvider.getNotifier",
165 NOTIFICATIONPROVIDER_GETNOTIFIER);
167 // UIThreadExtensionFunction implementation.
168 ExtensionFunction::ResponseAction Run() override;
171 // Implememtation of GetAllNotifiers function of the API. It will get all the
172 // notifiers that would send notifications.
173 class NotificationProviderGetAllNotifiersFunction
174 : public ChromeUIThreadExtensionFunction {
175 public:
176 NotificationProviderGetAllNotifiersFunction();
178 protected:
179 ~NotificationProviderGetAllNotifiersFunction() override;
181 private:
182 DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers",
183 NOTIFICATIONPROVIDER_GETALLNOTIFIERS);
185 // UIThreadExtensionFunction implementation.
186 ExtensionFunction::ResponseAction Run() override;
189 } // namespace extensions
191 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_