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 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 requesting_frame.GetOrigin(), | 1964 requesting_frame.GetOrigin(), |
1965 user_gesture, | 1965 user_gesture, |
1966 result_callback); | 1966 result_callback); |
1967 break; | 1967 break; |
1968 case content::PERMISSION_NUM: | 1968 case content::PERMISSION_NUM: |
1969 NOTREACHED() << "Invalid RequestPermission for " << permission; | 1969 NOTREACHED() << "Invalid RequestPermission for " << permission; |
1970 break; | 1970 break; |
1971 } | 1971 } |
1972 } | 1972 } |
1973 | 1973 |
| 1974 void ChromeContentBrowserClient::HasPermission( |
| 1975 content::PermissionType permission, |
| 1976 content::WebContents* web_contents, |
| 1977 const GURL& requesting_frame, |
| 1978 const base::Callback<void(bool)>& result_callback) { |
| 1979 Profile* profile = |
| 1980 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 1981 |
| 1982 PermissionContextBase* context = nullptr; |
| 1983 switch (permission) { |
| 1984 case content::PERMISSION_MIDI_SYSEX: |
| 1985 context = MidiPermissionContextFactory::GetForProfile(profile); |
| 1986 break; |
| 1987 case content::PERMISSION_NOTIFICATIONS: |
| 1988 #if defined(ENABLE_NOTIFICATIONS) |
| 1989 context = DesktopNotificationServiceFactory::GetForProfile(profile); |
| 1990 #else |
| 1991 NOTIMPLEMENTED(); |
| 1992 #endif |
| 1993 break; |
| 1994 case content::PERMISSION_GEOLOCATION: |
| 1995 context = GeolocationPermissionContextFactory::GetForProfile(profile); |
| 1996 break; |
| 1997 case content::PERMISSION_PROTECTED_MEDIA: |
| 1998 #if defined(OS_ANDROID) |
| 1999 context = ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( |
| 2000 profile); |
| 2001 #else |
| 2002 NOTIMPLEMENTED(); |
| 2003 #endif |
| 2004 break; |
| 2005 case content::PERMISSION_PUSH_MESSAGING: |
| 2006 context = gcm::PushMessagingPermissionContextFactory::GetForProfile( |
| 2007 profile); |
| 2008 break; |
| 2009 case content::PERMISSION_NUM: |
| 2010 NOTREACHED() << "Invalid RequestPermission for " << permission; |
| 2011 break; |
| 2012 } |
| 2013 |
| 2014 if (!context) |
| 2015 result_callback.Run(false); |
| 2016 |
| 2017 ContentSetting result = context->GetPermissionStatus( |
| 2018 requesting_frame.GetOrigin(), |
| 2019 web_contents->GetLastCommittedURL().GetOrigin()); |
| 2020 result_callback.Run(result == CONTENT_SETTING_ALLOW); |
| 2021 } |
| 2022 |
1974 void ChromeContentBrowserClient::CancelPermissionRequest( | 2023 void ChromeContentBrowserClient::CancelPermissionRequest( |
1975 content::PermissionType permission, | 2024 content::PermissionType permission, |
1976 content::WebContents* web_contents, | 2025 content::WebContents* web_contents, |
1977 int bridge_id, | 2026 int bridge_id, |
1978 const GURL& requesting_frame) { | 2027 const GURL& requesting_frame) { |
1979 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 2028 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
1980 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 2029 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
1981 | 2030 |
1982 const PermissionRequestID request_id(render_process_id, | 2031 const PermissionRequestID request_id(render_process_id, |
1983 render_view_id, | 2032 render_view_id, |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 switches::kDisableWebRtcEncryption, | 2722 switches::kDisableWebRtcEncryption, |
2674 }; | 2723 }; |
2675 to_command_line->CopySwitchesFrom(from_command_line, | 2724 to_command_line->CopySwitchesFrom(from_command_line, |
2676 kWebRtcDevSwitchNames, | 2725 kWebRtcDevSwitchNames, |
2677 arraysize(kWebRtcDevSwitchNames)); | 2726 arraysize(kWebRtcDevSwitchNames)); |
2678 } | 2727 } |
2679 } | 2728 } |
2680 #endif // defined(ENABLE_WEBRTC) | 2729 #endif // defined(ENABLE_WEBRTC) |
2681 | 2730 |
2682 } // namespace chrome | 2731 } // namespace chrome |
OLD | NEW |