Chromium Code Reviews| 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 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1809 int render_process_id, | 1809 int render_process_id, |
| 1810 int render_frame_id) { | 1810 int render_frame_id) { |
| 1811 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, | 1811 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, |
| 1812 render_process_id, render_frame_id); | 1812 render_process_id, render_frame_id); |
| 1813 } | 1813 } |
| 1814 | 1814 |
| 1815 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { | 1815 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
| 1816 return MediaCaptureDevicesDispatcher::GetInstance(); | 1816 return MediaCaptureDevicesDispatcher::GetInstance(); |
| 1817 } | 1817 } |
| 1818 | 1818 |
| 1819 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( | |
| 1820 const GURL& source_origin, | |
| 1821 content::RenderFrameHost* render_frame_host, | |
| 1822 const base::Callback<void(blink::WebNotificationPermission)>& callback) { | |
| 1823 #if defined(ENABLE_NOTIFICATIONS) | |
| 1824 // Skip showing the infobar if the request comes from an extension, and that | |
| 1825 // extension has the 'notify' permission. (If the extension does not have the | |
| 1826 // permission, the user will still be prompted.) | |
| 1827 Profile* profile = Profile::FromBrowserContext( | |
| 1828 render_frame_host->GetSiteInstance()->GetBrowserContext()); | |
| 1829 DesktopNotificationService* notification_service = | |
| 1830 DesktopNotificationServiceFactory::GetForProfile(profile); | |
| 1831 WebContents* web_contents = WebContents::FromRenderFrameHost( | |
| 1832 render_frame_host); | |
| 1833 int render_process_id = render_frame_host->GetProcess()->GetID(); | |
| 1834 const PermissionRequestID request_id(render_process_id, | |
| 1835 web_contents->GetRoutingID(), | |
| 1836 -1 /* bridge id */, | |
| 1837 GURL()); | |
| 1838 | |
| 1839 notification_service->RequestNotificationPermission( | |
| 1840 web_contents, | |
| 1841 request_id, | |
| 1842 source_origin, | |
| 1843 // TODO(peter): plumb user_gesture over IPC | |
| 1844 true, | |
| 1845 callback); | |
| 1846 | |
| 1847 #else | |
| 1848 NOTIMPLEMENTED(); | |
| 1849 #endif | |
| 1850 } | |
| 1851 | |
| 1852 blink::WebNotificationPermission | 1819 blink::WebNotificationPermission |
| 1853 ChromeContentBrowserClient::CheckDesktopNotificationPermission( | 1820 ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
| 1854 const GURL& source_origin, | 1821 const GURL& source_origin, |
| 1855 content::ResourceContext* context, | 1822 content::ResourceContext* context, |
| 1856 int render_process_id) { | 1823 int render_process_id) { |
| 1857 #if defined(ENABLE_NOTIFICATIONS) | 1824 #if defined(ENABLE_NOTIFICATIONS) |
| 1858 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1825 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1859 | 1826 |
| 1860 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1827 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1861 #if defined(ENABLE_EXTENSIONS) | 1828 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1910 service->ShowDesktopNotification( | 1877 service->ShowDesktopNotification( |
| 1911 params, render_frame_host, delegate.Pass(), cancel_callback); | 1878 params, render_frame_host, delegate.Pass(), cancel_callback); |
| 1912 | 1879 |
| 1913 profile->GetHostContentSettingsMap()->UpdateLastUsage( | 1880 profile->GetHostContentSettingsMap()->UpdateLastUsage( |
| 1914 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 1881 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 1915 #else | 1882 #else |
| 1916 NOTIMPLEMENTED(); | 1883 NOTIMPLEMENTED(); |
| 1917 #endif | 1884 #endif |
| 1918 } | 1885 } |
| 1919 | 1886 |
| 1920 void ChromeContentBrowserClient::RequestGeolocationPermission( | 1887 void ChromeContentBrowserClient::RequestPermission( |
| 1888 content::PermissionType permission, | |
| 1921 content::WebContents* web_contents, | 1889 content::WebContents* web_contents, |
| 1922 int bridge_id, | 1890 int bridge_id, |
| 1923 const GURL& requesting_frame, | 1891 const GURL& requesting_frame, |
| 1924 bool user_gesture, | 1892 bool user_gesture, |
| 1925 const base::Callback<void(bool)>& result_callback) { | 1893 const base::Callback<void(bool)>& result_callback) { |
| 1926 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 1894 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 1927 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 1895 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 1896 Profile* profile = Profile::FromBrowserContext( | |
| 1897 web_contents->GetBrowserContext()); | |
|
Peter Beverloo
2014/10/20 17:32:16
Profile* profile =
Profile::FromBrowserConte
Miguel Garcia
2014/10/21 17:17:12
Done.
| |
| 1928 | 1898 |
| 1929 const PermissionRequestID request_id(render_process_id, | 1899 const PermissionRequestID request_id(render_process_id, |
| 1930 render_view_id, | 1900 render_view_id, |
| 1931 bridge_id, | 1901 bridge_id, |
| 1932 requesting_frame); | 1902 requesting_frame); |
| 1933 GeolocationPermissionContextFactory::GetForProfile( | 1903 |
| 1934 Profile::FromBrowserContext(web_contents->GetBrowserContext()))-> | 1904 switch (permission) { |
| 1935 RequestPermission(web_contents, request_id, | 1905 case content::PERMISSION_MIDI_SYSEX: |
| 1936 requesting_frame.GetOrigin(), user_gesture, | 1906 MidiPermissionContextFactory::GetForProfile(profile)->RequestPermission( |
| 1937 result_callback); | 1907 web_contents, request_id, requesting_frame, |
| 1908 user_gesture, result_callback); | |
| 1909 break; | |
| 1910 case content::PERMISSION_NOTIFICATIONS: | |
| 1911 #if defined(ENABLE_NOTIFICATIONS) | |
| 1912 DesktopNotificationServiceFactory::GetForProfile(profile) | |
| 1913 ->RequestNotificationPermission( | |
|
Bernhard Bauer
2014/10/20 14:57:24
At the very least, indent this four more spaces, a
Miguel Garcia
2014/10/21 17:17:11
Done.
| |
| 1914 web_contents, | |
| 1915 request_id, | |
| 1916 requesting_frame, | |
| 1917 user_gesture, | |
| 1918 result_callback); | |
| 1919 #else | |
| 1920 NOTIMPLEMENTED(); | |
|
Bernhard Bauer
2014/10/20 14:57:24
Fix alignment.
Miguel Garcia
2014/10/21 17:17:12
Done.
| |
| 1921 #endif | |
| 1922 break; | |
| 1923 case content::PERMISSION_GEOLOCATION: | |
| 1924 GeolocationPermissionContextFactory::GetForProfile(profile) | |
| 1925 ->RequestPermission(web_contents, request_id, | |
| 1926 requesting_frame.GetOrigin(), user_gesture, | |
| 1927 result_callback); | |
| 1928 break; | |
| 1929 #if defined(OS_ANDROID) | |
|
Peter Beverloo
2014/10/20 17:32:16
Either place the #if inside of the case-statement,
Miguel Garcia
2014/10/21 17:17:12
Done.
| |
| 1930 case content::PERMISSION_PROTECTED_MEDIA: | |
| 1931 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(profile) | |
| 1932 ->RequestProtectedMediaIdentifierPermission(web_contents, | |
| 1933 requesting_frame, | |
| 1934 result_callback); | |
| 1935 break; | |
| 1936 #endif | |
| 1937 default: | |
| 1938 LOG(WARNING) << "Permission not available " << permission; | |
|
Peter Beverloo
2014/10/20 17:32:16
nit: break for consistency.
Miguel Garcia
2014/10/21 17:17:12
Not sure where do you want to see the break
| |
| 1939 } | |
| 1940 | |
| 1938 } | 1941 } |
| 1939 | 1942 |
| 1940 void ChromeContentBrowserClient::CancelGeolocationPermissionRequest( | 1943 void ChromeContentBrowserClient::CancelPermissionRequest( |
| 1944 content::PermissionType permission, | |
| 1941 content::WebContents* web_contents, | 1945 content::WebContents* web_contents, |
| 1942 int bridge_id, | 1946 int bridge_id, |
| 1943 const GURL& requesting_frame) { | 1947 const GURL& requesting_frame) { |
| 1944 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 1948 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 1945 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 1949 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 1946 | 1950 |
| 1947 const PermissionRequestID request_id(render_process_id, | 1951 const PermissionRequestID request_id(render_process_id, |
| 1948 render_view_id, | 1952 render_view_id, |
| 1949 bridge_id, | 1953 bridge_id, |
| 1950 requesting_frame); | 1954 requesting_frame); |
| 1951 GeolocationPermissionContextFactory::GetForProfile( | 1955 Profile* profile = Profile::FromBrowserContext( |
| 1952 Profile::FromBrowserContext(web_contents->GetBrowserContext()))-> | 1956 web_contents->GetBrowserContext()); |
| 1953 CancelPermissionRequest(web_contents, request_id); | 1957 switch (permission) { |
| 1958 case content::PERMISSION_MIDI_SYSEX: | |
| 1959 MidiPermissionContextFactory::GetForProfile(profile) | |
|
Peter Beverloo
2014/10/20 17:32:16
Fix indentation.
Miguel Garcia
2014/10/21 17:17:12
Done.
| |
| 1960 ->CancelPermissionRequest(web_contents, request_id); | |
| 1961 break; | |
| 1962 case content::PERMISSION_NOTIFICATIONS: | |
| 1963 #if defined(ENABLE_NOTIFICATIONS) | |
| 1964 DesktopNotificationServiceFactory::GetForProfile(profile) | |
| 1965 ->CancelPermissionRequest(web_contents, request_id); | |
| 1966 #else | |
| 1967 NOTIMPLEMENTED(); | |
| 1968 #endif | |
| 1969 | |
| 1970 break; | |
| 1971 case content::PERMISSION_GEOLOCATION: | |
| 1972 GeolocationPermissionContextFactory::GetForProfile(profile) | |
| 1973 ->CancelPermissionRequest(web_contents, request_id); | |
| 1974 break; | |
| 1975 #if defined(OS_ANDROID) | |
| 1976 case content::PERMISSION_PROTECTED_MEDIA: | |
| 1977 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( | |
| 1978 profile)->CancelProtectedMediaIdentifierPermissionRequests( | |
| 1979 render_process_id, | |
| 1980 render_view_id, | |
| 1981 requesting_frame); | |
| 1982 break; | |
| 1983 #endif | |
| 1984 default: | |
| 1985 LOG(WARNING) << "Permission not available " << permission; | |
| 1986 } | |
| 1954 } | 1987 } |
| 1955 | 1988 |
| 1956 void ChromeContentBrowserClient::RequestMidiSysExPermission( | 1989 // Helper method to translate from Permissions to ContentSettings |
| 1957 content::WebContents* web_contents, | 1990 static ContentSettingsType PermissionToContentSetting( |
| 1958 int bridge_id, | 1991 content::PermissionType permission) { |
| 1959 const GURL& requesting_frame, | 1992 switch (permission) { |
| 1960 bool user_gesture, | 1993 case content::PERMISSION_MIDI_SYSEX: |
|
Peter Beverloo
2014/10/20 17:32:16
Fix indentation.
Miguel Garcia
2014/10/21 17:17:11
Done.
| |
| 1961 base::Callback<void(bool)> result_callback, | 1994 return CONTENT_SETTINGS_TYPE_MIDI_SYSEX; |
| 1962 base::Closure* cancel_callback) { | 1995 case content::PERMISSION_NOTIFICATIONS: |
| 1963 MidiPermissionContext* context = | 1996 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
| 1964 MidiPermissionContextFactory::GetForProfile( | 1997 case content::PERMISSION_GEOLOCATION: |
| 1965 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | 1998 return CONTENT_SETTINGS_TYPE_GEOLOCATION; |
| 1966 int renderer_id = web_contents->GetRenderProcessHost()->GetID(); | 1999 #if defined(OS_ANDROID) |
| 1967 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 2000 case content::PERMISSION_PROTECTED_MEDIA: |
| 1968 const PermissionRequestID id(renderer_id, render_view_id, bridge_id, GURL()); | 2001 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; |
| 2002 #endif | |
| 1969 | 2003 |
| 1970 context->RequestPermission(web_contents, id, requesting_frame, | 2004 default: |
| 1971 user_gesture, result_callback); | 2005 NOTREACHED() << "Unknown content setting for permission " << permission; |
| 2006 return CONTENT_SETTINGS_TYPE_DEFAULT; | |
| 2007 } | |
| 1972 } | 2008 } |
| 1973 | 2009 |
| 1974 void ChromeContentBrowserClient::DidUseGeolocationPermission( | 2010 void ChromeContentBrowserClient::RegisterPermissionUsage( |
| 2011 content::PermissionType permission, | |
| 1975 content::WebContents* web_contents, | 2012 content::WebContents* web_contents, |
| 1976 const GURL& frame_url, | 2013 const GURL& frame_url, |
| 1977 const GURL& main_frame_url) { | 2014 const GURL& main_frame_url) { |
| 1978 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 2015 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 1979 ->GetHostContentSettingsMap() | 2016 ->GetHostContentSettingsMap() |
| 1980 ->UpdateLastUsage( | 2017 ->UpdateLastUsage( |
| 1981 frame_url, main_frame_url, CONTENT_SETTINGS_TYPE_GEOLOCATION); | 2018 frame_url, main_frame_url, PermissionToContentSetting(permission)); |
| 1982 } | |
| 1983 | |
| 1984 void ChromeContentBrowserClient::RequestProtectedMediaIdentifierPermission( | |
| 1985 content::WebContents* web_contents, | |
| 1986 const GURL& origin, | |
| 1987 base::Callback<void(bool)> result_callback, | |
| 1988 base::Closure* cancel_callback) { | |
| 1989 #if defined(OS_ANDROID) | |
| 1990 ProtectedMediaIdentifierPermissionContext* context = | |
| 1991 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( | |
| 1992 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | |
| 1993 context->RequestProtectedMediaIdentifierPermission(web_contents, | |
| 1994 origin, | |
| 1995 result_callback, | |
| 1996 cancel_callback); | |
| 1997 #else | |
| 1998 NOTIMPLEMENTED(); | |
| 1999 result_callback.Run(false); | |
| 2000 #endif // defined(OS_ANDROID) | |
| 2001 } | 2019 } |
| 2002 | 2020 |
| 2003 bool ChromeContentBrowserClient::CanCreateWindow( | 2021 bool ChromeContentBrowserClient::CanCreateWindow( |
| 2004 const GURL& opener_url, | 2022 const GURL& opener_url, |
| 2005 const GURL& opener_top_level_frame_url, | 2023 const GURL& opener_top_level_frame_url, |
| 2006 const GURL& source_origin, | 2024 const GURL& source_origin, |
| 2007 WindowContainerType container_type, | 2025 WindowContainerType container_type, |
| 2008 const GURL& target_url, | 2026 const GURL& target_url, |
| 2009 const content::Referrer& referrer, | 2027 const content::Referrer& referrer, |
| 2010 WindowOpenDisposition disposition, | 2028 WindowOpenDisposition disposition, |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2610 switches::kDisableWebRtcEncryption, | 2628 switches::kDisableWebRtcEncryption, |
| 2611 }; | 2629 }; |
| 2612 to_command_line->CopySwitchesFrom(from_command_line, | 2630 to_command_line->CopySwitchesFrom(from_command_line, |
| 2613 kWebRtcDevSwitchNames, | 2631 kWebRtcDevSwitchNames, |
| 2614 arraysize(kWebRtcDevSwitchNames)); | 2632 arraysize(kWebRtcDevSwitchNames)); |
| 2615 } | 2633 } |
| 2616 } | 2634 } |
| 2617 #endif // defined(ENABLE_WEBRTC) | 2635 #endif // defined(ENABLE_WEBRTC) |
| 2618 | 2636 |
| 2619 } // namespace chrome | 2637 } // namespace chrome |
| OLD | NEW |