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

Side by Side Diff: chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.h

Issue 356673003: Notification Provider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bug fix 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_CUSTOM_NOTIFICATION_CENTER_CUSTOM_NOTIFICA TION_CENTER_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_CUSTOM_NOTIFICATION_CENTER_CUSTOM_NOTIFICA TION_CENTER_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/custom_notification_center.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 CustomNotificationCenterEventRouter {
22 public:
23 explicit CustomNotificationCenterEventRouter(Profile* profile);
24 virtual ~CustomNotificationCenterEventRouter();
25
26 void CreateNotification(
27 const std::string& custom_notification_center_id,
28 const std::string& sender_id,
29 const std::string& notification_id,
30 const extensions::api::custom_notification_center::NotificationContent&
31 content);
32 void UpdateNotification(
33 const std::string& custom_notification_center_id,
34 const std::string& sender_id,
35 const std::string& notificaiton_id,
36 const extensions::api::custom_notification_center::NotificationContent&
37 content);
38 void ClearNotification(const std::string& custom_notification_center_id,
39 const std::string& sender_id,
40 const std::string& notification_id);
41
42 private:
43 void Create(
44 const std::string& custom_notification_center_id,
45 const std::string& sender_id,
46 const std::string& notification_id,
47 const extensions::api::custom_notification_center::NotificationContent&
48 content);
49 void Update(
50 const std::string& custom_notification_center_id,
51 const std::string& sender_id,
52 const std::string& notification_id,
53 const extensions::api::custom_notification_center::NotificationContent&
54 content);
55 void Clear(const std::string& custom_notification_center_id,
56 const std::string& sender_id,
57 const std::string& notification_id);
58
59 Profile* profile_;
60
61 DISALLOW_COPY_AND_ASSIGN(CustomNotificationCenterEventRouter);
62 };
63
64 // Implememtation of SendOnClear function of the API. It will notify the
65 // notification sender about the user action.
66 class CustomNotificationCenterSendOnClearFunction
67 : public ChromeAsyncExtensionFunction {
68 public:
69 CustomNotificationCenterSendOnClearFunction();
70
71 virtual bool RunAsync() OVERRIDE;
72
73 protected:
74 virtual ~CustomNotificationCenterSendOnClearFunction();
75
76 private:
77 scoped_ptr<api::custom_notification_center::SendOnClear::Params> params_;
78
79 DECLARE_EXTENSION_FUNCTION("customNotificationCenter.sendOnClear",
80 CUSTOMNOTIFICATIONCENTER_SENDONCLEAR)
81 };
82
83 // Implememtation of SendOnClick function of the API. It will notify the
84 // notification sender about the user action.
85 class CustomNotificationCenterSendOnClickFunction
86 : public ChromeAsyncExtensionFunction {
87 public:
88 CustomNotificationCenterSendOnClickFunction();
89
90 virtual bool RunAsync() OVERRIDE;
91
92 protected:
93 virtual ~CustomNotificationCenterSendOnClickFunction();
94
95 private:
96 scoped_ptr<api::custom_notification_center::SendOnClick::Params> params_;
97
98 DECLARE_EXTENSION_FUNCTION("customNotificationCenter.sendOnClick",
99 CUSTOMNOTIFICATIONCENTER_SENDONCLICK)
100 };
101
102 // Implememtation of SendOnButtonClick function of the API. It will notify the
103 // notification sender about the user action.
104 class CustomNotificationCenterSendOnButtonClickFunction
105 : public ChromeAsyncExtensionFunction {
106 public:
107 CustomNotificationCenterSendOnButtonClickFunction();
108
109 virtual bool RunAsync() OVERRIDE;
110
111 protected:
112 virtual ~CustomNotificationCenterSendOnButtonClickFunction();
113
114 private:
115 scoped_ptr<api::custom_notification_center::SendOnButtonClick::Params>
116 params_;
117
118 DECLARE_EXTENSION_FUNCTION("customNotificationCenter.sendOnButtonClick",
119 CUSTOMNOTIFICATIONCENTER_SENDONBUTTONCLICK)
120 };
121
122 // Implememtation of NotifyPermissionLevelChanged function of the API.
123 // It will notify the notification sender about the user action.
124 class CustomNotificationCenterNotifyPermissionLevelChangedFunction
125 : public ChromeAsyncExtensionFunction {
126 public:
127 CustomNotificationCenterNotifyPermissionLevelChangedFunction();
128
129 virtual bool RunAsync() OVERRIDE;
130
131 protected:
132 virtual ~CustomNotificationCenterNotifyPermissionLevelChangedFunction();
133
134 private:
135 scoped_ptr<
136 api::custom_notification_center::NotifyPermissionLevelChanged::Params>
137 params_;
138
139 DECLARE_EXTENSION_FUNCTION(
140 "customNotificationCenter.notifyPermissionLevelChanged",
141 CUSTOMNOTIFICATIONCENTER_NOTIFYPERMISSIONLEVELCHANGED)
142 };
143
144 } // namespace extensions
145
146 #endif // CHROME_BROWSER_EXTENSIONS_API_CUSTOM_NOTIFICATION_CENTER_CUSTOM_NOTIF ICATION_CENTER_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698