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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 12313115: Take notification API out of experimental. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missed one pathname. Created 7 years, 9 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/notification/notification_api.h" 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/extensions/event_names.h" 11 #include "chrome/browser/extensions/event_names.h"
12 #include "chrome/browser/extensions/event_router.h" 12 #include "chrome/browser/extensions/event_router.h"
13 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/notifications/desktop_notification_service.h" 14 #include "chrome/browser/notifications/desktop_notification_service.h"
15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
16 #include "chrome/browser/notifications/notification.h" 16 #include "chrome/browser/notifications/notification.h"
17 #include "chrome/browser/notifications/notification_ui_manager.h" 17 #include "chrome/browser/notifications/notification_ui_manager.h"
18 #include "chrome/common/chrome_version_info.h"
18 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/features/feature.h"
19 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
20 22
21 namespace extensions { 23 namespace extensions {
22 24
23 namespace { 25 namespace {
24 26
25 const char kResultKey[] = "result"; 27 const char kResultKey[] = "result";
26 28
27 class NotificationApiDelegate : public NotificationDelegate { 29 class NotificationsApiDelegate : public NotificationDelegate {
28 public: 30 public:
29 NotificationApiDelegate(ApiFunction* api_function, 31 NotificationsApiDelegate(ApiFunction* api_function,
30 Profile* profile, 32 Profile* profile,
31 const std::string& extension_id, 33 const std::string& extension_id,
32 const std::string& id) 34 const std::string& id)
33 : api_function_(api_function), 35 : api_function_(api_function),
34 profile_(profile), 36 profile_(profile),
35 extension_id_(extension_id), 37 extension_id_(extension_id),
36 id_(id), 38 id_(id),
37 scoped_id_(CreateScopedIdentifier(extension_id, id)) { 39 scoped_id_(CreateScopedIdentifier(extension_id, id)) {
38 DCHECK(api_function_); 40 DCHECK(api_function_);
39 } 41 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 80
79 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE { 81 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE {
80 // We're holding a reference to api_function_, so we know it'll be valid as 82 // We're holding a reference to api_function_, so we know it'll be valid as
81 // long as we are, and api_function_ (as a UIThreadExtensionFunction) 83 // long as we are, and api_function_ (as a UIThreadExtensionFunction)
82 // listens to content::NOTIFICATION_RENDER_VIEW_HOST_DELETED and will 84 // listens to content::NOTIFICATION_RENDER_VIEW_HOST_DELETED and will
83 // properly zero out its copy of render_view_host when the RVH goes away. 85 // properly zero out its copy of render_view_host when the RVH goes away.
84 return api_function_->render_view_host(); 86 return api_function_->render_view_host();
85 } 87 }
86 88
87 private: 89 private:
88 virtual ~NotificationApiDelegate() {} 90 virtual ~NotificationsApiDelegate() {}
89 91
90 void SendEvent(const std::string& name, scoped_ptr<ListValue> args) { 92 void SendEvent(const std::string& name, scoped_ptr<ListValue> args) {
91 scoped_ptr<Event> event(new Event(name, args.Pass())); 93 scoped_ptr<Event> event(new Event(name, args.Pass()));
92 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( 94 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
93 extension_id_, event.Pass()); 95 extension_id_, event.Pass());
94 } 96 }
95 97
96 scoped_ptr<ListValue> CreateBaseEventArgs() { 98 scoped_ptr<ListValue> CreateBaseEventArgs() {
97 scoped_ptr<ListValue> args(new ListValue()); 99 scoped_ptr<ListValue> args(new ListValue());
98 args->Append(Value::CreateStringValue(id_)); 100 args->Append(Value::CreateStringValue(id_));
99 return args.Pass(); 101 return args.Pass();
100 } 102 }
101 103
102 scoped_refptr<ApiFunction> api_function_; 104 scoped_refptr<ApiFunction> api_function_;
103 Profile* profile_; 105 Profile* profile_;
104 const std::string extension_id_; 106 const std::string extension_id_;
105 const std::string id_; 107 const std::string id_;
106 const std::string scoped_id_; 108 const std::string scoped_id_;
107 109
108 DISALLOW_COPY_AND_ASSIGN(NotificationApiDelegate); 110 DISALLOW_COPY_AND_ASSIGN(NotificationsApiDelegate);
109 }; 111 };
110 112
111 } // namespace 113 } // namespace
112 114
113 NotificationApiFunction::NotificationApiFunction() { 115 NotificationsApiFunction::NotificationsApiFunction() {
114 } 116 }
115 117
116 NotificationApiFunction::~NotificationApiFunction() { 118 NotificationsApiFunction::~NotificationsApiFunction() {
117 } 119 }
118 120
119 message_center::NotificationType 121 message_center::NotificationType
120 NotificationApiFunction::MapApiTemplateTypeToType( 122 NotificationsApiFunction::MapApiTemplateTypeToType(
dharcourt 2013/03/04 23:46:27 Nit: To match declaration order, the definition of
121 api::experimental_notification::TemplateType type) { 123 api::notifications::TemplateType type) {
122 switch (type) { 124 switch (type) {
123 case api::experimental_notification::TEMPLATE_TYPE_NONE: 125 case api::notifications::TEMPLATE_TYPE_NONE:
124 case api::experimental_notification::TEMPLATE_TYPE_SIMPLE: 126 case api::notifications::TEMPLATE_TYPE_SIMPLE:
125 return message_center::NOTIFICATION_TYPE_SIMPLE; 127 return message_center::NOTIFICATION_TYPE_SIMPLE;
126 case api::experimental_notification::TEMPLATE_TYPE_BASIC: 128 case api::notifications::TEMPLATE_TYPE_BASIC:
127 return message_center::NOTIFICATION_TYPE_BASE_FORMAT; 129 return message_center::NOTIFICATION_TYPE_BASE_FORMAT;
128 case api::experimental_notification::TEMPLATE_TYPE_IMAGE: 130 case api::notifications::TEMPLATE_TYPE_IMAGE:
129 return message_center::NOTIFICATION_TYPE_IMAGE; 131 return message_center::NOTIFICATION_TYPE_IMAGE;
130 case api::experimental_notification::TEMPLATE_TYPE_LIST: 132 case api::notifications::TEMPLATE_TYPE_LIST:
131 return message_center::NOTIFICATION_TYPE_MULTIPLE; 133 return message_center::NOTIFICATION_TYPE_MULTIPLE;
132 default: 134 default:
133 // Gracefully handle newer application code that is running on an older 135 // Gracefully handle newer application code that is running on an older
134 // runtime that doesn't recognize the requested template. 136 // runtime that doesn't recognize the requested template.
135 return message_center::NOTIFICATION_TYPE_BASE_FORMAT; 137 return message_center::NOTIFICATION_TYPE_BASE_FORMAT;
136 } 138 }
137 } 139 }
138 140
139 // If older notification runtime is used, MessageCenter is not built. 141 // If older notification runtime is used, MessageCenter is not built.
140 // Use simpler bridge then, ignoring all options. 142 // Use simpler bridge then, ignoring all options.
141 #if !defined (ENABLE_MESSAGE_CENTER) 143 #if !defined (ENABLE_MESSAGE_CENTER)
142 void NotificationApiFunction::CreateNotification( 144 void NotificationsApiFunction::CreateNotification(
143 const std::string& id, 145 const std::string& id,
144 api::experimental_notification::NotificationOptions* options) { 146 api::notifications::NotificationOptions* options) {
145 message_center::NotificationType type = 147 message_center::NotificationType type =
146 MapApiTemplateTypeToType(options->template_type); 148 MapApiTemplateTypeToType(options->template_type);
147 GURL icon_url(UTF8ToUTF16(options->icon_url)); 149 GURL icon_url(UTF8ToUTF16(options->icon_url));
148 string16 title(UTF8ToUTF16(options->title)); 150 string16 title(UTF8ToUTF16(options->title));
149 string16 message(UTF8ToUTF16(options->message)); 151 string16 message(UTF8ToUTF16(options->message));
150 152
151 // Ignore options if running on the old notification runtime. 153 // Ignore options if running on the old notification runtime.
152 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); 154 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue());
153 155
154 NotificationApiDelegate* api_delegate(new NotificationApiDelegate( 156 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
155 this, 157 this,
156 profile(), 158 profile(),
157 extension_->id(), 159 extension_->id(),
158 id)); // ownership is passed to Notification 160 id)); // ownership is passed to Notification
159 Notification notification(type, extension_->url(), icon_url, title, message, 161 Notification notification(type, extension_->url(), icon_url, title, message,
160 WebKit::WebTextDirectionDefault, 162 WebKit::WebTextDirectionDefault,
161 string16(), UTF8ToUTF16(api_delegate->id()), 163 string16(), UTF8ToUTF16(api_delegate->id()),
162 optional_fields.get(), api_delegate); 164 optional_fields.get(), api_delegate);
163 165
164 g_browser_process->notification_ui_manager()->Add(notification, profile()); 166 g_browser_process->notification_ui_manager()->Add(notification, profile());
165 } 167 }
166 #else // defined(ENABLE_MESSAGE_CENTER) 168 #else // defined(ENABLE_MESSAGE_CENTER)
167 void NotificationApiFunction::CreateNotification( 169 void NotificationsApiFunction::CreateNotification(
168 const std::string& id, 170 const std::string& id,
169 api::experimental_notification::NotificationOptions* options) { 171 api::notifications::NotificationOptions* options) {
170 message_center::NotificationType type = 172 message_center::NotificationType type =
171 MapApiTemplateTypeToType(options->template_type); 173 MapApiTemplateTypeToType(options->template_type);
172 GURL icon_url(UTF8ToUTF16(options->icon_url)); 174 GURL icon_url(UTF8ToUTF16(options->icon_url));
173 string16 title(UTF8ToUTF16(options->title)); 175 string16 title(UTF8ToUTF16(options->title));
174 string16 message(UTF8ToUTF16(options->message)); 176 string16 message(UTF8ToUTF16(options->message));
175 177
176 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); 178 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue());
177 179
178 // For all notification types. 180 // For all notification types.
179 if (options->priority.get()) 181 if (options->priority.get())
180 optional_fields->SetInteger(message_center::kPriorityKey, 182 optional_fields->SetInteger(message_center::kPriorityKey,
181 *options->priority); 183 *options->priority);
182 if (options->event_time.get()) 184 if (options->event_time.get())
183 optional_fields->SetDouble(message_center::kTimestampKey, 185 optional_fields->SetDouble(message_center::kTimestampKey,
184 *options->event_time); 186 *options->event_time);
185 if (options->buttons.get()) { 187 if (options->buttons.get()) {
186 if (options->buttons->size() > 0) { 188 if (options->buttons->size() > 0) {
187 linked_ptr<api::experimental_notification::NotificationButton> button = 189 linked_ptr<api::notifications::NotificationButton> button =
188 (*options->buttons)[0]; 190 (*options->buttons)[0];
189 optional_fields->SetString(message_center::kButtonOneTitleKey, 191 optional_fields->SetString(message_center::kButtonOneTitleKey,
190 UTF8ToUTF16(button->title)); 192 UTF8ToUTF16(button->title));
191 if (button->icon_url.get()) 193 if (button->icon_url.get())
192 optional_fields->SetString(message_center::kButtonOneIconUrlKey, 194 optional_fields->SetString(message_center::kButtonOneIconUrlKey,
193 UTF8ToUTF16(*button->icon_url)); 195 UTF8ToUTF16(*button->icon_url));
194 } 196 }
195 if (options->buttons->size() > 1) { 197 if (options->buttons->size() > 1) {
196 linked_ptr<api::experimental_notification::NotificationButton> button = 198 linked_ptr<api::notifications::NotificationButton> button =
197 (*options->buttons)[1]; 199 (*options->buttons)[1];
198 optional_fields->SetString(message_center::kButtonTwoTitleKey, 200 optional_fields->SetString(message_center::kButtonTwoTitleKey,
199 UTF8ToUTF16(button->title)); 201 UTF8ToUTF16(button->title));
200 if (button->icon_url.get()) 202 if (button->icon_url.get())
201 optional_fields->SetString(message_center::kButtonTwoIconUrlKey, 203 optional_fields->SetString(message_center::kButtonTwoIconUrlKey,
202 UTF8ToUTF16(*button->icon_url)); 204 UTF8ToUTF16(*button->icon_url));
203 } 205 }
204 } 206 }
205 if (options->expanded_message.get()) 207 if (options->expanded_message.get())
206 optional_fields->SetString(message_center::kExpandedMessageKey, 208 optional_fields->SetString(message_center::kExpandedMessageKey,
207 UTF8ToUTF16(*options->expanded_message)); 209 UTF8ToUTF16(*options->expanded_message));
208 210
209 // For image notifications (type == 'image'). 211 // For image notifications (type == 'image').
210 // TODO(dharcourt): Fail if (type == 'image' && !options->image_url.get()) 212 // TODO(dharcourt): Fail if (type == 'image' && !options->image_url.get())
211 // TODO(dharcourt): Fail if (type != 'image' && options->image_url.get()) 213 // TODO(dharcourt): Fail if (type != 'image' && options->image_url.get())
212 if (options->image_url.get()) 214 if (options->image_url.get())
213 optional_fields->SetString(message_center::kImageUrlKey, 215 optional_fields->SetString(message_center::kImageUrlKey,
214 UTF8ToUTF16(*options->image_url)); 216 UTF8ToUTF16(*options->image_url));
215 217
216 // For list notifications (type == 'multiple'). 218 // For list notifications (type == 'multiple').
217 // TODO(dharcourt): Fail if (type == 'multiple' && !options->items.get()) 219 // TODO(dharcourt): Fail if (type == 'multiple' && !options->items.get())
218 // TODO(dharcourt): Fail if (type != 'multiple' && options->items.get()) 220 // TODO(dharcourt): Fail if (type != 'multiple' && options->items.get())
219 if (options->items.get()) { 221 if (options->items.get()) {
220 base::ListValue* items = new base::ListValue(); 222 base::ListValue* items = new base::ListValue();
221 std::vector< 223 std::vector<
222 linked_ptr< 224 linked_ptr<
223 api::experimental_notification::NotificationItem> >::iterator i; 225 api::notifications::NotificationItem> >::iterator i;
224 for (i = options->items->begin(); i != options->items->end(); ++i) { 226 for (i = options->items->begin(); i != options->items->end(); ++i) {
225 base::DictionaryValue* item = new base::DictionaryValue(); 227 base::DictionaryValue* item = new base::DictionaryValue();
226 item->SetString(message_center::kItemTitleKey, 228 item->SetString(message_center::kItemTitleKey,
227 UTF8ToUTF16(i->get()->title)); 229 UTF8ToUTF16(i->get()->title));
228 item->SetString(message_center::kItemMessageKey, 230 item->SetString(message_center::kItemMessageKey,
229 UTF8ToUTF16(i->get()->message)); 231 UTF8ToUTF16(i->get()->message));
230 items->Append(item); 232 items->Append(item);
231 } 233 }
232 optional_fields->Set(message_center::kItemsKey, items); 234 optional_fields->Set(message_center::kItemsKey, items);
233 } 235 }
234 236
235 NotificationApiDelegate* api_delegate(new NotificationApiDelegate( 237 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
236 this, 238 this,
237 profile(), 239 profile(),
238 extension_->id(), 240 extension_->id(),
239 id)); // ownership is passed to Notification 241 id)); // ownership is passed to Notification
240 Notification notification(type, extension_->url(), icon_url, title, message, 242 Notification notification(type, extension_->url(), icon_url, title, message,
241 WebKit::WebTextDirectionDefault, 243 WebKit::WebTextDirectionDefault,
242 string16(), UTF8ToUTF16(api_delegate->id()), 244 string16(), UTF8ToUTF16(api_delegate->id()),
243 optional_fields.get(), api_delegate); 245 optional_fields.get(), api_delegate);
244 246
245 g_browser_process->notification_ui_manager()->Add(notification, profile()); 247 g_browser_process->notification_ui_manager()->Add(notification, profile());
246 } 248 }
247 #endif // !defined(ENABLE_MESSAGE_CENTER) 249 #endif // !defined(ENABLE_MESSAGE_CENTER)
248 250
249 bool NotificationApiFunction::IsNotificationApiEnabled() { 251 bool NotificationsApiFunction::IsNotificationsApiEnabled() {
250 DesktopNotificationService* service = 252 DesktopNotificationService* service =
251 DesktopNotificationServiceFactory::GetForProfile(profile()); 253 DesktopNotificationServiceFactory::GetForProfile(profile());
252 return service->IsExtensionEnabled(extension_->id()); 254 return service->IsExtensionEnabled(extension_->id());
253 } 255 }
254 256
255 bool NotificationApiFunction::RunImpl() { 257 bool NotificationsApiFunction::IsNotificationsApiAvailable() {
256 if (!IsNotificationApiEnabled()) { 258 // TODO(miket): remove/change this check when we leave dev.
259 if (chrome::VersionInfo::CHANNEL_DEV < Feature::GetCurrentChannel())
260 return false;
261
262 // We need to check this explicitly rather than letting
263 // _permission_features.json enforce it, because we're sharing the
264 // chrome.notifications permissions namespace with WebKit notifications.
265 if (!(GetExtension()->is_platform_app() || GetExtension()->is_extension()))
266 return false;
267
268 return true;
269 }
270
271 bool NotificationsApiFunction::RunImpl() {
272 if (IsNotificationsApiAvailable() && IsNotificationsApiEnabled()) {
273 return RunNotificationsApi();
274 } else {
257 SendResponse(false); 275 SendResponse(false);
258 return true; 276 return true;
259 } 277 }
260
261 return RunNotificationApi();
262 } 278 }
263 279
264 const char kNotificationPrefix[] = "extension.api."; 280 const char kNotificationPrefix[] = "extensions.api.";
265 281
266 static uint64 next_id_ = 0; 282 static uint64 next_id_ = 0;
267 283
268 NotificationCreateFunction::NotificationCreateFunction() { 284 NotificationsCreateFunction::NotificationsCreateFunction() {
269 } 285 }
270 286
271 NotificationCreateFunction::~NotificationCreateFunction() { 287 NotificationsCreateFunction::~NotificationsCreateFunction() {
272 } 288 }
273 289
274 bool NotificationCreateFunction::RunNotificationApi() { 290 bool NotificationsCreateFunction::RunNotificationsApi() {
275 params_ = api::experimental_notification::Create::Params::Create(*args_); 291 params_ = api::notifications::Create::Params::Create(*args_);
276 EXTENSION_FUNCTION_VALIDATE(params_.get()); 292 EXTENSION_FUNCTION_VALIDATE(params_.get());
277 293
278 // If the caller provided a notificationId, use that. Otherwise, generate 294 // If the caller provided a notificationId, use that. Otherwise, generate
279 // one. Note that there's nothing stopping an app developer from passing in 295 // one. Note that there's nothing stopping an app developer from passing in
280 // arbitrary "extension.api.999" notificationIds that will collide with 296 // arbitrary "extension.api.999" notificationIds that will collide with
281 // future generated IDs. It doesn't seem necessary to try to prevent this; if 297 // future generated IDs. It doesn't seem necessary to try to prevent this; if
282 // developers want to hurt themselves, we'll let them. 298 // developers want to hurt themselves, we'll let them.
283 const std::string extension_id(extension_->id()); 299 const std::string extension_id(extension_->id());
284 std::string notification_id; 300 std::string notification_id;
285 if (!params_->notification_id.empty()) 301 if (!params_->notification_id.empty())
286 notification_id = params_->notification_id; 302 notification_id = params_->notification_id;
287 else 303 else
288 notification_id = kNotificationPrefix + base::Uint64ToString(next_id_++); 304 notification_id = kNotificationPrefix + base::Uint64ToString(next_id_++);
289 305
290 CreateNotification(notification_id, &params_->options); 306 CreateNotification(notification_id, &params_->options);
291 307
292 SetResult(Value::CreateStringValue(notification_id)); 308 SetResult(Value::CreateStringValue(notification_id));
293 309
294 SendResponse(true); 310 SendResponse(true);
295 311
296 return true; 312 return true;
297 } 313 }
298 314
299 NotificationUpdateFunction::NotificationUpdateFunction() { 315 NotificationsUpdateFunction::NotificationsUpdateFunction() {
300 } 316 }
301 317
302 NotificationUpdateFunction::~NotificationUpdateFunction() { 318 NotificationsUpdateFunction::~NotificationsUpdateFunction() {
303 } 319 }
304 320
305 bool NotificationUpdateFunction::RunNotificationApi() { 321 bool NotificationsUpdateFunction::RunNotificationsApi() {
306 params_ = api::experimental_notification::Update::Params::Create(*args_); 322 params_ = api::notifications::Update::Params::Create(*args_);
307 EXTENSION_FUNCTION_VALIDATE(params_.get()); 323 EXTENSION_FUNCTION_VALIDATE(params_.get());
308 324
309 if (g_browser_process->notification_ui_manager()-> 325 if (g_browser_process->notification_ui_manager()->
310 DoesIdExist(NotificationApiDelegate::CreateScopedIdentifier( 326 DoesIdExist(NotificationsApiDelegate::CreateScopedIdentifier(
311 extension_->id(), params_->notification_id))) { 327 extension_->id(), params_->notification_id))) {
312 CreateNotification(params_->notification_id, &params_->options); 328 CreateNotification(params_->notification_id, &params_->options);
313 SetResult(Value::CreateBooleanValue(true)); 329 SetResult(Value::CreateBooleanValue(true));
314 } else { 330 } else {
315 SetResult(Value::CreateBooleanValue(false)); 331 SetResult(Value::CreateBooleanValue(false));
316 } 332 }
317 333
318 SendResponse(true); 334 SendResponse(true);
319 335
320 return true; 336 return true;
321 } 337 }
322 338
323 NotificationClearFunction::NotificationClearFunction() { 339 NotificationsClearFunction::NotificationsClearFunction() {
324 } 340 }
325 341
326 NotificationClearFunction::~NotificationClearFunction() { 342 NotificationsClearFunction::~NotificationsClearFunction() {
327 } 343 }
328 344
329 bool NotificationClearFunction::RunNotificationApi() { 345 bool NotificationsClearFunction::RunNotificationsApi() {
330 params_ = api::experimental_notification::Clear::Params::Create(*args_); 346 params_ = api::notifications::Clear::Params::Create(*args_);
331 EXTENSION_FUNCTION_VALIDATE(params_.get()); 347 EXTENSION_FUNCTION_VALIDATE(params_.get());
332 348
333 bool cancel_result = g_browser_process->notification_ui_manager()-> 349 bool cancel_result = g_browser_process->notification_ui_manager()->
334 CancelById(NotificationApiDelegate::CreateScopedIdentifier( 350 CancelById(NotificationsApiDelegate::CreateScopedIdentifier(
335 extension_->id(), params_->notification_id)); 351 extension_->id(), params_->notification_id));
336 352
337 SetResult(Value::CreateBooleanValue(cancel_result)); 353 SetResult(Value::CreateBooleanValue(cancel_result));
338 SendResponse(true); 354 SendResponse(true);
339 355
340 return true; 356 return true;
341 } 357 }
342 358
343 } // namespace extensions 359 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698