| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 48 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
| 49 #include "ui/base/webui/web_ui_util.h" | 49 #include "ui/base/webui/web_ui_util.h" |
| 50 #include "ui/message_center/notifier_settings.h" | 50 #include "ui/message_center/notifier_settings.h" |
| 51 | 51 |
| 52 #if defined(ENABLE_EXTENSIONS) | 52 #if defined(ENABLE_EXTENSIONS) |
| 53 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 53 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
| 54 #include "chrome/browser/extensions/extension_service.h" | 54 #include "chrome/browser/extensions/extension_service.h" |
| 55 #include "extensions/browser/event_router.h" | 55 #include "extensions/browser/event_router.h" |
| 56 #include "extensions/browser/extension_system.h" | 56 #include "extensions/browser/extension_system.h" |
| 57 #include "extensions/browser/extension_util.h" |
| 57 #include "extensions/browser/info_map.h" | 58 #include "extensions/browser/info_map.h" |
| 58 #include "extensions/common/constants.h" | 59 #include "extensions/common/constants.h" |
| 59 #include "extensions/common/extension.h" | 60 #include "extensions/common/extension.h" |
| 60 #include "extensions/common/extension_set.h" | 61 #include "extensions/common/extension_set.h" |
| 61 #endif | 62 #endif |
| 62 | 63 |
| 63 using blink::WebTextDirection; | 64 using blink::WebTextDirection; |
| 64 using content::BrowserThread; | 65 using content::BrowserThread; |
| 65 using content::RenderViewHost; | 66 using content::RenderViewHost; |
| 66 using content::WebContents; | 67 using content::WebContents; |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 #if defined(ENABLE_EXTENSIONS) | 716 #if defined(ENABLE_EXTENSIONS) |
| 716 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type); | 717 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type); |
| 717 | 718 |
| 718 extensions::Extension* extension = | 719 extensions::Extension* extension = |
| 719 content::Details<extensions::Extension>(details).ptr(); | 720 content::Details<extensions::Extension>(details).ptr(); |
| 720 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); | 721 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
| 721 if (IsNotifierEnabled(notifier_id)) | 722 if (IsNotifierEnabled(notifier_id)) |
| 722 return; | 723 return; |
| 723 | 724 |
| 724 // The settings for ephemeral apps will be persisted across cache evictions. | 725 // The settings for ephemeral apps will be persisted across cache evictions. |
| 725 if (extension->is_ephemeral()) | 726 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) |
| 726 return; | 727 return; |
| 727 | 728 |
| 728 SetNotifierEnabled(notifier_id, true); | 729 SetNotifierEnabled(notifier_id, true); |
| 729 #endif | 730 #endif |
| 730 } | 731 } |
| 731 | 732 |
| 732 void DesktopNotificationService::FirePermissionLevelChangedEvent( | 733 void DesktopNotificationService::FirePermissionLevelChangedEvent( |
| 733 const NotifierId& notifier_id, bool enabled) { | 734 const NotifierId& notifier_id, bool enabled) { |
| 734 #if defined(ENABLE_EXTENSIONS) | 735 #if defined(ENABLE_EXTENSIONS) |
| 735 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); | 736 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 748 // Tell the IO thread that this extension's permission for notifications | 749 // Tell the IO thread that this extension's permission for notifications |
| 749 // has changed. | 750 // has changed. |
| 750 extensions::InfoMap* extension_info_map = | 751 extensions::InfoMap* extension_info_map = |
| 751 extensions::ExtensionSystem::Get(profile_)->info_map(); | 752 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 752 BrowserThread::PostTask( | 753 BrowserThread::PostTask( |
| 753 BrowserThread::IO, FROM_HERE, | 754 BrowserThread::IO, FROM_HERE, |
| 754 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 755 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 755 extension_info_map, notifier_id.id, !enabled)); | 756 extension_info_map, notifier_id.id, !enabled)); |
| 756 #endif | 757 #endif |
| 757 } | 758 } |
| OLD | NEW |