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

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: Fix merge conflict. 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 bool NotificationsApiFunction::IsNotificationsApiAvailable() {
116 // TODO(miket): remove/change this check when we leave dev.
117 if (chrome::VersionInfo::CHANNEL_DEV < Feature::GetCurrentChannel())
118 return false;
119
120 // We need to check this explicitly rather than letting
121 // _permission_features.json enforce it, because we're sharing the
122 // chrome.notifications permissions namespace with WebKit notifications.
123 if (!(GetExtension()->is_platform_app() || GetExtension()->is_extension()))
124 return false;
125
126 return true;
114 } 127 }
115 128
116 NotificationApiFunction::~NotificationApiFunction() { 129 NotificationsApiFunction::NotificationsApiFunction() {
117 } 130 }
118 131
119 message_center::NotificationType 132 NotificationsApiFunction::~NotificationsApiFunction() {
120 NotificationApiFunction::MapApiTemplateTypeToType(
121 api::experimental_notification::TemplateType type) {
122 switch (type) {
123 case api::experimental_notification::TEMPLATE_TYPE_NONE:
124 case api::experimental_notification::TEMPLATE_TYPE_SIMPLE:
125 return message_center::NOTIFICATION_TYPE_SIMPLE;
126 case api::experimental_notification::TEMPLATE_TYPE_BASIC:
127 return message_center::NOTIFICATION_TYPE_BASE_FORMAT;
128 case api::experimental_notification::TEMPLATE_TYPE_IMAGE:
129 return message_center::NOTIFICATION_TYPE_IMAGE;
130 case api::experimental_notification::TEMPLATE_TYPE_LIST:
131 return message_center::NOTIFICATION_TYPE_MULTIPLE;
132 default:
133 // Gracefully handle newer application code that is running on an older
134 // runtime that doesn't recognize the requested template.
135 return message_center::NOTIFICATION_TYPE_BASE_FORMAT;
136 }
137 } 133 }
138 134
139 // If older notification runtime is used, MessageCenter is not built. 135 // If older notification runtime is used, MessageCenter is not built.
140 // Use simpler bridge then, ignoring all options. 136 // Use simpler bridge then, ignoring all options.
141 #if !defined (ENABLE_MESSAGE_CENTER) 137 #if !defined (ENABLE_MESSAGE_CENTER)
142 void NotificationApiFunction::CreateNotification( 138 void NotificationsApiFunction::CreateNotification(
143 const std::string& id, 139 const std::string& id,
144 api::experimental_notification::NotificationOptions* options) { 140 api::notifications::NotificationOptions* options) {
145 message_center::NotificationType type = 141 message_center::NotificationType type =
146 MapApiTemplateTypeToType(options->template_type); 142 MapApiTemplateTypeToType(options->template_type);
147 GURL icon_url(UTF8ToUTF16(options->icon_url)); 143 GURL icon_url(UTF8ToUTF16(options->icon_url));
148 string16 title(UTF8ToUTF16(options->title)); 144 string16 title(UTF8ToUTF16(options->title));
149 string16 message(UTF8ToUTF16(options->message)); 145 string16 message(UTF8ToUTF16(options->message));
150 146
151 // Ignore options if running on the old notification runtime. 147 // Ignore options if running on the old notification runtime.
152 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); 148 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue());
153 149
154 NotificationApiDelegate* api_delegate(new NotificationApiDelegate( 150 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
155 this, 151 this,
156 profile(), 152 profile(),
157 extension_->id(), 153 extension_->id(),
158 id)); // ownership is passed to Notification 154 id)); // ownership is passed to Notification
159 Notification notification(type, extension_->url(), icon_url, title, message, 155 Notification notification(type, extension_->url(), icon_url, title, message,
160 WebKit::WebTextDirectionDefault, 156 WebKit::WebTextDirectionDefault,
161 string16(), UTF8ToUTF16(api_delegate->id()), 157 string16(), UTF8ToUTF16(api_delegate->id()),
162 optional_fields.get(), api_delegate); 158 optional_fields.get(), api_delegate);
163 159
164 g_browser_process->notification_ui_manager()->Add(notification, profile()); 160 g_browser_process->notification_ui_manager()->Add(notification, profile());
165 } 161 }
166 #else // defined(ENABLE_MESSAGE_CENTER) 162 #else // defined(ENABLE_MESSAGE_CENTER)
167 void NotificationApiFunction::CreateNotification( 163 void NotificationsApiFunction::CreateNotification(
168 const std::string& id, 164 const std::string& id,
169 api::experimental_notification::NotificationOptions* options) { 165 api::notifications::NotificationOptions* options) {
170 message_center::NotificationType type = 166 message_center::NotificationType type =
171 MapApiTemplateTypeToType(options->template_type); 167 MapApiTemplateTypeToType(options->template_type);
172 GURL icon_url(UTF8ToUTF16(options->icon_url)); 168 GURL icon_url(UTF8ToUTF16(options->icon_url));
173 string16 title(UTF8ToUTF16(options->title)); 169 string16 title(UTF8ToUTF16(options->title));
174 string16 message(UTF8ToUTF16(options->message)); 170 string16 message(UTF8ToUTF16(options->message));
175 171
176 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); 172 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue());
177 173
178 // For all notification types. 174 // For all notification types.
179 if (options->priority.get()) 175 if (options->priority.get())
180 optional_fields->SetInteger(message_center::kPriorityKey, 176 optional_fields->SetInteger(message_center::kPriorityKey,
181 *options->priority); 177 *options->priority);
182 if (options->event_time.get()) 178 if (options->event_time.get())
183 optional_fields->SetDouble(message_center::kTimestampKey, 179 optional_fields->SetDouble(message_center::kTimestampKey,
184 *options->event_time); 180 *options->event_time);
185 if (options->buttons.get()) { 181 if (options->buttons.get()) {
186 if (options->buttons->size() > 0) { 182 if (options->buttons->size() > 0) {
187 linked_ptr<api::experimental_notification::NotificationButton> button = 183 linked_ptr<api::notifications::NotificationButton> button =
188 (*options->buttons)[0]; 184 (*options->buttons)[0];
189 optional_fields->SetString(message_center::kButtonOneTitleKey, 185 optional_fields->SetString(message_center::kButtonOneTitleKey,
190 UTF8ToUTF16(button->title)); 186 UTF8ToUTF16(button->title));
191 if (button->icon_url.get()) 187 if (button->icon_url.get())
192 optional_fields->SetString(message_center::kButtonOneIconUrlKey, 188 optional_fields->SetString(message_center::kButtonOneIconUrlKey,
193 UTF8ToUTF16(*button->icon_url)); 189 UTF8ToUTF16(*button->icon_url));
194 } 190 }
195 if (options->buttons->size() > 1) { 191 if (options->buttons->size() > 1) {
196 linked_ptr<api::experimental_notification::NotificationButton> button = 192 linked_ptr<api::notifications::NotificationButton> button =
197 (*options->buttons)[1]; 193 (*options->buttons)[1];
198 optional_fields->SetString(message_center::kButtonTwoTitleKey, 194 optional_fields->SetString(message_center::kButtonTwoTitleKey,
199 UTF8ToUTF16(button->title)); 195 UTF8ToUTF16(button->title));
200 if (button->icon_url.get()) 196 if (button->icon_url.get())
201 optional_fields->SetString(message_center::kButtonTwoIconUrlKey, 197 optional_fields->SetString(message_center::kButtonTwoIconUrlKey,
202 UTF8ToUTF16(*button->icon_url)); 198 UTF8ToUTF16(*button->icon_url));
203 } 199 }
204 } 200 }
205 if (options->expanded_message.get()) 201 if (options->expanded_message.get())
206 optional_fields->SetString(message_center::kExpandedMessageKey, 202 optional_fields->SetString(message_center::kExpandedMessageKey,
207 UTF8ToUTF16(*options->expanded_message)); 203 UTF8ToUTF16(*options->expanded_message));
208 204
209 // For image notifications (type == 'image'). 205 // For image notifications (type == 'image').
210 // TODO(dharcourt): Fail if (type == 'image' && !options->image_url.get()) 206 // TODO(dharcourt): Fail if (type == 'image' && !options->image_url.get())
211 // TODO(dharcourt): Fail if (type != 'image' && options->image_url.get()) 207 // TODO(dharcourt): Fail if (type != 'image' && options->image_url.get())
212 if (options->image_url.get()) 208 if (options->image_url.get())
213 optional_fields->SetString(message_center::kImageUrlKey, 209 optional_fields->SetString(message_center::kImageUrlKey,
214 UTF8ToUTF16(*options->image_url)); 210 UTF8ToUTF16(*options->image_url));
215 211
216 // For list notifications (type == 'multiple'). 212 // For list notifications (type == 'multiple').
217 // TODO(dharcourt): Fail if (type == 'multiple' && !options->items.get()) 213 // TODO(dharcourt): Fail if (type == 'multiple' && !options->items.get())
218 // TODO(dharcourt): Fail if (type != 'multiple' && options->items.get()) 214 // TODO(dharcourt): Fail if (type != 'multiple' && options->items.get())
219 if (options->items.get()) { 215 if (options->items.get()) {
220 base::ListValue* items = new base::ListValue(); 216 base::ListValue* items = new base::ListValue();
221 std::vector< 217 std::vector<
222 linked_ptr< 218 linked_ptr<
223 api::experimental_notification::NotificationItem> >::iterator i; 219 api::notifications::NotificationItem> >::iterator i;
224 for (i = options->items->begin(); i != options->items->end(); ++i) { 220 for (i = options->items->begin(); i != options->items->end(); ++i) {
225 base::DictionaryValue* item = new base::DictionaryValue(); 221 base::DictionaryValue* item = new base::DictionaryValue();
226 item->SetString(message_center::kItemTitleKey, 222 item->SetString(message_center::kItemTitleKey,
227 UTF8ToUTF16(i->get()->title)); 223 UTF8ToUTF16(i->get()->title));
228 item->SetString(message_center::kItemMessageKey, 224 item->SetString(message_center::kItemMessageKey,
229 UTF8ToUTF16(i->get()->message)); 225 UTF8ToUTF16(i->get()->message));
230 items->Append(item); 226 items->Append(item);
231 } 227 }
232 optional_fields->Set(message_center::kItemsKey, items); 228 optional_fields->Set(message_center::kItemsKey, items);
233 } 229 }
234 230
235 NotificationApiDelegate* api_delegate(new NotificationApiDelegate( 231 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
236 this, 232 this,
237 profile(), 233 profile(),
238 extension_->id(), 234 extension_->id(),
239 id)); // ownership is passed to Notification 235 id)); // ownership is passed to Notification
240 Notification notification(type, extension_->url(), icon_url, title, message, 236 Notification notification(type, extension_->url(), icon_url, title, message,
241 WebKit::WebTextDirectionDefault, 237 WebKit::WebTextDirectionDefault,
242 string16(), UTF8ToUTF16(api_delegate->id()), 238 string16(), UTF8ToUTF16(api_delegate->id()),
243 optional_fields.get(), api_delegate); 239 optional_fields.get(), api_delegate);
244 240
245 g_browser_process->notification_ui_manager()->Add(notification, profile()); 241 g_browser_process->notification_ui_manager()->Add(notification, profile());
246 } 242 }
247 #endif // !defined(ENABLE_MESSAGE_CENTER) 243 #endif // !defined(ENABLE_MESSAGE_CENTER)
248 244
249 bool NotificationApiFunction::IsNotificationApiEnabled() { 245 bool NotificationsApiFunction::IsNotificationsApiEnabled() {
250 DesktopNotificationService* service = 246 DesktopNotificationService* service =
251 DesktopNotificationServiceFactory::GetForProfile(profile()); 247 DesktopNotificationServiceFactory::GetForProfile(profile());
252 return service->IsExtensionEnabled(extension_->id()); 248 return service->IsExtensionEnabled(extension_->id());
253 } 249 }
254 250
255 bool NotificationApiFunction::RunImpl() { 251 bool NotificationsApiFunction::RunImpl() {
256 if (!IsNotificationApiEnabled()) { 252 if (IsNotificationsApiAvailable() && IsNotificationsApiEnabled()) {
253 return RunNotificationsApi();
254 } else {
257 SendResponse(false); 255 SendResponse(false);
258 return true; 256 return true;
259 } 257 }
260
261 return RunNotificationApi();
262 } 258 }
263 259
264 const char kNotificationPrefix[] = "extension.api."; 260 message_center::NotificationType
261 NotificationsApiFunction::MapApiTemplateTypeToType(
262 api::notifications::TemplateType type) {
263 switch (type) {
264 case api::notifications::TEMPLATE_TYPE_NONE:
265 case api::notifications::TEMPLATE_TYPE_SIMPLE:
266 return message_center::NOTIFICATION_TYPE_SIMPLE;
267 case api::notifications::TEMPLATE_TYPE_BASIC:
268 return message_center::NOTIFICATION_TYPE_BASE_FORMAT;
269 case api::notifications::TEMPLATE_TYPE_IMAGE:
270 return message_center::NOTIFICATION_TYPE_IMAGE;
271 case api::notifications::TEMPLATE_TYPE_LIST:
272 return message_center::NOTIFICATION_TYPE_MULTIPLE;
273 default:
274 // Gracefully handle newer application code that is running on an older
275 // runtime that doesn't recognize the requested template.
276 return message_center::NOTIFICATION_TYPE_BASE_FORMAT;
277 }
278 }
279
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