Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2108)

Unified Diff: chrome/browser/extensions/api/notification_provider/notification_provider_api.h

Issue 356673003: Notification Provider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/notification_provider/notification_provider_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..82c509c4a1505d728b15fe566b27b53f48b1b722
--- /dev/null
+++ b/chrome/browser/extensions/api/notification_provider/notification_provider_api.h
@@ -0,0 +1,191 @@
+// 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 api::notifications::NotificationOptions& options);
+ void UpdateNotification(
+ const std::string& notification_provider_id,
+ const std::string& sender_id,
+ const std::string& notificaiton_id,
+ const 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 api::notifications::NotificationOptions& options);
+ void Update(const std::string& notification_provider_id,
+ const std::string& sender_id,
+ const std::string& notification_id,
+ const 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:
+ 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:
+ 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:
+ 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:
+ 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:
+ 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_
« no previous file with comments | « no previous file | chrome/browser/extensions/api/notification_provider/notification_provider_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698