Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / notifications / notifications_api.h
blobb3ef00b9f2bd98571e7592900b0b96376a4fca81
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h"
12 #include "chrome/common/extensions/api/notifications.h"
13 #include "extensions/browser/extension_function.h"
14 #include "ui/message_center/notification_types.h"
16 class Notification;
18 namespace extensions {
20 class NotificationsApiFunction : public ChromeAsyncExtensionFunction {
21 public:
22 // Whether the current extension and channel allow the API. Public for
23 // testing.
24 bool IsNotificationsApiAvailable();
26 protected:
27 NotificationsApiFunction();
28 ~NotificationsApiFunction() override;
30 bool CreateNotification(const std::string& id,
31 api::notifications::NotificationOptions* options);
32 bool UpdateNotification(const std::string& id,
33 api::notifications::NotificationOptions* options,
34 Notification* notification);
36 bool IsNotificationsApiEnabled() const;
38 bool AreExtensionNotificationsAllowed() const;
40 // Returns true if the API function is still allowed to run even when the
41 // notifications for a notifier have been disabled.
42 virtual bool CanRunWhileDisabled() const;
44 // Called inside of RunAsync.
45 virtual bool RunNotificationsApi() = 0;
47 // UITHreadExtensionFunction:
48 bool RunAsync() override;
50 message_center::NotificationType MapApiTemplateTypeToType(
51 api::notifications::TemplateType type);
54 class NotificationsCreateFunction : public NotificationsApiFunction {
55 public:
56 NotificationsCreateFunction();
58 // NotificationsApiFunction:
59 bool RunNotificationsApi() override;
61 protected:
62 ~NotificationsCreateFunction() override;
64 private:
65 scoped_ptr<api::notifications::Create::Params> params_;
67 DECLARE_EXTENSION_FUNCTION("notifications.create", NOTIFICATIONS_CREATE)
70 class NotificationsUpdateFunction : public NotificationsApiFunction {
71 public:
72 NotificationsUpdateFunction();
74 // NotificationsApiFunction:
75 bool RunNotificationsApi() override;
77 protected:
78 ~NotificationsUpdateFunction() override;
80 private:
81 scoped_ptr<api::notifications::Update::Params> params_;
83 DECLARE_EXTENSION_FUNCTION("notifications.update", NOTIFICATIONS_UPDATE)
86 class NotificationsClearFunction : public NotificationsApiFunction {
87 public:
88 NotificationsClearFunction();
90 // NotificationsApiFunction:
91 bool RunNotificationsApi() override;
93 protected:
94 ~NotificationsClearFunction() override;
96 private:
97 scoped_ptr<api::notifications::Clear::Params> params_;
99 DECLARE_EXTENSION_FUNCTION("notifications.clear", NOTIFICATIONS_CLEAR)
102 class NotificationsGetAllFunction : public NotificationsApiFunction {
103 public:
104 NotificationsGetAllFunction();
106 // NotificationsApiFunction:
107 bool RunNotificationsApi() override;
109 protected:
110 ~NotificationsGetAllFunction() override;
112 private:
113 DECLARE_EXTENSION_FUNCTION("notifications.getAll", NOTIFICATIONS_GET_ALL)
116 class NotificationsGetPermissionLevelFunction
117 : public NotificationsApiFunction {
118 public:
119 NotificationsGetPermissionLevelFunction();
121 // NotificationsApiFunction:
122 bool CanRunWhileDisabled() const override;
123 bool RunNotificationsApi() override;
125 protected:
126 ~NotificationsGetPermissionLevelFunction() override;
128 private:
129 DECLARE_EXTENSION_FUNCTION("notifications.getPermissionLevel",
130 NOTIFICATIONS_GET_ALL)
133 } // namespace extensions
135 #endif // CHROME_BROWSER_EXTENSIONS_API_NOTIFICATIONS_NOTIFICATIONS_API_H_