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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 61323002: Fix broken threading model in CheckDesktopNotificationPermission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Even more merge conflicts.. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 620ac98d46306a27a851cc90dee2adc16628f320..93e379627761945f3cf9cd0a737c342a30c10ba5 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1941,31 +1941,37 @@ blink::WebNotificationPresenter::Permission
int render_process_id) {
#if defined(ENABLE_NOTIFICATIONS)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- // Sometimes a notification may be invoked during the shutdown.
- // See http://crbug.com/256638
- if (browser_shutdown::IsTryingToQuit())
- return blink::WebNotificationPresenter::PermissionNotAllowed;
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
-
- DesktopNotificationService* notification_service =
- io_data->GetNotificationService();
- if (notification_service) {
- InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
- ExtensionSet extensions;
- extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
- source_origin, render_process_id,
- extensions::APIPermission::kNotification, &extensions);
- for (ExtensionSet::const_iterator iter = extensions.begin();
- iter != extensions.end(); ++iter) {
- NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id());
- if (notification_service->IsNotifierEnabled(notifier_id))
- return blink::WebNotificationPresenter::PermissionAllowed;
- }
-
- return notification_service->HasPermission(source_origin);
- }
-
+ InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
+
+ // We want to see if there is an extension that hasn't been manually disabled
+ // that has the notifications permission and applies to this security origin.
+ // First, get the list of extensions with permission for the origin.
+ ExtensionSet extensions;
+ extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
+ source_origin, render_process_id,
+ extensions::APIPermission::kNotification, &extensions);
+ for (ExtensionSet::const_iterator iter = extensions.begin();
+ iter != extensions.end(); ++iter) {
+ // Then, check to see if it's been disabled by the user.
+ if (!extension_info_map->AreNotificationsDisabled((*iter)->id()))
+ return blink::WebNotificationPresenter::PermissionAllowed;
+ }
+
+ // No enabled extensions exist, so check the normal host content settings.
+ HostContentSettingsMap* host_content_settings_map =
+ io_data->GetHostContentSettingsMap();
+ ContentSetting setting = host_content_settings_map->GetContentSetting(
+ source_origin,
+ source_origin,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ NO_RESOURCE_IDENTIFIER);
+
+ if (setting == CONTENT_SETTING_ALLOW)
+ return blink::WebNotificationPresenter::PermissionAllowed;
+ if (setting == CONTENT_SETTING_BLOCK)
+ return blink::WebNotificationPresenter::PermissionDenied;
return blink::WebNotificationPresenter::PermissionNotAllowed;
#else
return blink::WebNotificationPresenter::PermissionAllowed;
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698