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 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1935 requesting_frame.GetOrigin(), | 1935 requesting_frame.GetOrigin(), |
1936 user_gesture, | 1936 user_gesture, |
1937 result_callback); | 1937 result_callback); |
1938 break; | 1938 break; |
1939 case content::PERMISSION_NUM: | 1939 case content::PERMISSION_NUM: |
1940 NOTREACHED() << "Invalid RequestPermission for " << permission; | 1940 NOTREACHED() << "Invalid RequestPermission for " << permission; |
1941 break; | 1941 break; |
1942 } | 1942 } |
1943 } | 1943 } |
1944 | 1944 |
1945 PermissionContextBase* | |
1946 ChromeContentBrowserClient::GetPermissionContextFromProfile(Profile* profile, | |
mlamouri (slow - plz ping)
2014/12/19 13:08:03
I don't think you need this to be part of the clas
timvolodine
2015/01/22 19:37:01
Done.
| |
1947 content::PermissionType permission) { | |
1948 switch (permission) { | |
1949 case content::PERMISSION_MIDI_SYSEX: | |
1950 return MidiPermissionContextFactory::GetForProfile(profile); | |
1951 case content::PERMISSION_NOTIFICATIONS: | |
1952 #if defined(ENABLE_NOTIFICATIONS) | |
1953 return DesktopNotificationServiceFactory::GetForProfile(profile); | |
1954 #else | |
1955 NOTIMPLEMENTED(); | |
1956 #endif | |
1957 case content::PERMISSION_GEOLOCATION: | |
1958 return GeolocationPermissionContextFactory::GetForProfile(profile); | |
1959 case content::PERMISSION_PROTECTED_MEDIA: | |
1960 NOTIMPLEMENTED(); | |
1961 break; | |
1962 case content::PERMISSION_PUSH_MESSAGING: | |
1963 return gcm::PushMessagingPermissionContextFactory::GetForProfile(profile); | |
1964 case content::PERMISSION_NUM: | |
1965 NOTREACHED() << "Invalid RequestPermission for " << permission; | |
1966 break; | |
1967 } | |
1968 return nullptr; | |
1969 } | |
1970 | |
1945 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( | 1971 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( |
1946 content::PermissionType permission, | 1972 content::PermissionType permission, |
1947 content::BrowserContext* browser_context, | 1973 content::BrowserContext* browser_context, |
1948 const GURL& requesting_origin, | 1974 const GURL& requesting_origin, |
1949 const GURL& embedding_origin) { | 1975 const GURL& embedding_origin) { |
1950 DCHECK(browser_context); | 1976 DCHECK(browser_context); |
1951 Profile* profile = Profile::FromBrowserContext(browser_context); | 1977 Profile* profile = Profile::FromBrowserContext(browser_context); |
1952 | 1978 PermissionContextBase* context = GetPermissionContextFromProfile(profile, |
1953 PermissionContextBase* context = nullptr; | 1979 permission); |
1954 switch (permission) { | |
1955 case content::PERMISSION_MIDI_SYSEX: | |
1956 context = MidiPermissionContextFactory::GetForProfile(profile); | |
1957 break; | |
1958 case content::PERMISSION_NOTIFICATIONS: | |
1959 #if defined(ENABLE_NOTIFICATIONS) | |
1960 context = DesktopNotificationServiceFactory::GetForProfile(profile); | |
1961 #else | |
1962 NOTIMPLEMENTED(); | |
1963 #endif | |
1964 break; | |
1965 case content::PERMISSION_GEOLOCATION: | |
1966 context = GeolocationPermissionContextFactory::GetForProfile(profile); | |
1967 break; | |
1968 case content::PERMISSION_PROTECTED_MEDIA: | |
1969 NOTIMPLEMENTED(); | |
1970 break; | |
1971 case content::PERMISSION_PUSH_MESSAGING: | |
1972 context = gcm::PushMessagingPermissionContextFactory::GetForProfile( | |
1973 profile); | |
1974 break; | |
1975 case content::PERMISSION_NUM: | |
1976 NOTREACHED() << "Invalid RequestPermission for " << permission; | |
1977 break; | |
1978 } | |
1979 | 1980 |
1980 ContentSetting result = context | 1981 ContentSetting result = context |
1981 ? context->GetPermissionStatus(requesting_origin.GetOrigin(), | 1982 ? context->GetPermissionStatus(requesting_origin.GetOrigin(), |
1982 embedding_origin.GetOrigin()) | 1983 embedding_origin.GetOrigin()) |
1983 : CONTENT_SETTING_DEFAULT; | 1984 : CONTENT_SETTING_DEFAULT; |
1984 | 1985 |
1985 return ContentSettingToPermissionStatus(result); | 1986 return ContentSettingToPermissionStatus(result); |
1986 } | 1987 } |
1987 | 1988 |
1989 content::PermissionStatus ChromeContentBrowserClient::RevokePermission( | |
1990 content::PermissionType permission, | |
1991 content::BrowserContext* browser_context, | |
1992 const GURL& requesting_origin, | |
1993 const GURL& embedding_origin) { | |
1994 DCHECK(browser_context); | |
1995 Profile* profile = Profile::FromBrowserContext(browser_context); | |
1996 PermissionContextBase* context = GetPermissionContextFromProfile(profile, | |
1997 permission); | |
1998 | |
1999 ContentSetting result = context | |
2000 ? context->RevokePermission(requesting_origin.GetOrigin(), | |
2001 embedding_origin.GetOrigin()) | |
2002 : CONTENT_SETTING_DEFAULT; | |
mlamouri (slow - plz ping)
2014/12/19 13:08:03
Maybe you could do:
if (!context)
return PERMIS
timvolodine
2015/01/22 19:37:01
Done.
| |
2003 | |
2004 return ContentSettingToPermissionStatus(result); | |
2005 } | |
2006 | |
1988 void ChromeContentBrowserClient::CancelPermissionRequest( | 2007 void ChromeContentBrowserClient::CancelPermissionRequest( |
1989 content::PermissionType permission, | 2008 content::PermissionType permission, |
1990 content::WebContents* web_contents, | 2009 content::WebContents* web_contents, |
1991 int bridge_id, | 2010 int bridge_id, |
1992 const GURL& requesting_frame) { | 2011 const GURL& requesting_frame) { |
1993 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 2012 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
1994 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 2013 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
1995 | 2014 |
1996 const PermissionRequestID request_id(render_process_id, | 2015 const PermissionRequestID request_id(render_process_id, |
1997 render_view_id, | 2016 render_view_id, |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2618 switches::kDisableWebRtcEncryption, | 2637 switches::kDisableWebRtcEncryption, |
2619 }; | 2638 }; |
2620 to_command_line->CopySwitchesFrom(from_command_line, | 2639 to_command_line->CopySwitchesFrom(from_command_line, |
2621 kWebRtcDevSwitchNames, | 2640 kWebRtcDevSwitchNames, |
2622 arraysize(kWebRtcDevSwitchNames)); | 2641 arraysize(kWebRtcDevSwitchNames)); |
2623 } | 2642 } |
2624 } | 2643 } |
2625 #endif // defined(ENABLE_WEBRTC) | 2644 #endif // defined(ENABLE_WEBRTC) |
2626 | 2645 |
2627 } // namespace chrome | 2646 } // namespace chrome |
OLD | NEW |