Chromium Code Reviews| Index: chrome/browser/extensions/api/notification_provider/notification_provider_api.h |
| diff --git a/chrome/browser/extensions/api/notification_provider/notification_provider_api.h b/chrome/browser/extensions/api/notification_provider/notification_provider_api.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1836a307c871868e38d09f4d5d9a69d379a289ca |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/notification_provider/notification_provider_api.h |
| @@ -0,0 +1,204 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/extensions/chrome_extension_function.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/extensions/api/notification_provider.h" |
| +#include "extensions/browser/extension_function.h" |
| +#include "ui/message_center/notification_types.h" |
| + |
| +namespace extensions { |
| + |
| +// Send events to the client. This will send events onCreated, onUpdated and |
| +// onCleared to extensions/apps using this API. |
| +class NotificationProviderEventRouter { |
| + public: |
| + explicit NotificationProviderEventRouter(Profile* profile); |
| + virtual ~NotificationProviderEventRouter(); |
| + |
| + void CreateNotification( |
| + const std::string& notification_provider_id, |
| + const std::string& sender_id, |
| + const std::string& notification_id, |
| + const extensions::api::notifications::NotificationOptions& options); |
| + void UpdateNotification( |
| + const std::string& notification_provider_id, |
| + const std::string& sender_id, |
| + const std::string& notificaiton_id, |
| + const extensions::api::notifications::NotificationOptions& options); |
| + void ClearNotification(const std::string& notification_provider_id, |
| + const std::string& sender_id, |
| + const std::string& notification_id); |
| + |
| + private: |
| + void Create( |
| + const std::string& notification_provider_id, |
| + const std::string& sender_id, |
| + const std::string& notification_id, |
| + const extensions::api::notifications::NotificationOptions& options); |
| + void Update( |
| + const std::string& notification_provider_id, |
| + const std::string& sender_id, |
| + const std::string& notification_id, |
| + const extensions::api::notifications::NotificationOptions& options); |
| + void Clear(const std::string& notification_provider_id, |
| + const std::string& sender_id, |
| + const std::string& notification_id); |
| + |
| + Profile* profile_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NotificationProviderEventRouter); |
| +}; |
| + |
| +// Implememtation of NotifyOnCleared function of the API. It will inform the |
| +// notifier that the user cleared a notification sent from that notifier. |
| +class NotificationProviderNotifyOnClearedFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderNotifyOnClearedFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderNotifyOnClearedFunction(); |
| + |
| + private: |
| + 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.
|
| + |
| + DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared", |
| + NOTIFICATIONPROVIDER_NOTIFYONCLEARED); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +// Implememtation of NotifyOnClicked function of the API. It will inform the |
| +// notifier that the user clicked in a non-button area of a notification sent |
| +// from that notifier. |
| +class NotificationProviderNotifyOnClickedFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderNotifyOnClickedFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderNotifyOnClickedFunction(); |
| + |
| + private: |
| + scoped_ptr<api::notification_provider::NotifyOnClicked::Params> params_; |
| + |
| + DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked", |
| + NOTIFICATIONPROVIDER_NOTIFYONCLICKED); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +// Implememtation of NotifyOnButtonClicked function of the API. It will inform |
| +// the |
| +// notifier that the user pressed a button in the notification sent from that |
| +// notifier. |
| +class NotificationProviderNotifyOnButtonClickedFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderNotifyOnButtonClickedFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderNotifyOnButtonClickedFunction(); |
| + |
| + private: |
| + scoped_ptr<api::notification_provider::NotifyOnButtonClicked::Params> params_; |
| + |
| + DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnButtonClicked", |
| + NOTIFICATIONPROVIDER_NOTIFYONBUTTONCLICKED); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +// Implememtation of NotifyOnPermissionLevelChanged function of the API. It will |
| +// inform the notifier that the user changed the permission level of that |
| +// notifier. |
| +class NotificationProviderNotifyOnPermissionLevelChangedFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderNotifyOnPermissionLevelChangedFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderNotifyOnPermissionLevelChangedFunction(); |
| + |
| + private: |
| + scoped_ptr<api::notification_provider::NotifyOnPermissionLevelChanged::Params> |
| + params_; |
| + |
| + DECLARE_EXTENSION_FUNCTION( |
| + "notificationProvider.notifyOnPermissionLevelChanged", |
| + NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +// Implememtation of NotifyOnShowSettings function of the API. It will inform |
| +// the notifier that the user clicked on advanced settings of that notifier. |
| +class NotificationProviderNotifyOnShowSettingsFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderNotifyOnShowSettingsFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderNotifyOnShowSettingsFunction(); |
| + |
| + private: |
| + scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params_; |
| + |
| + DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings", |
| + NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +// Implememtation of GetNotifier function of the API. It will get the notifier |
| +// object that corresponds to the notifier ID. |
| +class NotificationProviderGetNotifierFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderGetNotifierFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderGetNotifierFunction(); |
| + |
| + private: |
| + DECLARE_EXTENSION_FUNCTION("notificationProvider.getNotifier", |
| + NOTIFICATIONPROVIDER_GETNOTIFIER); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +// Implememtation of GetAllNotifiers function of the API. It will get all the |
| +// notifiers that would send notifications. |
| +class NotificationProviderGetAllNotifiersFunction |
| + : public ChromeUIThreadExtensionFunction { |
| + public: |
| + NotificationProviderGetAllNotifiersFunction(); |
| + |
| + protected: |
| + virtual ~NotificationProviderGetAllNotifiersFunction(); |
| + |
| + private: |
| + DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers", |
| + NOTIFICATIONPROVIDER_GETALLNOTIFIERS); |
| + |
| + // UIThreadExtensionFunction implementation. |
| + virtual ExtensionFunction::ResponseAction Run() OVERRIDE; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_ |