| 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 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" | 37 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
| 38 #include "chrome/browser/media/cast_transport_host_filter.h" | 38 #include "chrome/browser/media/cast_transport_host_filter.h" |
| 39 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 39 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 40 #include "chrome/browser/media/midi_permission_context.h" | 40 #include "chrome/browser/media/midi_permission_context.h" |
| 41 #include "chrome/browser/media/midi_permission_context_factory.h" | 41 #include "chrome/browser/media/midi_permission_context_factory.h" |
| 42 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" | 42 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" |
| 43 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" | 43 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" |
| 44 #include "chrome/browser/net/chrome_net_log.h" | 44 #include "chrome/browser/net/chrome_net_log.h" |
| 45 #include "chrome/browser/notifications/desktop_notification_service.h" | 45 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 46 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 46 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 47 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 47 #include "chrome/browser/platform_util.h" | 48 #include "chrome/browser/platform_util.h" |
| 48 #include "chrome/browser/prerender/prerender_final_status.h" | 49 #include "chrome/browser/prerender/prerender_final_status.h" |
| 49 #include "chrome/browser/prerender/prerender_manager.h" | 50 #include "chrome/browser/prerender/prerender_manager.h" |
| 50 #include "chrome/browser/prerender/prerender_manager_factory.h" | 51 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 51 #include "chrome/browser/prerender/prerender_message_filter.h" | 52 #include "chrome/browser/prerender/prerender_message_filter.h" |
| 52 #include "chrome/browser/prerender/prerender_tracker.h" | 53 #include "chrome/browser/prerender/prerender_tracker.h" |
| 53 #include "chrome/browser/printing/printing_message_filter.h" | 54 #include "chrome/browser/printing/printing_message_filter.h" |
| 54 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" | 55 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
| 55 #include "chrome/browser/profiles/profile.h" | 56 #include "chrome/browser/profiles/profile.h" |
| 56 #include "chrome/browser/profiles/profile_io_data.h" | 57 #include "chrome/browser/profiles/profile_io_data.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 #include "components/pref_registry/pref_registry_syncable.h" | 102 #include "components/pref_registry/pref_registry_syncable.h" |
| 102 #include "components/signin/core/common/profile_management_switches.h" | 103 #include "components/signin/core/common/profile_management_switches.h" |
| 103 #include "components/translate/core/common/translate_switches.h" | 104 #include "components/translate/core/common/translate_switches.h" |
| 104 #include "content/public/browser/browser_child_process_host.h" | 105 #include "content/public/browser/browser_child_process_host.h" |
| 105 #include "content/public/browser/browser_main_parts.h" | 106 #include "content/public/browser/browser_main_parts.h" |
| 106 #include "content/public/browser/browser_ppapi_host.h" | 107 #include "content/public/browser/browser_ppapi_host.h" |
| 107 #include "content/public/browser/browser_thread.h" | 108 #include "content/public/browser/browser_thread.h" |
| 108 #include "content/public/browser/browser_url_handler.h" | 109 #include "content/public/browser/browser_url_handler.h" |
| 109 #include "content/public/browser/child_process_data.h" | 110 #include "content/public/browser/child_process_data.h" |
| 110 #include "content/public/browser/child_process_security_policy.h" | 111 #include "content/public/browser/child_process_security_policy.h" |
| 111 #include "content/public/browser/desktop_notification_delegate.h" | |
| 112 #include "content/public/browser/permission_type.h" | 112 #include "content/public/browser/permission_type.h" |
| 113 #include "content/public/browser/render_frame_host.h" | 113 #include "content/public/browser/render_frame_host.h" |
| 114 #include "content/public/browser/render_process_host.h" | 114 #include "content/public/browser/render_process_host.h" |
| 115 #include "content/public/browser/render_view_host.h" | 115 #include "content/public/browser/render_view_host.h" |
| 116 #include "content/public/browser/resource_context.h" | 116 #include "content/public/browser/resource_context.h" |
| 117 #include "content/public/browser/site_instance.h" | 117 #include "content/public/browser/site_instance.h" |
| 118 #include "content/public/browser/web_contents.h" | 118 #include "content/public/browser/web_contents.h" |
| 119 #include "content/public/common/child_process_host.h" | 119 #include "content/public/common/child_process_host.h" |
| 120 #include "content/public/common/content_descriptors.h" | 120 #include "content/public/common/content_descriptors.h" |
| 121 #include "content/public/common/show_desktop_notification_params.h" | |
| 122 #include "content/public/common/url_utils.h" | 121 #include "content/public/common/url_utils.h" |
| 123 #include "content/public/common/web_preferences.h" | 122 #include "content/public/common/web_preferences.h" |
| 124 #include "net/base/mime_util.h" | 123 #include "net/base/mime_util.h" |
| 125 #include "net/cookies/canonical_cookie.h" | 124 #include "net/cookies/canonical_cookie.h" |
| 126 #include "net/cookies/cookie_options.h" | 125 #include "net/cookies/cookie_options.h" |
| 127 #include "net/ssl/ssl_cert_request_info.h" | 126 #include "net/ssl/ssl_cert_request_info.h" |
| 128 #include "ppapi/host/ppapi_host.h" | 127 #include "ppapi/host/ppapi_host.h" |
| 129 #include "storage/browser/fileapi/external_mount_points.h" | 128 #include "storage/browser/fileapi/external_mount_points.h" |
| 130 #include "ui/base/l10n/l10n_util.h" | 129 #include "ui/base/l10n/l10n_util.h" |
| 131 #include "ui/base/resource/resource_bundle.h" | 130 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 int render_process_id, | 1830 int render_process_id, |
| 1832 int render_frame_id) { | 1831 int render_frame_id) { |
| 1833 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, | 1832 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, |
| 1834 render_process_id, render_frame_id); | 1833 render_process_id, render_frame_id); |
| 1835 } | 1834 } |
| 1836 | 1835 |
| 1837 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { | 1836 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
| 1838 return MediaCaptureDevicesDispatcher::GetInstance(); | 1837 return MediaCaptureDevicesDispatcher::GetInstance(); |
| 1839 } | 1838 } |
| 1840 | 1839 |
| 1841 blink::WebNotificationPermission | 1840 content::PlatformNotificationService* |
| 1842 ChromeContentBrowserClient::CheckDesktopNotificationPermission( | 1841 ChromeContentBrowserClient::GetPlatformNotificationService() { |
| 1843 const GURL& source_origin, | |
| 1844 content::ResourceContext* context, | |
| 1845 int render_process_id) { | |
| 1846 #if defined(ENABLE_NOTIFICATIONS) | 1842 #if defined(ENABLE_NOTIFICATIONS) |
| 1847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1843 return PlatformNotificationServiceImpl::GetInstance(); |
| 1848 | |
| 1849 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | |
| 1850 #if defined(ENABLE_EXTENSIONS) | |
| 1851 InfoMap* extension_info_map = io_data->GetExtensionInfoMap(); | |
| 1852 | |
| 1853 // We want to see if there is an extension that hasn't been manually disabled | |
| 1854 // that has the notifications permission and applies to this security origin. | |
| 1855 // First, get the list of extensions with permission for the origin. | |
| 1856 extensions::ExtensionSet extensions; | |
| 1857 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( | |
| 1858 source_origin, | |
| 1859 render_process_id, | |
| 1860 extensions::APIPermission::kNotifications, | |
| 1861 &extensions); | |
| 1862 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); | |
| 1863 iter != extensions.end(); ++iter) { | |
| 1864 // Then, check to see if it's been disabled by the user. | |
| 1865 if (!extension_info_map->AreNotificationsDisabled((*iter)->id())) | |
| 1866 return blink::WebNotificationPermissionAllowed; | |
| 1867 } | |
| 1868 #endif | |
| 1869 | |
| 1870 // No enabled extensions exist, so check the normal host content settings. | |
| 1871 HostContentSettingsMap* host_content_settings_map = | |
| 1872 io_data->GetHostContentSettingsMap(); | |
| 1873 ContentSetting setting = host_content_settings_map->GetContentSetting( | |
| 1874 source_origin, | |
| 1875 source_origin, | |
| 1876 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | |
| 1877 NO_RESOURCE_IDENTIFIER); | |
| 1878 | |
| 1879 if (setting == CONTENT_SETTING_ALLOW) | |
| 1880 return blink::WebNotificationPermissionAllowed; | |
| 1881 if (setting == CONTENT_SETTING_BLOCK) | |
| 1882 return blink::WebNotificationPermissionDenied; | |
| 1883 return blink::WebNotificationPermissionDefault; | |
| 1884 #else | 1844 #else |
| 1885 return blink::WebNotificationPermissionAllowed; | 1845 NOTIMPLEMENTED(); |
| 1846 return NULL; |
| 1886 #endif | 1847 #endif |
| 1887 } | 1848 } |
| 1888 | 1849 |
| 1889 void ChromeContentBrowserClient::ShowDesktopNotification( | |
| 1890 const content::ShowDesktopNotificationHostMsgParams& params, | |
| 1891 content::BrowserContext* browser_context, | |
| 1892 int render_process_id, | |
| 1893 scoped_ptr<content::DesktopNotificationDelegate> delegate, | |
| 1894 base::Closure* cancel_callback) { | |
| 1895 #if defined(ENABLE_NOTIFICATIONS) | |
| 1896 Profile* profile = Profile::FromBrowserContext(browser_context); | |
| 1897 DCHECK(profile); | |
| 1898 | |
| 1899 DesktopNotificationService* service = | |
| 1900 DesktopNotificationServiceFactory::GetForProfile(profile); | |
| 1901 DCHECK(service); | |
| 1902 | |
| 1903 service->ShowDesktopNotification( | |
| 1904 params, render_process_id, delegate.Pass(), cancel_callback); | |
| 1905 profile->GetHostContentSettingsMap()->UpdateLastUsage( | |
| 1906 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | |
| 1907 #else | |
| 1908 NOTIMPLEMENTED(); | |
| 1909 #endif | |
| 1910 } | |
| 1911 | |
| 1912 void ChromeContentBrowserClient::RequestPermission( | 1850 void ChromeContentBrowserClient::RequestPermission( |
| 1913 content::PermissionType permission, | 1851 content::PermissionType permission, |
| 1914 content::WebContents* web_contents, | 1852 content::WebContents* web_contents, |
| 1915 int bridge_id, | 1853 int bridge_id, |
| 1916 const GURL& requesting_frame, | 1854 const GURL& requesting_frame, |
| 1917 bool user_gesture, | 1855 bool user_gesture, |
| 1918 const base::Callback<void(bool)>& result_callback) { | 1856 const base::Callback<void(bool)>& result_callback) { |
| 1919 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 1857 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 1920 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 1858 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 1921 Profile* profile = | 1859 Profile* profile = |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2612 switches::kDisableWebRtcEncryption, | 2550 switches::kDisableWebRtcEncryption, |
| 2613 }; | 2551 }; |
| 2614 to_command_line->CopySwitchesFrom(from_command_line, | 2552 to_command_line->CopySwitchesFrom(from_command_line, |
| 2615 kWebRtcDevSwitchNames, | 2553 kWebRtcDevSwitchNames, |
| 2616 arraysize(kWebRtcDevSwitchNames)); | 2554 arraysize(kWebRtcDevSwitchNames)); |
| 2617 } | 2555 } |
| 2618 } | 2556 } |
| 2619 #endif // defined(ENABLE_WEBRTC) | 2557 #endif // defined(ENABLE_WEBRTC) |
| 2620 | 2558 |
| 2621 } // namespace chrome | 2559 } // namespace chrome |
| OLD | NEW |