| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/notifications/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return; | 260 return; |
| 261 tab->AddInfoBar(new NotificationPermissionInfoBarDelegate(tab, origin, | 261 tab->AddInfoBar(new NotificationPermissionInfoBarDelegate(tab, origin, |
| 262 callback_context)); | 262 callback_context)); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void DesktopNotificationService::ShowNotification( | 265 void DesktopNotificationService::ShowNotification( |
| 266 const Notification& notification) { | 266 const Notification& notification) { |
| 267 ui_manager_->Add(notification, profile_); | 267 ui_manager_->Add(notification, profile_); |
| 268 } | 268 } |
| 269 | 269 |
| 270 bool DesktopNotificationService::CancelDesktopNotification( |
| 271 int process_id, int route_id, int notification_id) { |
| 272 scoped_refptr<NotificationObjectProxy> proxy( |
| 273 new NotificationObjectProxy(process_id, route_id, notification_id, |
| 274 false)); |
| 275 Notification notif(GURL(), GURL(), proxy); |
| 276 return ui_manager_->Cancel(notif); |
| 277 } |
| 278 |
| 279 |
| 270 bool DesktopNotificationService::ShowDesktopNotification( | 280 bool DesktopNotificationService::ShowDesktopNotification( |
| 271 const GURL& origin, const GURL& url, int process_id, int route_id, | 281 const GURL& origin, const GURL& url, int process_id, int route_id, |
| 272 NotificationSource source, int notification_id) { | 282 NotificationSource source, int notification_id) { |
| 273 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 283 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 274 NotificationObjectProxy* proxy = | 284 NotificationObjectProxy* proxy = |
| 275 new NotificationObjectProxy(process_id, route_id, | 285 new NotificationObjectProxy(process_id, route_id, |
| 276 notification_id, | 286 notification_id, |
| 277 source == WorkerNotification); | 287 source == WorkerNotification); |
| 278 Notification notif(origin, url, proxy); | 288 Notification notif(origin, url, proxy); |
| 279 ShowNotification(notif); | 289 ShowNotification(notif); |
| 280 return true; | 290 return true; |
| 281 } | 291 } |
| 282 | 292 |
| 283 bool DesktopNotificationService::ShowDesktopNotificationText( | 293 bool DesktopNotificationService::ShowDesktopNotificationText( |
| 284 const GURL& origin, const GURL& icon, const string16& title, | 294 const GURL& origin, const GURL& icon, const string16& title, |
| 285 const string16& text, int process_id, int route_id, | 295 const string16& text, int process_id, int route_id, |
| 286 NotificationSource source, int notification_id) { | 296 NotificationSource source, int notification_id) { |
| 287 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 297 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 288 NotificationObjectProxy* proxy = | 298 NotificationObjectProxy* proxy = |
| 289 new NotificationObjectProxy(process_id, route_id, | 299 new NotificationObjectProxy(process_id, route_id, |
| 290 notification_id, | 300 notification_id, |
| 291 source == WorkerNotification); | 301 source == WorkerNotification); |
| 292 // "upconvert" the string parameters to a data: URL. | 302 // "upconvert" the string parameters to a data: URL. |
| 293 string16 data_url = CreateDataUrl(icon, title, text); | 303 string16 data_url = CreateDataUrl(icon, title, text); |
| 294 Notification notif(origin, GURL(data_url), proxy); | 304 Notification notif(origin, GURL(data_url), proxy); |
| 295 ShowNotification(notif); | 305 ShowNotification(notif); |
| 296 return true; | 306 return true; |
| 297 } | 307 } |
| OLD | NEW |