| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 const content::ShowDesktopNotificationHostMsgParams& params, | 487 const content::ShowDesktopNotificationHostMsgParams& params, |
| 488 int process_id, int route_id, DesktopNotificationSource source) { | 488 int process_id, int route_id, DesktopNotificationSource source) { |
| 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 490 const GURL& origin = params.origin; | 490 const GURL& origin = params.origin; |
| 491 NotificationObjectProxy* proxy = | 491 NotificationObjectProxy* proxy = |
| 492 new NotificationObjectProxy(process_id, route_id, | 492 new NotificationObjectProxy(process_id, route_id, |
| 493 params.notification_id, | 493 params.notification_id, |
| 494 source == WorkerNotification); | 494 source == WorkerNotification); |
| 495 | 495 |
| 496 string16 display_source = DisplayNameForOriginInProcessId(origin, process_id); | 496 string16 display_source = DisplayNameForOriginInProcessId(origin, process_id); |
| 497 if (params.is_html) { | 497 Notification notification(origin, params.icon_url, params.title, |
| 498 ShowNotification(Notification(origin, params.contents_url, display_source, | 498 params.body, params.direction, display_source, params.replace_id, |
| 499 params.replace_id, proxy)); | 499 proxy); |
| 500 } else { | 500 |
| 501 Notification notification(origin, params.icon_url, params.title, | 501 // The webkit notification doesn't timeout. |
| 502 params.body, params.direction, display_source, params.replace_id, | 502 notification.set_never_timeout(true); |
| 503 proxy); | 503 |
| 504 // The webkit notification doesn't timeout. | 504 ShowNotification(notification); |
| 505 notification.set_never_timeout(true); | |
| 506 ShowNotification(notification); | |
| 507 } | |
| 508 return true; | 505 return true; |
| 509 } | 506 } |
| 510 | 507 |
| 511 string16 DesktopNotificationService::DisplayNameForOriginInProcessId( | 508 string16 DesktopNotificationService::DisplayNameForOriginInProcessId( |
| 512 const GURL& origin, int process_id) { | 509 const GURL& origin, int process_id) { |
| 513 // If the source is an extension, lookup the display name. | 510 // If the source is an extension, lookup the display name. |
| 514 // Message center prefers to use extension name if the notification | 511 // Message center prefers to use extension name if the notification |
| 515 // is allowed by an extension. | 512 // is allowed by an extension. |
| 516 if (NotificationUIManager::DelegatesToMessageCenter() || | 513 if (NotificationUIManager::DelegatesToMessageCenter() || |
| 517 origin.SchemeIs(extensions::kExtensionScheme)) { | 514 origin.SchemeIs(extensions::kExtensionScheme)) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 // Tell the IO thread that this extension's permission for notifications | 679 // Tell the IO thread that this extension's permission for notifications |
| 683 // has changed. | 680 // has changed. |
| 684 extensions::InfoMap* extension_info_map = | 681 extensions::InfoMap* extension_info_map = |
| 685 extensions::ExtensionSystem::Get(profile_)->info_map(); | 682 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 686 BrowserThread::PostTask( | 683 BrowserThread::PostTask( |
| 687 BrowserThread::IO, FROM_HERE, | 684 BrowserThread::IO, FROM_HERE, |
| 688 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 685 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 689 extension_info_map, notifier_id.id, !enabled)); | 686 extension_info_map, notifier_id.id, !enabled)); |
| 690 | 687 |
| 691 } | 688 } |
| OLD | NEW |