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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 #endif 1931 #endif
1932 } 1932 }
1933 1933
1934 WebKit::WebNotificationPresenter::Permission 1934 WebKit::WebNotificationPresenter::Permission
1935 ChromeContentBrowserClient::CheckDesktopNotificationPermission( 1935 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
1936 const GURL& source_origin, 1936 const GURL& source_origin,
1937 content::ResourceContext* context, 1937 content::ResourceContext* context,
1938 int render_process_id) { 1938 int render_process_id) {
1939 #if defined(ENABLE_NOTIFICATIONS) 1939 #if defined(ENABLE_NOTIFICATIONS)
1940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1941 // Sometimes a notification may be invoked during the shutdown.
1942 // See http://crbug.com/256638
1943 if (browser_shutdown::IsTryingToQuit())
1944 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
1945 1941
1946 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1942 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1943 ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap();
1947 1944
1948 DesktopNotificationService* notification_service = 1945 // We want to see if there is an extension that hasn't been manually disabled
1949 io_data->GetNotificationService(); 1946 // that has the notifications permission and applies to this security origin.
1950 if (notification_service) { 1947 // First, get the list of extensions with permission for the origin.
1951 ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap(); 1948 ExtensionSet extensions;
1952 ExtensionSet extensions; 1949 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1953 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 1950 source_origin, render_process_id,
1954 source_origin, render_process_id, 1951 extensions::APIPermission::kNotification, &extensions);
1955 extensions::APIPermission::kNotification, &extensions); 1952 for (ExtensionSet::const_iterator iter = extensions.begin();
1956 for (ExtensionSet::const_iterator iter = extensions.begin(); 1953 iter != extensions.end(); ++iter) {
1957 iter != extensions.end(); ++iter) { 1954 // Then, check to see if it's been disabled by the user.
1958 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); 1955 const std::string& id = (*iter)->id();
1959 if (notification_service->IsNotifierEnabled(notifier_id)) 1956 if (!extension_info_map->GetNotificationsDisabledForExtension(id))
1960 return WebKit::WebNotificationPresenter::PermissionAllowed; 1957 return WebKit::WebNotificationPresenter::PermissionAllowed;
1961 }
1962
1963 return notification_service->HasPermission(source_origin);
1964 } 1958 }
1965 1959
1960 // No enabled extensions exist, so check the normal host content settings.
1961 HostContentSettingsMap* host_content_settings_map =
1962 io_data->GetHostContentSettingsMap();
1963 ContentSetting setting = host_content_settings_map->GetContentSetting(
1964 source_origin,
1965 source_origin,
1966 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1967 NO_RESOURCE_IDENTIFIER);
1968
1969 if (setting == CONTENT_SETTING_ALLOW)
1970 return WebKit::WebNotificationPresenter::PermissionAllowed;
1971 if (setting == CONTENT_SETTING_BLOCK)
1972 return WebKit::WebNotificationPresenter::PermissionDenied;
1966 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 1973 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
1967 #else 1974 #else
1968 return WebKit::WebNotificationPresenter::PermissionAllowed; 1975 return WebKit::WebNotificationPresenter::PermissionAllowed;
1969 #endif 1976 #endif
1970 } 1977 }
1971 1978
1972 void ChromeContentBrowserClient::ShowDesktopNotification( 1979 void ChromeContentBrowserClient::ShowDesktopNotification(
1973 const content::ShowDesktopNotificationHostMsgParams& params, 1980 const content::ShowDesktopNotificationHostMsgParams& params,
1974 int render_process_id, 1981 int render_process_id,
1975 int render_view_id, 1982 int render_view_id,
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, 2651 return IsExtensionOrSharedModuleWhitelisted(url, extension_set,
2645 allowed_file_handle_origins_) || 2652 allowed_file_handle_origins_) ||
2646 IsHostAllowedByCommandLine(url, extension_set, 2653 IsHostAllowedByCommandLine(url, extension_set,
2647 switches::kAllowNaClFileHandleAPI); 2654 switches::kAllowNaClFileHandleAPI);
2648 #else 2655 #else
2649 return false; 2656 return false;
2650 #endif 2657 #endif
2651 } 2658 }
2652 2659
2653 } // namespace chrome 2660 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_info_map.h » ('j') | chrome/browser/extensions/extension_info_map.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698