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 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( | 1796 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
1797 const GURL& source_origin, | 1797 const GURL& source_origin, |
1798 content::RenderFrameHost* render_frame_host, | 1798 content::RenderFrameHost* render_frame_host, |
1799 const base::Callback<void(blink::WebNotificationPermission)>& callback) { | 1799 const base::Callback<void(blink::WebNotificationPermission)>& callback) { |
1800 #if defined(ENABLE_NOTIFICATIONS) | 1800 #if defined(ENABLE_NOTIFICATIONS) |
1801 // Skip showing the infobar if the request comes from an extension, and that | 1801 // Skip showing the infobar if the request comes from an extension, and that |
1802 // extension has the 'notify' permission. (If the extension does not have the | 1802 // extension has the 'notify' permission. (If the extension does not have the |
1803 // permission, the user will still be prompted.) | 1803 // permission, the user will still be prompted.) |
1804 Profile* profile = Profile::FromBrowserContext( | 1804 Profile* profile = Profile::FromBrowserContext( |
1805 render_frame_host->GetSiteInstance()->GetBrowserContext()); | 1805 render_frame_host->GetSiteInstance()->GetBrowserContext()); |
| 1806 DesktopNotificationService* notification_service = |
| 1807 DesktopNotificationServiceFactory::GetForProfile(profile); |
| 1808 #if defined(ENABLE_EXTENSIONS) |
1806 InfoMap* extension_info_map = | 1809 InfoMap* extension_info_map = |
1807 extensions::ExtensionSystem::Get(profile)->info_map(); | 1810 extensions::ExtensionSystem::Get(profile)->info_map(); |
1808 DesktopNotificationService* notification_service = | |
1809 DesktopNotificationServiceFactory::GetForProfile(profile); | |
1810 const Extension* extension = NULL; | 1811 const Extension* extension = NULL; |
1811 if (extension_info_map) { | 1812 if (extension_info_map) { |
1812 extensions::ExtensionSet extensions; | 1813 extensions::ExtensionSet extensions; |
1813 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( | 1814 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( |
1814 source_origin, | 1815 source_origin, |
1815 render_frame_host->GetProcess()->GetID(), | 1816 render_frame_host->GetProcess()->GetID(), |
1816 extensions::APIPermission::kNotifications, | 1817 extensions::APIPermission::kNotifications, |
1817 &extensions); | 1818 &extensions); |
1818 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); | 1819 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); |
1819 iter != extensions.end(); ++iter) { | 1820 iter != extensions.end(); ++iter) { |
1820 if (notification_service->IsNotifierEnabled(NotifierId( | 1821 if (notification_service->IsNotifierEnabled(NotifierId( |
1821 NotifierId::APPLICATION, (*iter)->id()))) { | 1822 NotifierId::APPLICATION, (*iter)->id()))) { |
1822 extension = iter->get(); | 1823 extension = iter->get(); |
1823 break; | 1824 break; |
1824 } | 1825 } |
1825 } | 1826 } |
1826 } | 1827 } |
1827 if (IsExtensionWithPermissionOrSuggestInConsole( | 1828 if (IsExtensionWithPermissionOrSuggestInConsole( |
1828 APIPermission::kNotifications, | 1829 APIPermission::kNotifications, |
1829 extension, | 1830 extension, |
1830 render_frame_host->GetRenderViewHost())) { | 1831 render_frame_host->GetRenderViewHost())) { |
1831 callback.Run(blink::WebNotificationPermissionAllowed); | 1832 callback.Run(blink::WebNotificationPermissionAllowed); |
1832 return; | 1833 return; |
1833 } | 1834 } |
| 1835 #endif |
1834 | 1836 |
1835 WebContents* web_contents = WebContents::FromRenderFrameHost( | 1837 WebContents* web_contents = WebContents::FromRenderFrameHost( |
1836 render_frame_host); | 1838 render_frame_host); |
1837 int render_process_id = render_frame_host->GetProcess()->GetID(); | 1839 int render_process_id = render_frame_host->GetProcess()->GetID(); |
1838 const PermissionRequestID request_id(render_process_id, | 1840 const PermissionRequestID request_id(render_process_id, |
1839 web_contents->GetRoutingID(), | 1841 web_contents->GetRoutingID(), |
1840 -1 /* bridge id */, | 1842 -1 /* bridge id */, |
1841 GURL()); | 1843 GURL()); |
1842 | 1844 |
1843 notification_service->RequestNotificationPermission( | 1845 notification_service->RequestNotificationPermission( |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 switches::kDisableWebRtcEncryption, | 2616 switches::kDisableWebRtcEncryption, |
2615 }; | 2617 }; |
2616 to_command_line->CopySwitchesFrom(from_command_line, | 2618 to_command_line->CopySwitchesFrom(from_command_line, |
2617 kWebRtcDevSwitchNames, | 2619 kWebRtcDevSwitchNames, |
2618 arraysize(kWebRtcDevSwitchNames)); | 2620 arraysize(kWebRtcDevSwitchNames)); |
2619 } | 2621 } |
2620 } | 2622 } |
2621 #endif // defined(ENABLE_WEBRTC) | 2623 #endif // defined(ENABLE_WEBRTC) |
2622 | 2624 |
2623 } // namespace chrome | 2625 } // namespace chrome |
OLD | NEW |