OLD | NEW |
---|---|
(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); | |
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 ChromeAsyncExtensionFunction { | |
not at google - send to devlin
2014/07/28 21:32:40
Implementing ChromeAsyncExtensionFunction is depre
liyanhou
2014/07/29 18:26:54
Done.
| |
64 public: | |
65 NotificationProviderNotifyOnClearedFunction(); | |
66 | |
67 virtual bool RunAsync() OVERRIDE; | |
68 | |
69 protected: | |
70 virtual ~NotificationProviderNotifyOnClearedFunction(); | |
71 | |
72 private: | |
73 scoped_ptr<api::notification_provider::NotifyOnCleared::Params> params_; | |
74 | |
75 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared", | |
76 NOTIFICATIONPROVIDER_NOTIFYONCLEARED) | |
77 }; | |
78 | |
79 // Implememtation of NotifyOnClicked function of the API. It will inform the | |
80 // notifier that the user clicked in a non-button area of a notification sent | |
81 // from that notifier. | |
82 class NotificationProviderNotifyOnClickedFunction | |
83 : public ChromeAsyncExtensionFunction { | |
84 public: | |
85 NotificationProviderNotifyOnClickedFunction(); | |
86 | |
87 virtual bool RunAsync() OVERRIDE; | |
88 | |
89 protected: | |
90 virtual ~NotificationProviderNotifyOnClickedFunction(); | |
91 | |
92 private: | |
93 scoped_ptr<api::notification_provider::NotifyOnClicked::Params> params_; | |
94 | |
95 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked", | |
96 NOTIFICATIONPROVIDER_NOTIFYONCLICKED) | |
97 }; | |
98 | |
99 // Implememtation of NotifyOnButtonClicked function of the API. It will inform | |
100 // the | |
101 // notifier that the user pressed a button in the notification sent from that | |
102 // notifier. | |
103 class NotificationProviderNotifyOnButtonClickedFunction | |
104 : public ChromeAsyncExtensionFunction { | |
105 public: | |
106 NotificationProviderNotifyOnButtonClickedFunction(); | |
107 | |
108 virtual bool RunAsync() OVERRIDE; | |
109 | |
110 protected: | |
111 virtual ~NotificationProviderNotifyOnButtonClickedFunction(); | |
112 | |
113 private: | |
114 scoped_ptr<api::notification_provider::NotifyOnButtonClicked::Params> params_; | |
115 | |
116 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnButtonClicked", | |
117 NOTIFICATIONPROVIDER_NOTIFYONBUTTONCLICKED) | |
118 }; | |
119 | |
120 // Implememtation of NotifyOnPermissionLevelChanged function of the API. It will | |
121 // inform the notifier that the user changed the permission level of that | |
122 // notifier. | |
123 class NotificationProviderNotifyOnPermissionLevelChangedFunction | |
124 : public ChromeAsyncExtensionFunction { | |
125 public: | |
126 NotificationProviderNotifyOnPermissionLevelChangedFunction(); | |
127 | |
128 virtual bool RunAsync() OVERRIDE; | |
129 | |
130 protected: | |
131 virtual ~NotificationProviderNotifyOnPermissionLevelChangedFunction(); | |
132 | |
133 private: | |
134 scoped_ptr<api::notification_provider::NotifyOnPermissionLevelChanged::Params> | |
135 params_; | |
136 | |
137 DECLARE_EXTENSION_FUNCTION( | |
138 "notificationProvider.notifyOnPermissionLevelChanged", | |
139 NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED) | |
140 }; | |
141 | |
142 // Implememtation of NotifyOnShowSettings function of the API. It will inform | |
143 // the notifier that the user clicked on advanced settings of that notifier. | |
144 class NotificationProviderNotifyOnShowSettingsFunction | |
145 : public ChromeAsyncExtensionFunction { | |
146 public: | |
147 NotificationProviderNotifyOnShowSettingsFunction(); | |
148 | |
149 virtual bool RunAsync() OVERRIDE; | |
150 | |
151 protected: | |
152 virtual ~NotificationProviderNotifyOnShowSettingsFunction(); | |
153 | |
154 private: | |
155 scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params_; | |
156 | |
157 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings", | |
158 NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS) | |
159 }; | |
160 | |
161 // Implememtation of GetAllNotifiers function of the API. It will get all the | |
162 // notifiers that would send notifications. | |
163 class NotificationProviderGetAllNotifiersFunction | |
164 : public ChromeAsyncExtensionFunction { | |
165 public: | |
166 NotificationProviderGetAllNotifiersFunction(); | |
167 | |
168 virtual bool RunAsync() OVERRIDE; | |
169 | |
170 protected: | |
171 virtual ~NotificationProviderGetAllNotifiersFunction(); | |
172 | |
173 private: | |
174 DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers", | |
175 NOTIFICATIONPROVIDER_GETALLNOTIFIERS) | |
176 }; | |
177 | |
178 } // namespace extensions | |
179 | |
180 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROV IDER_API_H_ | |
OLD | NEW |