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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 689 } |
690 } | 690 } |
691 | 691 |
692 void DesktopNotificationService::Observe( | 692 void DesktopNotificationService::Observe( |
693 int type, | 693 int type, |
694 const content::NotificationSource& source, | 694 const content::NotificationSource& source, |
695 const content::NotificationDetails& details) { | 695 const content::NotificationDetails& details) { |
696 #if defined(ENABLE_EXTENSIONS) | 696 #if defined(ENABLE_EXTENSIONS) |
697 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, type); | 697 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, type); |
698 | 698 |
699 extensions::Extension* extension = | 699 extensions::UninstalledExtensionInfo* info = |
700 content::Details<extensions::Extension>(details).ptr(); | 700 content::Details<extensions::UninstalledExtensionInfo>(details).ptr(); |
701 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); | 701 NotifierId notifier_id(NotifierId::APPLICATION, info->extension->id()); |
702 if (IsNotifierEnabled(notifier_id)) | 702 if (IsNotifierEnabled(notifier_id)) |
703 return; | 703 return; |
704 | 704 |
705 // The settings for ephemeral apps will be persisted across cache evictions. | 705 // The settings for ephemeral apps will be persisted across cache evictions. |
706 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) | 706 if (extensions::util::IsEphemeralApp(info->extension->id(), profile_)) |
707 return; | 707 return; |
708 | 708 |
709 SetNotifierEnabled(notifier_id, true); | 709 SetNotifierEnabled(notifier_id, true); |
710 #endif | 710 #endif |
711 } | 711 } |
712 | 712 |
713 void DesktopNotificationService::FirePermissionLevelChangedEvent( | 713 void DesktopNotificationService::FirePermissionLevelChangedEvent( |
714 const NotifierId& notifier_id, bool enabled) { | 714 const NotifierId& notifier_id, bool enabled) { |
715 #if defined(ENABLE_EXTENSIONS) | 715 #if defined(ENABLE_EXTENSIONS) |
716 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); | 716 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); |
(...skipping 12 matching lines...) Expand all Loading... |
729 // Tell the IO thread that this extension's permission for notifications | 729 // Tell the IO thread that this extension's permission for notifications |
730 // has changed. | 730 // has changed. |
731 extensions::InfoMap* extension_info_map = | 731 extensions::InfoMap* extension_info_map = |
732 extensions::ExtensionSystem::Get(profile_)->info_map(); | 732 extensions::ExtensionSystem::Get(profile_)->info_map(); |
733 BrowserThread::PostTask( | 733 BrowserThread::PostTask( |
734 BrowserThread::IO, FROM_HERE, | 734 BrowserThread::IO, FROM_HERE, |
735 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 735 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
736 extension_info_map, notifier_id.id, !enabled)); | 736 extension_info_map, notifier_id.id, !enabled)); |
737 #endif | 737 #endif |
738 } | 738 } |
OLD | NEW |