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

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

Issue 2713083003: Use ContentSetting in chrome/ instead of PermissionStatus (Closed)
Patch Set: maybe fix android compile + address comments + basic tests Created 3 years, 9 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/permissions/permission_result.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "components/content_settings/core/common/content_settings_types.h" 18 #include "components/content_settings/core/common/content_settings_types.h"
18 #include "components/pref_registry/pref_registry_syncable.h" 19 #include "components/pref_registry/pref_registry_syncable.h"
19 #include "components/prefs/scoped_user_pref_update.h" 20 #include "components/prefs/scoped_user_pref_update.h"
20 #include "extensions/features/features.h" 21 #include "extensions/features/features.h"
21 #include "ui/message_center/notifier_settings.h" 22 #include "ui/message_center/notifier_settings.h"
22 23
23 #if BUILDFLAG(ENABLE_EXTENSIONS) 24 #if BUILDFLAG(ENABLE_EXTENSIONS)
24 #include "chrome/common/extensions/api/notifications.h" 25 #include "chrome/common/extensions/api/notifications.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 NotifierStateTracker::~NotifierStateTracker() { 80 NotifierStateTracker::~NotifierStateTracker() {
80 } 81 }
81 82
82 bool NotifierStateTracker::IsNotifierEnabled( 83 bool NotifierStateTracker::IsNotifierEnabled(
83 const NotifierId& notifier_id) const { 84 const NotifierId& notifier_id) const {
84 switch (notifier_id.type) { 85 switch (notifier_id.type) {
85 case NotifierId::APPLICATION: 86 case NotifierId::APPLICATION:
86 return disabled_extension_ids_.find(notifier_id.id) == 87 return disabled_extension_ids_.find(notifier_id.id) ==
87 disabled_extension_ids_.end(); 88 disabled_extension_ids_.end();
88 case NotifierId::WEB_PAGE: 89 case NotifierId::WEB_PAGE:
89 return PermissionManager::Get(profile_)->GetPermissionStatus( 90 return PermissionManager::Get(profile_)
90 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, notifier_id.url, 91 ->GetPermissionStatus(CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
91 notifier_id.url) == blink::mojom::PermissionStatus::GRANTED; 92 notifier_id.url, notifier_id.url)
93 .content_setting == CONTENT_SETTING_ALLOW;
92 case NotifierId::SYSTEM_COMPONENT: 94 case NotifierId::SYSTEM_COMPONENT:
93 #if defined(OS_CHROMEOS) 95 #if defined(OS_CHROMEOS)
94 return disabled_system_component_ids_.find(notifier_id.id) == 96 return disabled_system_component_ids_.find(notifier_id.id) ==
95 disabled_system_component_ids_.end(); 97 disabled_system_component_ids_.end();
96 #else 98 #else
97 // We do not disable system component notifications. 99 // We do not disable system component notifications.
98 return true; 100 return true;
99 #endif 101 #endif
100 case NotifierId::ARC_APPLICATION: 102 case NotifierId::ARC_APPLICATION:
101 #if defined(OS_CHROMEOS) 103 #if defined(OS_CHROMEOS)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Tell the IO thread that this extension's permission for notifications 202 // Tell the IO thread that this extension's permission for notifications
201 // has changed. 203 // has changed.
202 extensions::InfoMap* extension_info_map = 204 extensions::InfoMap* extension_info_map =
203 extensions::ExtensionSystem::Get(profile_)->info_map(); 205 extensions::ExtensionSystem::Get(profile_)->info_map();
204 content::BrowserThread::PostTask( 206 content::BrowserThread::PostTask(
205 content::BrowserThread::IO, FROM_HERE, 207 content::BrowserThread::IO, FROM_HERE,
206 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 208 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
207 extension_info_map, notifier_id.id, !enabled)); 209 extension_info_map, notifier_id.id, !enabled));
208 } 210 }
209 #endif 211 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698