Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/extensions/api/notification_provider/notification_provider_api.h

Issue 356673003: Notification Provider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bug fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDE R_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDE R_API_H_
7
8 #include <string>
9
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"
16
17 namespace extensions {
18
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();
25
26 void CreateNotification(
27 const std::string& notification_provider_id,
28 const std::string& sender_id,
29 const std::string& notification_id,
30 const extensions::api::notifications::NotificationOptions& options);
not at google - send to devlin 2014/07/30 19:24:37 extensions:: unnecessary (for all occurrences of e
liyanhou 2014/07/30 22:21:51 Done.
31 void UpdateNotification(
32 const std::string& notification_provider_id,
33 const std::string& sender_id,
34 const std::string& notificaiton_id,
35 const extensions::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);
39
40 private:
41 void Create(
42 const std::string& notification_provider_id,
43 const std::string& sender_id,
44 const std::string& notification_id,
45 const extensions::api::notifications::NotificationOptions& options);
46 void Update(
47 const std::string& notification_provider_id,
48 const std::string& sender_id,
49 const std::string& notification_id,
50 const extensions::api::notifications::NotificationOptions& options);
51 void Clear(const std::string& notification_provider_id,
52 const std::string& sender_id,
53 const std::string& notification_id);
54
55 Profile* profile_;
56
57 DISALLOW_COPY_AND_ASSIGN(NotificationProviderEventRouter);
58 };
59
60 // Implememtation of NotifyOnCleared function of the API. It will inform the
61 // notifier that the user cleared a notification sent from that notifier.
62 class NotificationProviderNotifyOnClearedFunction
63 : public ChromeUIThreadExtensionFunction {
64 public:
65 NotificationProviderNotifyOnClearedFunction();
66
67 protected:
68 virtual ~NotificationProviderNotifyOnClearedFunction();
69
70 private:
71 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared",
72 NOTIFICATIONPROVIDER_NOTIFYONCLEARED);
73
74 // UIThreadExtensionFunction implementation.
75 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
76 };
77
78 // Implememtation of NotifyOnClicked function of the API. It will inform the
79 // notifier that the user clicked in a non-button area of a notification sent
80 // from that notifier.
81 class NotificationProviderNotifyOnClickedFunction
82 : public ChromeUIThreadExtensionFunction {
83 public:
84 NotificationProviderNotifyOnClickedFunction();
85
86 protected:
87 virtual ~NotificationProviderNotifyOnClickedFunction();
88
89 private:
90 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked",
91 NOTIFICATIONPROVIDER_NOTIFYONCLICKED);
92
93 // UIThreadExtensionFunction implementation.
94 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
95 };
96
97 // Implememtation of NotifyOnButtonClicked function of the API. It will inform
98 // the
99 // notifier that the user pressed a button in the notification sent from that
100 // notifier.
101 class NotificationProviderNotifyOnButtonClickedFunction
102 : public ChromeUIThreadExtensionFunction {
103 public:
104 NotificationProviderNotifyOnButtonClickedFunction();
105
106 protected:
107 virtual ~NotificationProviderNotifyOnButtonClickedFunction();
108
109 private:
110 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnButtonClicked",
111 NOTIFICATIONPROVIDER_NOTIFYONBUTTONCLICKED);
112
113 // UIThreadExtensionFunction implementation.
114 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
115 };
116
117 // Implememtation of NotifyOnPermissionLevelChanged function of the API. It will
118 // inform the notifier that the user changed the permission level of that
119 // notifier.
120 class NotificationProviderNotifyOnPermissionLevelChangedFunction
121 : public ChromeUIThreadExtensionFunction {
122 public:
123 NotificationProviderNotifyOnPermissionLevelChangedFunction();
124
125 protected:
126 virtual ~NotificationProviderNotifyOnPermissionLevelChangedFunction();
127
128 private:
129 DECLARE_EXTENSION_FUNCTION(
130 "notificationProvider.notifyOnPermissionLevelChanged",
131 NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED);
132
133 // UIThreadExtensionFunction implementation.
134 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
135 };
136
137 // Implememtation of NotifyOnShowSettings function of the API. It will inform
138 // the notifier that the user clicked on advanced settings of that notifier.
139 class NotificationProviderNotifyOnShowSettingsFunction
140 : public ChromeUIThreadExtensionFunction {
141 public:
142 NotificationProviderNotifyOnShowSettingsFunction();
143
144 protected:
145 virtual ~NotificationProviderNotifyOnShowSettingsFunction();
146
147 private:
148 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings",
149 NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS);
150
151 // UIThreadExtensionFunction implementation.
152 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
153 };
154
155 // Implememtation of GetNotifier function of the API. It will get the notifier
156 // object that corresponds to the notifier ID.
157 class NotificationProviderGetNotifierFunction
158 : public ChromeUIThreadExtensionFunction {
159 public:
160 NotificationProviderGetNotifierFunction();
161
162 protected:
163 virtual ~NotificationProviderGetNotifierFunction();
164
165 private:
166 DECLARE_EXTENSION_FUNCTION("notificationProvider.getNotifier",
167 NOTIFICATIONPROVIDER_GETNOTIFIER);
168
169 // UIThreadExtensionFunction implementation.
170 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
171 };
172
173 // Implememtation of GetAllNotifiers function of the API. It will get all the
174 // notifiers that would send notifications.
175 class NotificationProviderGetAllNotifiersFunction
176 : public ChromeUIThreadExtensionFunction {
177 public:
178 NotificationProviderGetAllNotifiersFunction();
179
180 protected:
181 virtual ~NotificationProviderGetAllNotifiersFunction();
182
183 private:
184 DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers",
185 NOTIFICATIONPROVIDER_GETALLNOTIFIERS);
186
187 // UIThreadExtensionFunction implementation.
188 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
189 };
190
191 } // namespace extensions
192
193 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROV IDER_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698