OLD | NEW |
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 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 } | 1839 } |
1840 | 1840 |
1841 notification_service->RequestPermission(source_origin, render_process_id, | 1841 notification_service->RequestPermission(source_origin, render_process_id, |
1842 render_view_id, callback_context, contents); | 1842 render_view_id, callback_context, contents); |
1843 #else | 1843 #else |
1844 NOTIMPLEMENTED(); | 1844 NOTIMPLEMENTED(); |
1845 #endif | 1845 #endif |
1846 } | 1846 } |
1847 | 1847 |
1848 WebKit::WebNotificationPresenter::Permission | 1848 WebKit::WebNotificationPresenter::Permission |
1849 ChromeContentBrowserClient::CheckDesktopNotificationPermission( | 1849 ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
1850 const GURL& source_origin, | 1850 const GURL& source_origin, |
1851 content::ResourceContext* context, | 1851 content::ResourceContext* context, |
1852 int render_process_id) { | 1852 int render_process_id) { |
1853 #if defined(ENABLE_NOTIFICATIONS) | 1853 #if defined(ENABLE_NOTIFICATIONS) |
1854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1855 // Sometimes a notification may be invoked during the shutdown. | 1855 content::RenderProcessHost* process = |
1856 // See http://crbug.com/256638 | 1856 content::RenderProcessHost::FromID(render_process_id); |
1857 if (browser_shutdown::IsTryingToQuit()) | 1857 DCHECK(process); |
| 1858 |
| 1859 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
| 1860 DesktopNotificationService* notification_service = |
| 1861 DesktopNotificationServiceFactory::GetForProfile(profile); |
| 1862 |
| 1863 if (!notification_service) { |
1858 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 1864 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
1859 | |
1860 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | |
1861 | |
1862 DesktopNotificationService* notification_service = | |
1863 io_data->GetNotificationService(); | |
1864 if (notification_service) { | |
1865 ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap(); | |
1866 ExtensionSet extensions; | |
1867 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( | |
1868 source_origin, render_process_id, | |
1869 extensions::APIPermission::kNotification, &extensions); | |
1870 for (ExtensionSet::const_iterator iter = extensions.begin(); | |
1871 iter != extensions.end(); ++iter) { | |
1872 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); | |
1873 if (notification_service->IsNotifierEnabled(notifier_id)) | |
1874 return WebKit::WebNotificationPresenter::PermissionAllowed; | |
1875 } | |
1876 | |
1877 return notification_service->HasPermission(source_origin); | |
1878 } | 1865 } |
1879 | 1866 |
1880 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 1867 return notification_service->HasPermission(source_origin, render_process_id); |
1881 #else | 1868 #else |
1882 return WebKit::WebNotificationPresenter::PermissionAllowed; | 1869 return WebKit::WebNotificationPresenter::PermissionAllowed; |
1883 #endif | 1870 #endif |
1884 } | 1871 } |
1885 | 1872 |
1886 void ChromeContentBrowserClient::ShowDesktopNotification( | 1873 void ChromeContentBrowserClient::ShowDesktopNotification( |
1887 const content::ShowDesktopNotificationHostMsgParams& params, | 1874 const content::ShowDesktopNotificationHostMsgParams& params, |
1888 int render_process_id, | 1875 int render_process_id, |
1889 int render_view_id, | 1876 int render_view_id, |
1890 bool worker) { | 1877 bool worker) { |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2541 #if defined(USE_NSS) | 2528 #if defined(USE_NSS) |
2542 crypto::CryptoModuleBlockingPasswordDelegate* | 2529 crypto::CryptoModuleBlockingPasswordDelegate* |
2543 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 2530 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
2544 const GURL& url) { | 2531 const GURL& url) { |
2545 return chrome::NewCryptoModuleBlockingDialogDelegate( | 2532 return chrome::NewCryptoModuleBlockingDialogDelegate( |
2546 chrome::kCryptoModulePasswordKeygen, url.host()); | 2533 chrome::kCryptoModulePasswordKeygen, url.host()); |
2547 } | 2534 } |
2548 #endif | 2535 #endif |
2549 | 2536 |
2550 } // namespace chrome | 2537 } // namespace chrome |
OLD | NEW |