| OLD | NEW |
| 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/notifications/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Notify renderer immediately. | 549 // Notify renderer immediately. |
| 550 RenderViewHost* host = RenderViewHost::FromID(process_id, route_id); | 550 RenderViewHost* host = RenderViewHost::FromID(process_id, route_id); |
| 551 if (host) | 551 if (host) |
| 552 host->DesktopNotificationPermissionRequestDone(callback_context); | 552 host->DesktopNotificationPermissionRequestDone(callback_context); |
| 553 } | 553 } |
| 554 | 554 |
| 555 #if !defined(OS_WIN) | |
| 556 void DesktopNotificationService::ShowNotification( | 555 void DesktopNotificationService::ShowNotification( |
| 557 const Notification& notification) { | 556 const Notification& notification) { |
| 558 GetUIManager()->Add(notification, profile_); | 557 GetUIManager()->Add(notification, profile_); |
| 559 } | 558 } |
| 560 | 559 |
| 561 bool DesktopNotificationService::CancelDesktopNotification( | 560 bool DesktopNotificationService::CancelDesktopNotification( |
| 562 int process_id, int route_id, int notification_id) { | 561 int process_id, int route_id, int notification_id) { |
| 563 scoped_refptr<NotificationObjectProxy> proxy( | 562 scoped_refptr<NotificationObjectProxy> proxy( |
| 564 new NotificationObjectProxy(process_id, route_id, notification_id)); | 563 new NotificationObjectProxy(process_id, route_id, notification_id)); |
| 565 return GetUIManager()->CancelById(proxy->id()); | 564 return GetUIManager()->CancelById(proxy->id()); |
| 566 } | 565 } |
| 567 #endif // OS_WIN | |
| 568 | 566 |
| 569 bool DesktopNotificationService::ShowDesktopNotification( | 567 bool DesktopNotificationService::ShowDesktopNotification( |
| 570 const content::ShowDesktopNotificationHostMsgParams& params, | 568 const content::ShowDesktopNotificationHostMsgParams& params, |
| 571 int process_id, int route_id) { | 569 int process_id, int route_id) { |
| 572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 573 const GURL& origin = params.origin; | 571 const GURL& origin = params.origin; |
| 574 NotificationObjectProxy* proxy = | 572 NotificationObjectProxy* proxy = |
| 575 new NotificationObjectProxy(process_id, route_id, | 573 new NotificationObjectProxy(process_id, route_id, |
| 576 params.notification_id); | 574 params.notification_id); |
| 577 | 575 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 // Tell the IO thread that this extension's permission for notifications | 761 // Tell the IO thread that this extension's permission for notifications |
| 764 // has changed. | 762 // has changed. |
| 765 extensions::InfoMap* extension_info_map = | 763 extensions::InfoMap* extension_info_map = |
| 766 extensions::ExtensionSystem::Get(profile_)->info_map(); | 764 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 767 BrowserThread::PostTask( | 765 BrowserThread::PostTask( |
| 768 BrowserThread::IO, FROM_HERE, | 766 BrowserThread::IO, FROM_HERE, |
| 769 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 767 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 770 extension_info_map, notifier_id.id, !enabled)); | 768 extension_info_map, notifier_id.id, !enabled)); |
| 771 | 769 |
| 772 } | 770 } |
| OLD | NEW |