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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 const content::NotificationSource& source, | 774 const content::NotificationSource& source, |
775 const content::NotificationDetails& details) { | 775 const content::NotificationDetails& details) { |
776 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type); | 776 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type); |
777 | 777 |
778 extensions::Extension* extension = | 778 extensions::Extension* extension = |
779 content::Details<extensions::Extension>(details).ptr(); | 779 content::Details<extensions::Extension>(details).ptr(); |
780 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); | 780 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
781 if (IsNotifierEnabled(notifier_id)) | 781 if (IsNotifierEnabled(notifier_id)) |
782 return; | 782 return; |
783 | 783 |
| 784 // The settings for ephemeral apps will be persisted across cache evictions. |
| 785 if (extension->is_ephemeral()) |
| 786 return; |
| 787 |
784 SetNotifierEnabled(notifier_id, true); | 788 SetNotifierEnabled(notifier_id, true); |
785 } | 789 } |
786 | 790 |
787 void DesktopNotificationService::FirePermissionLevelChangedEvent( | 791 void DesktopNotificationService::FirePermissionLevelChangedEvent( |
788 const NotifierId& notifier_id, bool enabled) { | 792 const NotifierId& notifier_id, bool enabled) { |
789 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); | 793 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); |
790 extensions::api::notifications::PermissionLevel permission = | 794 extensions::api::notifications::PermissionLevel permission = |
791 enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED | 795 enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED |
792 : extensions::api::notifications::PERMISSION_LEVEL_DENIED; | 796 : extensions::api::notifications::PERMISSION_LEVEL_DENIED; |
793 scoped_ptr<base::ListValue> args(new base::ListValue()); | 797 scoped_ptr<base::ListValue> args(new base::ListValue()); |
794 args->Append(new base::StringValue( | 798 args->Append(new base::StringValue( |
795 extensions::api::notifications::ToString(permission))); | 799 extensions::api::notifications::ToString(permission))); |
796 scoped_ptr<extensions::Event> event(new extensions::Event( | 800 scoped_ptr<extensions::Event> event(new extensions::Event( |
797 extensions::api::notifications::OnPermissionLevelChanged::kEventName, | 801 extensions::api::notifications::OnPermissionLevelChanged::kEventName, |
798 args.Pass())); | 802 args.Pass())); |
799 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 803 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
800 DispatchEventToExtension(notifier_id.id, event.Pass()); | 804 DispatchEventToExtension(notifier_id.id, event.Pass()); |
801 | 805 |
802 // Tell the IO thread that this extension's permission for notifications | 806 // Tell the IO thread that this extension's permission for notifications |
803 // has changed. | 807 // has changed. |
804 extensions::InfoMap* extension_info_map = | 808 extensions::InfoMap* extension_info_map = |
805 extensions::ExtensionSystem::Get(profile_)->info_map(); | 809 extensions::ExtensionSystem::Get(profile_)->info_map(); |
806 BrowserThread::PostTask( | 810 BrowserThread::PostTask( |
807 BrowserThread::IO, FROM_HERE, | 811 BrowserThread::IO, FROM_HERE, |
808 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 812 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
809 extension_info_map, notifier_id.id, !enabled)); | 813 extension_info_map, notifier_id.id, !enabled)); |
810 | 814 |
811 } | 815 } |
OLD | NEW |