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

Side by Side Diff: chrome/browser/extensions/api/notification_provider/notification_provider_api.cc

Issue 356673003: Notification Provider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 #include "chrome/browser/extensions/api/notification_provider/notification_provi der_api.h"
6
7 #include "base/callback.h"
8 #include "base/guid.h"
9 #include "base/rand_util.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/common/chrome_version_info.h"
14 #include "extensions/browser/event_router.h"
15 #include "extensions/common/extension.h"
16 #include "extensions/common/features/feature.h"
17 #include "ui/base/layout.h"
18 #include "url/gurl.h"
19
20 namespace extensions {
21
22 NotificationProviderEventRouter::NotificationProviderEventRouter(
23 Profile* profile)
24 : profile_(profile) {
25 }
26
27 NotificationProviderEventRouter::~NotificationProviderEventRouter() {
28 }
29
30 void NotificationProviderEventRouter::CreateNotification(
31 const std::string& notification_provider_id,
32 const std::string& sender_id,
33 const std::string& notification_id,
34 const api::notifications::NotificationOptions& options) {
35 Create(notification_provider_id, sender_id, notification_id, options);
36 }
37
38 void NotificationProviderEventRouter::UpdateNotification(
39 const std::string& notification_provider_id,
40 const std::string& sender_id,
41 const std::string& notification_id,
42 const api::notifications::NotificationOptions& options) {
43 Update(notification_provider_id, sender_id, notification_id, options);
44 }
45 void NotificationProviderEventRouter::ClearNotification(
46 const std::string& notification_provider_id,
47 const std::string& sender_id,
48 const std::string& notification_id) {
49 Clear(notification_provider_id, sender_id, notification_id);
50 }
51
52 void NotificationProviderEventRouter::Create(
53 const std::string& notification_provider_id,
54 const std::string& sender_id,
55 const std::string& notification_id,
56 const api::notifications::NotificationOptions& options) {
57 scoped_ptr<base::ListValue> args =
58 api::notification_provider::OnCreated::Create(
59 sender_id, notification_id, options);
60
61 scoped_ptr<Event> event(new Event(
62 api::notification_provider::OnCreated::kEventName, args.Pass()));
63
64 EventRouter::Get(profile_)
65 ->DispatchEventToExtension(notification_provider_id, event.Pass());
66 }
67
68 void NotificationProviderEventRouter::Update(
69 const std::string& notification_provider_id,
70 const std::string& sender_id,
71 const std::string& notification_id,
72 const extensions::api::notifications::NotificationOptions& options) {
73 scoped_ptr<base::ListValue> args =
74 api::notification_provider::OnUpdated::Create(
75 sender_id, notification_id, options);
76
77 scoped_ptr<Event> event(new Event(
78 api::notification_provider::OnUpdated::kEventName, args.Pass()));
79
80 EventRouter::Get(profile_)
81 ->DispatchEventToExtension(notification_provider_id, event.Pass());
82 }
83
84 void NotificationProviderEventRouter::Clear(
85 const std::string& notification_provider_id,
86 const std::string& sender_id,
87 const std::string& notification_id) {
88 scoped_ptr<base::ListValue> args =
89 api::notification_provider::OnCleared::Create(sender_id, notification_id);
90
91 scoped_ptr<Event> event(new Event(
92 api::notification_provider::OnCleared::kEventName, args.Pass()));
93
94 EventRouter::Get(profile_)
95 ->DispatchEventToExtension(notification_provider_id, event.Pass());
96 }
97
98 NotificationProviderNotifyOnClearedFunction::
99 NotificationProviderNotifyOnClearedFunction() {
100 }
101
102 NotificationProviderNotifyOnClearedFunction::
103 ~NotificationProviderNotifyOnClearedFunction() {
104 }
105
106 ExtensionFunction::ResponseAction
107 NotificationProviderNotifyOnClearedFunction::Run() {
108 params_ = api::notification_provider::NotifyOnCleared::Params::Create(*args_);
109 EXTENSION_FUNCTION_VALIDATE(params_.get());
110
111 base::FundamentalValue* result = new base::FundamentalValue(true);
not at google - send to devlin 2014/07/29 20:09:38 for every function: it's better to use the generat
liyanhou 2014/07/30 17:19:24 Done.
112
113 return RespondNow(OneArgument(result));
114 }
115
116 NotificationProviderNotifyOnClickedFunction::
117 NotificationProviderNotifyOnClickedFunction() {
118 }
119
120 NotificationProviderNotifyOnClickedFunction::
121 ~NotificationProviderNotifyOnClickedFunction() {
122 }
123
124 ExtensionFunction::ResponseAction
125 NotificationProviderNotifyOnClickedFunction::Run() {
126 params_ = api::notification_provider::NotifyOnClicked::Params::Create(*args_);
127 EXTENSION_FUNCTION_VALIDATE(params_.get());
128
129 base::FundamentalValue* result = new base::FundamentalValue(true);
130
131 return RespondNow(OneArgument(result));
132 }
133
134 NotificationProviderNotifyOnButtonClickedFunction::
135 NotificationProviderNotifyOnButtonClickedFunction() {
136 }
137
138 NotificationProviderNotifyOnButtonClickedFunction::
139 ~NotificationProviderNotifyOnButtonClickedFunction() {
140 }
141
142 ExtensionFunction::ResponseAction
143 NotificationProviderNotifyOnButtonClickedFunction::Run() {
144 params_ =
145 api::notification_provider::NotifyOnButtonClicked::Params::Create(*args_);
146 EXTENSION_FUNCTION_VALIDATE(params_.get());
147
148 base::FundamentalValue* result = new base::FundamentalValue(true);
149
150 return RespondNow(OneArgument(result));
151 }
152
153 NotificationProviderNotifyOnPermissionLevelChangedFunction::
154 NotificationProviderNotifyOnPermissionLevelChangedFunction() {
155 }
156
157 NotificationProviderNotifyOnPermissionLevelChangedFunction::
158 ~NotificationProviderNotifyOnPermissionLevelChangedFunction() {
159 }
160
161 ExtensionFunction::ResponseAction
162 NotificationProviderNotifyOnPermissionLevelChangedFunction::Run() {
163 params_ = api::notification_provider::NotifyOnPermissionLevelChanged::Params::
164 Create(*args_);
165 EXTENSION_FUNCTION_VALIDATE(params_.get());
166
167 base::FundamentalValue* result = new base::FundamentalValue(true);
168
169 return RespondNow(OneArgument(result));
170 }
171
172 NotificationProviderNotifyOnShowSettingsFunction::
173 NotificationProviderNotifyOnShowSettingsFunction() {
174 }
175
176 NotificationProviderNotifyOnShowSettingsFunction::
177 ~NotificationProviderNotifyOnShowSettingsFunction() {
178 }
179
180 ExtensionFunction::ResponseAction
181 NotificationProviderNotifyOnShowSettingsFunction::Run() {
182 params_ =
183 api::notification_provider::NotifyOnShowSettings::Params::Create(*args_);
184 EXTENSION_FUNCTION_VALIDATE(params_.get());
185
186 base::FundamentalValue* result = new base::FundamentalValue(true);
187
188 return RespondNow(OneArgument(result));
189 }
190
191 NotificationProviderGetNotifierFunction::
192 NotificationProviderGetNotifierFunction() {
193 }
194
195 NotificationProviderGetNotifierFunction::
196 ~NotificationProviderGetNotifierFunction() {
197 }
198
199 ExtensionFunction::ResponseAction
200 NotificationProviderGetNotifierFunction::Run() {
201 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
202
203 return RespondNow(OneArgument(result.release()));
204 }
205
206 NotificationProviderGetAllNotifiersFunction::
207 NotificationProviderGetAllNotifiersFunction() {
208 }
209
210 NotificationProviderGetAllNotifiersFunction::
211 ~NotificationProviderGetAllNotifiersFunction() {
212 }
213
214 ExtensionFunction::ResponseAction
215 NotificationProviderGetAllNotifiersFunction::Run() {
216 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue());
217 scoped_ptr<base::ListValue> result(new base::ListValue());
218 result->Append(dictionary.release());
not at google - send to devlin 2014/07/29 20:09:38 for example, here the result could be nicer: retu
liyanhou 2014/07/30 17:19:25 Done.
219
220 return RespondNow(OneArgument(result.release()));
221 }
222
223 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698