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

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: added histogram values to histograms.xml 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 bool NotificationProviderNotifyOnClearedFunction::RunAsync() {
107 params_ = api::notification_provider::NotifyOnCleared::Params::Create(*args_);
108 EXTENSION_FUNCTION_VALIDATE(params_.get());
109
110 SendResponse(true);
111 return true;
112 }
113
114 NotificationProviderNotifyOnClickedFunction::
115 NotificationProviderNotifyOnClickedFunction() {
116 }
117
118 NotificationProviderNotifyOnClickedFunction::
119 ~NotificationProviderNotifyOnClickedFunction() {
120 }
121
122 bool NotificationProviderNotifyOnClickedFunction::RunAsync() {
123 params_ = api::notification_provider::NotifyOnClicked::Params::Create(*args_);
124 EXTENSION_FUNCTION_VALIDATE(params_.get());
125
126 SendResponse(true);
127 return true;
128 }
129
130 NotificationProviderNotifyOnButtonClickedFunction::
131 NotificationProviderNotifyOnButtonClickedFunction() {
132 }
133
134 NotificationProviderNotifyOnButtonClickedFunction::
135 ~NotificationProviderNotifyOnButtonClickedFunction() {
136 }
137
138 bool NotificationProviderNotifyOnButtonClickedFunction::RunAsync() {
139 params_ =
140 api::notification_provider::NotifyOnButtonClicked::Params::Create(*args_);
141 EXTENSION_FUNCTION_VALIDATE(params_.get());
142
143 SendResponse(true);
144 return true;
145 }
146
147 NotificationProviderNotifyOnPermissionLevelChangedFunction::
148 NotificationProviderNotifyOnPermissionLevelChangedFunction() {
149 }
150
151 NotificationProviderNotifyOnPermissionLevelChangedFunction::
152 ~NotificationProviderNotifyOnPermissionLevelChangedFunction() {
153 }
154
155 bool NotificationProviderNotifyOnPermissionLevelChangedFunction::RunAsync() {
156 params_ = api::notification_provider::NotifyOnPermissionLevelChanged::Params::
157 Create(*args_);
158 EXTENSION_FUNCTION_VALIDATE(params_.get());
159
160 SendResponse(true);
161 return true;
162 }
163
164 NotificationProviderNotifyOnShowSettingsFunction::
165 NotificationProviderNotifyOnShowSettingsFunction() {
166 }
167
168 NotificationProviderNotifyOnShowSettingsFunction::
169 ~NotificationProviderNotifyOnShowSettingsFunction() {
170 }
171
172 bool NotificationProviderNotifyOnShowSettingsFunction::RunAsync() {
173 params_ =
174 api::notification_provider::NotifyOnShowSettings::Params::Create(*args_);
175 EXTENSION_FUNCTION_VALIDATE(params_.get());
176
177 SendResponse(true);
178 return true;
179 }
180
181 NotificationProviderGetAllNotifiersFunction::
182 NotificationProviderGetAllNotifiersFunction() {
183 }
184
185 NotificationProviderGetAllNotifiersFunction::
186 ~NotificationProviderGetAllNotifiersFunction() {
187 }
188
189 bool NotificationProviderGetAllNotifiersFunction::RunAsync() {
190 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
191
192 SetResult(result.release());
193 SendResponse(true);
194 return true;
195 }
196
197 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698