Chromium Code Reviews| 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 ChromeUIThreadExtensionFunction { | |
| 64 public: | |
| 65 NotificationProviderNotifyOnClearedFunction(); | |
| 66 | |
| 67 protected: | |
| 68 virtual ~NotificationProviderNotifyOnClearedFunction(); | |
| 69 | |
| 70 private: | |
| 71 scoped_ptr<api::notification_provider::NotifyOnCleared::Params> params_; | |
|
not at google - send to devlin
2014/07/29 20:09:38
for every function: It's unlikely that you'll actu
liyanhou
2014/07/30 17:19:25
Done.
| |
| 72 | |
| 73 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared", | |
| 74 NOTIFICATIONPROVIDER_NOTIFYONCLEARED); | |
| 75 | |
| 76 // UIThreadExtensionFunction implementation. | |
| 77 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 78 }; | |
| 79 | |
| 80 // Implememtation of NotifyOnClicked function of the API. It will inform the | |
| 81 // notifier that the user clicked in a non-button area of a notification sent | |
| 82 // from that notifier. | |
| 83 class NotificationProviderNotifyOnClickedFunction | |
| 84 : public ChromeUIThreadExtensionFunction { | |
| 85 public: | |
| 86 NotificationProviderNotifyOnClickedFunction(); | |
| 87 | |
| 88 protected: | |
| 89 virtual ~NotificationProviderNotifyOnClickedFunction(); | |
| 90 | |
| 91 private: | |
| 92 scoped_ptr<api::notification_provider::NotifyOnClicked::Params> params_; | |
| 93 | |
| 94 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked", | |
| 95 NOTIFICATIONPROVIDER_NOTIFYONCLICKED); | |
| 96 | |
| 97 // UIThreadExtensionFunction implementation. | |
| 98 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 99 }; | |
| 100 | |
| 101 // Implememtation of NotifyOnButtonClicked function of the API. It will inform | |
| 102 // the | |
| 103 // notifier that the user pressed a button in the notification sent from that | |
| 104 // notifier. | |
| 105 class NotificationProviderNotifyOnButtonClickedFunction | |
| 106 : public ChromeUIThreadExtensionFunction { | |
| 107 public: | |
| 108 NotificationProviderNotifyOnButtonClickedFunction(); | |
| 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 // UIThreadExtensionFunction implementation. | |
| 120 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 121 }; | |
| 122 | |
| 123 // Implememtation of NotifyOnPermissionLevelChanged function of the API. It will | |
| 124 // inform the notifier that the user changed the permission level of that | |
| 125 // notifier. | |
| 126 class NotificationProviderNotifyOnPermissionLevelChangedFunction | |
| 127 : public ChromeUIThreadExtensionFunction { | |
| 128 public: | |
| 129 NotificationProviderNotifyOnPermissionLevelChangedFunction(); | |
| 130 | |
| 131 protected: | |
| 132 virtual ~NotificationProviderNotifyOnPermissionLevelChangedFunction(); | |
| 133 | |
| 134 private: | |
| 135 scoped_ptr<api::notification_provider::NotifyOnPermissionLevelChanged::Params> | |
| 136 params_; | |
| 137 | |
| 138 DECLARE_EXTENSION_FUNCTION( | |
| 139 "notificationProvider.notifyOnPermissionLevelChanged", | |
| 140 NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED); | |
| 141 | |
| 142 // UIThreadExtensionFunction implementation. | |
| 143 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 144 }; | |
| 145 | |
| 146 // Implememtation of NotifyOnShowSettings function of the API. It will inform | |
| 147 // the notifier that the user clicked on advanced settings of that notifier. | |
| 148 class NotificationProviderNotifyOnShowSettingsFunction | |
| 149 : public ChromeUIThreadExtensionFunction { | |
| 150 public: | |
| 151 NotificationProviderNotifyOnShowSettingsFunction(); | |
| 152 | |
| 153 protected: | |
| 154 virtual ~NotificationProviderNotifyOnShowSettingsFunction(); | |
| 155 | |
| 156 private: | |
| 157 scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params_; | |
| 158 | |
| 159 DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings", | |
| 160 NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS); | |
| 161 | |
| 162 // UIThreadExtensionFunction implementation. | |
| 163 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 164 }; | |
| 165 | |
| 166 // Implememtation of GetNotifier function of the API. It will get the notifier | |
| 167 // object that corresponds to the notifier ID. | |
| 168 class NotificationProviderGetNotifierFunction | |
| 169 : public ChromeUIThreadExtensionFunction { | |
| 170 public: | |
| 171 NotificationProviderGetNotifierFunction(); | |
| 172 | |
| 173 protected: | |
| 174 virtual ~NotificationProviderGetNotifierFunction(); | |
| 175 | |
| 176 private: | |
| 177 DECLARE_EXTENSION_FUNCTION("notificationProvider.getNotifier", | |
| 178 NOTIFICATIONPROVIDER_GETNOTIFIER); | |
| 179 | |
| 180 // UIThreadExtensionFunction implementation. | |
| 181 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 182 }; | |
| 183 | |
| 184 // Implememtation of GetAllNotifiers function of the API. It will get all the | |
| 185 // notifiers that would send notifications. | |
| 186 class NotificationProviderGetAllNotifiersFunction | |
| 187 : public ChromeUIThreadExtensionFunction { | |
| 188 public: | |
| 189 NotificationProviderGetAllNotifiersFunction(); | |
| 190 | |
| 191 protected: | |
| 192 virtual ~NotificationProviderGetAllNotifiersFunction(); | |
| 193 | |
| 194 private: | |
| 195 DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers", | |
| 196 NOTIFICATIONPROVIDER_GETALLNOTIFIERS); | |
| 197 | |
| 198 // UIThreadExtensionFunction implementation. | |
| 199 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | |
| 200 }; | |
| 201 | |
| 202 } // namespace extensions | |
| 203 | |
| 204 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROV IDER_API_H_ | |
| OLD | NEW |