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/permissions/permission_manager.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/content_settings/core/common/content_settings_types.h" |
17 #include "components/pref_registry/pref_registry_syncable.h" | 18 #include "components/pref_registry/pref_registry_syncable.h" |
18 #include "components/prefs/scoped_user_pref_update.h" | 19 #include "components/prefs/scoped_user_pref_update.h" |
19 #include "content/public/browser/permission_type.h" | |
20 #include "extensions/features/features.h" | 20 #include "extensions/features/features.h" |
21 #include "ui/message_center/notifier_settings.h" | 21 #include "ui/message_center/notifier_settings.h" |
22 | 22 |
23 #if BUILDFLAG(ENABLE_EXTENSIONS) | 23 #if BUILDFLAG(ENABLE_EXTENSIONS) |
24 #include "chrome/common/extensions/api/notifications.h" | 24 #include "chrome/common/extensions/api/notifications.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "extensions/browser/event_router.h" | 26 #include "extensions/browser/event_router.h" |
27 #include "extensions/browser/extension_event_histogram_value.h" | 27 #include "extensions/browser/extension_event_histogram_value.h" |
28 #include "extensions/browser/extension_system.h" | 28 #include "extensions/browser/extension_system.h" |
29 #include "extensions/browser/extension_util.h" | 29 #include "extensions/browser/extension_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 bool NotifierStateTracker::IsNotifierEnabled( | 82 bool NotifierStateTracker::IsNotifierEnabled( |
83 const NotifierId& notifier_id) const { | 83 const NotifierId& notifier_id) const { |
84 switch (notifier_id.type) { | 84 switch (notifier_id.type) { |
85 case NotifierId::APPLICATION: | 85 case NotifierId::APPLICATION: |
86 return disabled_extension_ids_.find(notifier_id.id) == | 86 return disabled_extension_ids_.find(notifier_id.id) == |
87 disabled_extension_ids_.end(); | 87 disabled_extension_ids_.end(); |
88 case NotifierId::WEB_PAGE: | 88 case NotifierId::WEB_PAGE: |
89 return PermissionManager::Get(profile_)->GetPermissionStatus( | 89 return PermissionManager::Get(profile_)->GetPermissionStatus( |
90 content::PermissionType::NOTIFICATIONS, notifier_id.url, | 90 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, notifier_id.url, |
91 notifier_id.url) == blink::mojom::PermissionStatus::GRANTED; | 91 notifier_id.url) == blink::mojom::PermissionStatus::GRANTED; |
92 case NotifierId::SYSTEM_COMPONENT: | 92 case NotifierId::SYSTEM_COMPONENT: |
93 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
94 return disabled_system_component_ids_.find(notifier_id.id) == | 94 return disabled_system_component_ids_.find(notifier_id.id) == |
95 disabled_system_component_ids_.end(); | 95 disabled_system_component_ids_.end(); |
96 #else | 96 #else |
97 // We do not disable system component notifications. | 97 // We do not disable system component notifications. |
98 return true; | 98 return true; |
99 #endif | 99 #endif |
100 case NotifierId::ARC_APPLICATION: | 100 case NotifierId::ARC_APPLICATION: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Tell the IO thread that this extension's permission for notifications | 200 // Tell the IO thread that this extension's permission for notifications |
201 // has changed. | 201 // has changed. |
202 extensions::InfoMap* extension_info_map = | 202 extensions::InfoMap* extension_info_map = |
203 extensions::ExtensionSystem::Get(profile_)->info_map(); | 203 extensions::ExtensionSystem::Get(profile_)->info_map(); |
204 content::BrowserThread::PostTask( | 204 content::BrowserThread::PostTask( |
205 content::BrowserThread::IO, FROM_HERE, | 205 content::BrowserThread::IO, FROM_HERE, |
206 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 206 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
207 extension_info_map, notifier_id.id, !enabled)); | 207 extension_info_map, notifier_id.id, !enabled)); |
208 } | 208 } |
209 #endif | 209 #endif |
OLD | NEW |