Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/notifications/notifier_state_tracker.cc

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: ready Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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"
20 #include "extensions/features/features.h" 19 #include "extensions/features/features.h"
21 #include "ui/message_center/notifier_settings.h" 20 #include "ui/message_center/notifier_settings.h"
22 21
23 #if BUILDFLAG(ENABLE_EXTENSIONS) 22 #if BUILDFLAG(ENABLE_EXTENSIONS)
24 #include "chrome/common/extensions/api/notifications.h" 23 #include "chrome/common/extensions/api/notifications.h"
25 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
26 #include "extensions/browser/event_router.h" 25 #include "extensions/browser/event_router.h"
27 #include "extensions/browser/extension_event_histogram_value.h" 26 #include "extensions/browser/extension_event_histogram_value.h"
28 #include "extensions/browser/extension_system.h" 27 #include "extensions/browser/extension_system.h"
29 #include "extensions/browser/extension_util.h" 28 #include "extensions/browser/extension_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 79 }
81 80
82 bool NotifierStateTracker::IsNotifierEnabled( 81 bool NotifierStateTracker::IsNotifierEnabled(
83 const NotifierId& notifier_id) const { 82 const NotifierId& notifier_id) const {
84 switch (notifier_id.type) { 83 switch (notifier_id.type) {
85 case NotifierId::APPLICATION: 84 case NotifierId::APPLICATION:
86 return disabled_extension_ids_.find(notifier_id.id) == 85 return disabled_extension_ids_.find(notifier_id.id) ==
87 disabled_extension_ids_.end(); 86 disabled_extension_ids_.end();
88 case NotifierId::WEB_PAGE: 87 case NotifierId::WEB_PAGE:
89 return PermissionManager::Get(profile_)->GetPermissionStatus( 88 return PermissionManager::Get(profile_)->GetPermissionStatus(
90 content::PermissionType::NOTIFICATIONS, notifier_id.url, 89 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, notifier_id.url,
91 notifier_id.url) == blink::mojom::PermissionStatus::GRANTED; 90 notifier_id.url) == blink::mojom::PermissionStatus::GRANTED;
92 case NotifierId::SYSTEM_COMPONENT: 91 case NotifierId::SYSTEM_COMPONENT:
93 #if defined(OS_CHROMEOS) 92 #if defined(OS_CHROMEOS)
94 return disabled_system_component_ids_.find(notifier_id.id) == 93 return disabled_system_component_ids_.find(notifier_id.id) ==
95 disabled_system_component_ids_.end(); 94 disabled_system_component_ids_.end();
96 #else 95 #else
97 // We do not disable system component notifications. 96 // We do not disable system component notifications.
98 return true; 97 return true;
99 #endif 98 #endif
100 case NotifierId::ARC_APPLICATION: 99 case NotifierId::ARC_APPLICATION:
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Tell the IO thread that this extension's permission for notifications 199 // Tell the IO thread that this extension's permission for notifications
201 // has changed. 200 // has changed.
202 extensions::InfoMap* extension_info_map = 201 extensions::InfoMap* extension_info_map =
203 extensions::ExtensionSystem::Get(profile_)->info_map(); 202 extensions::ExtensionSystem::Get(profile_)->info_map();
204 content::BrowserThread::PostTask( 203 content::BrowserThread::PostTask(
205 content::BrowserThread::IO, FROM_HERE, 204 content::BrowserThread::IO, FROM_HERE,
206 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 205 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
207 extension_info_map, notifier_id.id, !enabled)); 206 extension_info_map, notifier_id.id, !enabled));
208 } 207 }
209 #endif 208 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698