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..3536724535df54a88d1421676898af75d3f2c4af |
--- /dev/null |
+++ b/chrome/browser/extensions/api/notification_provider/notification_provider_api.h |
@@ -0,0 +1,180 @@ |
+// 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 ChromeAsyncExtensionFunction { |
+ public: |
+ NotificationProviderNotifyOnClearedFunction(); |
+ |
+ virtual bool RunAsync() OVERRIDE; |
+ |
+ protected: |
+ virtual ~NotificationProviderNotifyOnClearedFunction(); |
+ |
+ private: |
+ scoped_ptr<api::notification_provider::NotifyOnCleared::Params> params_; |
+ |
+ DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnCleared", |
+ NOTIFICATIONPROVIDER_NOTIFYONCLEARED) |
+}; |
+ |
+// 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 ChromeAsyncExtensionFunction { |
+ public: |
+ NotificationProviderNotifyOnClickedFunction(); |
+ |
+ virtual bool RunAsync() OVERRIDE; |
+ |
+ protected: |
+ virtual ~NotificationProviderNotifyOnClickedFunction(); |
+ |
+ private: |
+ scoped_ptr<api::notification_provider::NotifyOnClicked::Params> params_; |
+ |
+ DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnClicked", |
+ NOTIFICATIONPROVIDER_NOTIFYONCLICKED) |
+}; |
+ |
+// 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 ChromeAsyncExtensionFunction { |
+ public: |
+ NotificationProviderNotifyOnButtonClickedFunction(); |
+ |
+ virtual bool RunAsync() OVERRIDE; |
+ |
+ protected: |
+ virtual ~NotificationProviderNotifyOnButtonClickedFunction(); |
+ |
+ private: |
+ scoped_ptr<api::notification_provider::NotifyOnButtonClicked::Params> params_; |
+ |
+ DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnButtonClicked", |
+ NOTIFICATIONPROVIDER_NOTIFYONBUTTONCLICKED) |
+}; |
+ |
+// 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 ChromeAsyncExtensionFunction { |
+ public: |
+ NotificationProviderNotifyOnPermissionLevelChangedFunction(); |
+ |
+ virtual bool RunAsync() OVERRIDE; |
+ |
+ protected: |
+ virtual ~NotificationProviderNotifyOnPermissionLevelChangedFunction(); |
+ |
+ private: |
+ scoped_ptr<api::notification_provider::NotifyOnPermissionLevelChanged::Params> |
+ params_; |
+ |
+ DECLARE_EXTENSION_FUNCTION( |
+ "notificationProvider.notifyOnPermissionLevelChanged", |
+ NOTIFICATIONPROVIDER_NOTIFYONPERMISSIONLEVELCHANGED) |
+}; |
+ |
+// 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 ChromeAsyncExtensionFunction { |
+ public: |
+ NotificationProviderNotifyOnShowSettingsFunction(); |
+ |
+ virtual bool RunAsync() OVERRIDE; |
+ |
+ protected: |
+ virtual ~NotificationProviderNotifyOnShowSettingsFunction(); |
+ |
+ private: |
+ scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params_; |
+ |
+ DECLARE_EXTENSION_FUNCTION("notificationProvider.notifyOnShowSettings", |
+ NOTIFICATIONPROVIDER_NOTIFYONSHOWSETTINGS) |
+}; |
+ |
+// Implememtation of GetAllNotifiers function of the API. It will get all the |
+// notifiers that would send notifications. |
+class NotificationProviderGetAllNotifiersFunction |
+ : public ChromeAsyncExtensionFunction { |
+ public: |
+ NotificationProviderGetAllNotifiersFunction(); |
+ |
+ virtual bool RunAsync() OVERRIDE; |
+ |
+ protected: |
+ virtual ~NotificationProviderGetAllNotifiersFunction(); |
+ |
+ private: |
+ DECLARE_EXTENSION_FUNCTION("notificationProvider.getAllNotifiers", |
+ NOTIFICATIONPROVIDER_GETALLNOTIFIERS) |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATION_PROVIDER_NOTIFICATION_PROVIDER_API_H_ |