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 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); |
| 39 |
| 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); |
| 52 |
| 53 Profile* profile_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(NotificationProviderEventRouter); |
| 56 }; |
| 57 |
| 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(); |
| 64 |
| 65 protected: |
| 66 virtual ~NotificationProviderNotifyOnClearedFunction(); |
| 67 |
| 68 private: |
| 69 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared", |
| 70 NOTIFICATIONPROVIDER_NOTIFYONCLEARED); |
| 71 |
| 72 // UIThreadExtensionFunction implementation. |
| 73 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 74 }; |
| 75 |
| 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(); |
| 83 |
| 84 protected: |
| 85 virtual ~NotificationProviderNotifyOnClickedFunction(); |
| 86 |
| 87 private: |
| 88 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked", |
| 89 NOTIFICATIONPROVIDER_NOTIFYONCLICKED); |
| 90 |
| 91 // UIThreadExtensionFunction implementation. |
| 92 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 93 }; |
| 94 |
| 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(); |
| 103 |
| 104 protected: |
| 105 virtual ~NotificationProviderNotifyOnButtonClickedFunction(); |
| 106 |
| 107 private: |
| 108 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnButtonClicked", |
| 109 NOTIFICATIONPROVIDER_NOTIFYONBUTTONCLICKED); |
| 110 |
| 111 // UIThreadExtensionFunction implementation. |
| 112 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 113 }; |
| 114 |
| 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(); |
| 122 |
| 123 protected: |
| 124 virtual ~NotificationProviderNotifyOnPermissionLevelChangedFunction(); |
| 125 |
| 126 private: |
| 127 DECLARE_EXTENSION_FUNCTION( |
| 128 "notificationProvider.notifyOnPermissionLevelChanged", |
| 129 NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED); |
| 130 |
| 131 // UIThreadExtensionFunction implementation. |
| 132 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 133 }; |
| 134 |
| 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(); |
| 141 |
| 142 protected: |
| 143 virtual ~NotificationProviderNotifyOnShowSettingsFunction(); |
| 144 |
| 145 private: |
| 146 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings", |
| 147 NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS); |
| 148 |
| 149 // UIThreadExtensionFunction implementation. |
| 150 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 151 }; |
| 152 |
| 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(); |
| 159 |
| 160 protected: |
| 161 virtual ~NotificationProviderGetNotifierFunction(); |
| 162 |
| 163 private: |
| 164 DECLARE_EXTENSION_FUNCTION("notificationProvider.getNotifier", |
| 165 NOTIFICATIONPROVIDER_GETNOTIFIER); |
| 166 |
| 167 // UIThreadExtensionFunction implementation. |
| 168 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 169 }; |
| 170 |
| 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(); |
| 177 |
| 178 protected: |
| 179 virtual ~NotificationProviderGetAllNotifiersFunction(); |
| 180 |
| 181 private: |
| 182 DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers", |
| 183 NOTIFICATIONPROVIDER_GETALLNOTIFIERS); |
| 184 |
| 185 // UIThreadExtensionFunction implementation. |
| 186 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| 187 }; |
| 188 |
| 189 } // namespace extensions |
| 190 |
| 191 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROV
IDER_API_H_ |
OLD | NEW |