| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/notifier_state_tracker.h" | 5 #include "chrome/browser/notifications/notifier_state_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 14 #include "chrome/browser/permissions/permission_manager.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/pref_registry/pref_registry_syncable.h" | 17 #include "components/pref_registry/pref_registry_syncable.h" |
| 18 #include "components/prefs/scoped_user_pref_update.h" | 18 #include "components/prefs/scoped_user_pref_update.h" |
| 19 #include "content/public/browser/permission_type.h" |
| 19 #include "ui/message_center/notifier_settings.h" | 20 #include "ui/message_center/notifier_settings.h" |
| 20 | 21 |
| 21 #if defined(ENABLE_EXTENSIONS) | 22 #if defined(ENABLE_EXTENSIONS) |
| 22 #include "chrome/common/extensions/api/notifications.h" | 23 #include "chrome/common/extensions/api/notifications.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "extensions/browser/event_router.h" | 25 #include "extensions/browser/event_router.h" |
| 25 #include "extensions/browser/extension_event_histogram_value.h" | 26 #include "extensions/browser/extension_event_histogram_value.h" |
| 26 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
| 27 #include "extensions/browser/extension_util.h" | 28 #include "extensions/browser/extension_util.h" |
| 28 #include "extensions/browser/info_map.h" | 29 #include "extensions/browser/info_map.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 NotifierStateTracker::~NotifierStateTracker() { | 78 NotifierStateTracker::~NotifierStateTracker() { |
| 78 } | 79 } |
| 79 | 80 |
| 80 bool NotifierStateTracker::IsNotifierEnabled( | 81 bool NotifierStateTracker::IsNotifierEnabled( |
| 81 const NotifierId& notifier_id) const { | 82 const NotifierId& notifier_id) const { |
| 82 switch (notifier_id.type) { | 83 switch (notifier_id.type) { |
| 83 case NotifierId::APPLICATION: | 84 case NotifierId::APPLICATION: |
| 84 return disabled_extension_ids_.find(notifier_id.id) == | 85 return disabled_extension_ids_.find(notifier_id.id) == |
| 85 disabled_extension_ids_.end(); | 86 disabled_extension_ids_.end(); |
| 86 case NotifierId::WEB_PAGE: | 87 case NotifierId::WEB_PAGE: |
| 87 return DesktopNotificationProfileUtil::GetContentSetting( | 88 return PermissionManager::Get(profile_)->GetPermissionStatus( |
| 88 profile_, notifier_id.url) == CONTENT_SETTING_ALLOW; | 89 content::PermissionType::NOTIFICATIONS, notifier_id.url, |
| 90 notifier_id.url) == blink::mojom::PermissionStatus::GRANTED; |
| 89 case NotifierId::SYSTEM_COMPONENT: | 91 case NotifierId::SYSTEM_COMPONENT: |
| 90 #if defined(OS_CHROMEOS) | 92 #if defined(OS_CHROMEOS) |
| 91 return disabled_system_component_ids_.find(notifier_id.id) == | 93 return disabled_system_component_ids_.find(notifier_id.id) == |
| 92 disabled_system_component_ids_.end(); | 94 disabled_system_component_ids_.end(); |
| 93 #else | 95 #else |
| 94 // We do not disable system component notifications. | 96 // We do not disable system component notifications. |
| 95 return true; | 97 return true; |
| 96 #endif | 98 #endif |
| 97 } | 99 } |
| 98 | 100 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Tell the IO thread that this extension's permission for notifications | 191 // Tell the IO thread that this extension's permission for notifications |
| 190 // has changed. | 192 // has changed. |
| 191 extensions::InfoMap* extension_info_map = | 193 extensions::InfoMap* extension_info_map = |
| 192 extensions::ExtensionSystem::Get(profile_)->info_map(); | 194 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 193 content::BrowserThread::PostTask( | 195 content::BrowserThread::PostTask( |
| 194 content::BrowserThread::IO, FROM_HERE, | 196 content::BrowserThread::IO, FROM_HERE, |
| 195 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 197 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 196 extension_info_map, notifier_id.id, !enabled)); | 198 extension_info_map, notifier_id.id, !enabled)); |
| 197 } | 199 } |
| 198 #endif | 200 #endif |
| OLD | NEW |