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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 #endif 1934 #endif
1935 } 1935 }
1936 1936
1937 blink::WebNotificationPresenter::Permission 1937 blink::WebNotificationPresenter::Permission
1938 ChromeContentBrowserClient::CheckDesktopNotificationPermission( 1938 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
1939 const GURL& source_origin, 1939 const GURL& source_origin,
1940 content::ResourceContext* context, 1940 content::ResourceContext* context,
1941 int render_process_id) { 1941 int render_process_id) {
1942 #if defined(ENABLE_NOTIFICATIONS) 1942 #if defined(ENABLE_NOTIFICATIONS)
1943 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1943 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1944 // Sometimes a notification may be invoked during the shutdown.
1945 // See http://crbug.com/256638
1946 if (browser_shutdown::IsTryingToQuit())
1947 return blink::WebNotificationPresenter::PermissionNotAllowed;
1948 1944
1949 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1945 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1946 InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
1950 1947
1951 DesktopNotificationService* notification_service = 1948 // We want to see if there is an extension that hasn't been manually disabled
1952 io_data->GetNotificationService(); 1949 // that has the notifications permission and applies to this security origin.
1953 if (notification_service) { 1950 // First, get the list of extensions with permission for the origin.
1954 InfoMap* extension_info_map = io_data->GetExtensionInfoMap(); 1951 ExtensionSet extensions;
1955 ExtensionSet extensions; 1952 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1956 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 1953 source_origin, render_process_id,
1957 source_origin, render_process_id, 1954 extensions::APIPermission::kNotification, &extensions);
1958 extensions::APIPermission::kNotification, &extensions); 1955 for (ExtensionSet::const_iterator iter = extensions.begin();
1959 for (ExtensionSet::const_iterator iter = extensions.begin(); 1956 iter != extensions.end(); ++iter) {
1960 iter != extensions.end(); ++iter) { 1957 // Then, check to see if it's been disabled by the user.
1961 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); 1958 if (!extension_info_map->AreNotificationsDisabled((*iter)->id()))
1962 if (notification_service->IsNotifierEnabled(notifier_id)) 1959 return blink::WebNotificationPresenter::PermissionAllowed;
1963 return blink::WebNotificationPresenter::PermissionAllowed;
1964 }
1965
1966 return notification_service->HasPermission(source_origin);
1967 } 1960 }
1968 1961
1962 // No enabled extensions exist, so check the normal host content settings.
1963 HostContentSettingsMap* host_content_settings_map =
1964 io_data->GetHostContentSettingsMap();
1965 ContentSetting setting = host_content_settings_map->GetContentSetting(
1966 source_origin,
1967 source_origin,
1968 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1969 NO_RESOURCE_IDENTIFIER);
1970
1971 if (setting == CONTENT_SETTING_ALLOW)
1972 return blink::WebNotificationPresenter::PermissionAllowed;
1973 if (setting == CONTENT_SETTING_BLOCK)
1974 return blink::WebNotificationPresenter::PermissionDenied;
1969 return blink::WebNotificationPresenter::PermissionNotAllowed; 1975 return blink::WebNotificationPresenter::PermissionNotAllowed;
1970 #else 1976 #else
1971 return blink::WebNotificationPresenter::PermissionAllowed; 1977 return blink::WebNotificationPresenter::PermissionAllowed;
1972 #endif 1978 #endif
1973 } 1979 }
1974 1980
1975 void ChromeContentBrowserClient::ShowDesktopNotification( 1981 void ChromeContentBrowserClient::ShowDesktopNotification(
1976 const content::ShowDesktopNotificationHostMsgParams& params, 1982 const content::ShowDesktopNotificationHostMsgParams& params,
1977 int render_process_id, 1983 int render_process_id,
1978 int render_view_id, 1984 int render_view_id,
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, 2638 return IsExtensionOrSharedModuleWhitelisted(url, extension_set,
2633 allowed_file_handle_origins_) || 2639 allowed_file_handle_origins_) ||
2634 IsHostAllowedByCommandLine(url, extension_set, 2640 IsHostAllowedByCommandLine(url, extension_set,
2635 switches::kAllowNaClFileHandleAPI); 2641 switches::kAllowNaClFileHandleAPI);
2636 #else 2642 #else
2637 return false; 2643 return false;
2638 #endif 2644 #endif
2639 } 2645 }
2640 2646
2641 } // namespace chrome 2647 } // namespace chrome
OLDNEW
« 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