Chromium Code Reviews| Index: android_webview/browser/aw_content_browser_client.cc |
| diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc |
| index 6c0d6f503eb95fc15aec6cb2135670944d0b3972..7d2955ffd7418d972988b962ae9091924c653851 100644 |
| --- a/android_webview/browser/aw_content_browser_client.cc |
| +++ b/android_webview/browser/aw_content_browser_client.cc |
| @@ -140,17 +140,6 @@ class AwAccessTokenStore : public content::AccessTokenStore { |
| DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
| }; |
| -void CancelProtectedMediaIdentifierPermissionRequests( |
| - int render_process_id, |
| - int render_view_id, |
| - const GURL& origin) { |
| - AwBrowserPermissionRequestDelegate* delegate = |
| - AwBrowserPermissionRequestDelegate::FromID(render_process_id, |
| - render_view_id); |
| - if (delegate) |
| - delegate->CancelProtectedMediaIdentifierPermissionRequests(origin); |
| -} |
| - |
| } // namespace |
| std::string AwContentBrowserClient::GetAcceptLangsImpl() { |
| @@ -402,7 +391,8 @@ void AwContentBrowserClient::ShowDesktopNotification( |
| NOTREACHED() << "Android WebView does not support desktop notifications."; |
| } |
| -void AwContentBrowserClient::RequestGeolocationPermission( |
| +void AwContentBrowserClient::RequestPermission( |
| + content::PermissionType permission, |
| content::WebContents* web_contents, |
| int bridge_id, |
| const GURL& requesting_frame, |
| @@ -410,66 +400,66 @@ void AwContentBrowserClient::RequestGeolocationPermission( |
| const base::Callback<void(bool)>& result_callback) { |
| int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| - AwBrowserPermissionRequestDelegate* delegate = |
| - AwBrowserPermissionRequestDelegate::FromID(render_process_id, |
| - render_view_id); |
| - if (delegate == NULL) { |
| - DVLOG(0) << "Dropping GeolocationPermission request"; |
| - result_callback.Run(false); |
| - return; |
| - } |
| - |
| GURL origin = requesting_frame.GetOrigin(); |
| - delegate->RequestGeolocationPermission(origin, result_callback); |
| -} |
| - |
| -void AwContentBrowserClient::CancelGeolocationPermissionRequest( |
| - content::WebContents* web_contents, |
| - int bridge_id, |
| - const GURL& requesting_frame) { |
| - int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| - int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| AwBrowserPermissionRequestDelegate* delegate = |
| AwBrowserPermissionRequestDelegate::FromID(render_process_id, |
| render_view_id); |
| - if (delegate) |
| - delegate->CancelGeolocationPermissionRequests(requesting_frame); |
| -} |
| - |
| -void AwContentBrowserClient::RequestMidiSysExPermission( |
| + switch (permission) { |
| + case content::PERMISSION_MIDI_SYSEX: |
| + break; |
|
Bernhard Bauer
2014/10/20 14:57:23
Do you want to fall through here?
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
|
| + case content::PERMISSION_NOTIFICATIONS: |
| + LOG(WARNING) << "Permission Request not implemented for " |
| + << permission; |
|
Bernhard Bauer
2014/10/20 14:57:24
Nit: Align << signs.
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
|
| + break; |
|
Peter Beverloo
2014/10/20 17:32:16
Can we just handle these cases in the |default| cl
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
|
| + case content::PERMISSION_GEOLOCATION: |
| + if (delegate == NULL) { |
|
Bernhard Bauer
2014/10/20 14:57:24
Nit: Just !delegate
Miguel Garcia
2014/10/21 17:17:11
Done.
|
| + DVLOG(0) << "Dropping GeolocationPermission request"; |
| + result_callback.Run(false); |
| + return; |
| + } |
| + delegate->RequestGeolocationPermission(origin, result_callback); |
| + break; |
| + case content::PERMISSION_PROTECTED_MEDIA: |
| + if (delegate == NULL) { |
| + DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request"; |
| + result_callback.Run(false); |
| + return; |
| + } |
| + delegate->RequestProtectedMediaIdentifierPermission( |
| + origin, result_callback); |
| + break; |
| + default: |
| + LOG(WARNING) << "Permission not available " << permission; |
|
Bernhard Bauer
2014/10/20 14:57:23
Is there a difference between "Permission not avai
Peter Beverloo
2014/10/20 17:32:16
nit: break; after this line for consistency.
Peter Beverloo
2014/10/20 17:32:16
+1 to merging them.
Miguel Garcia
2014/10/21 17:17:11
I merged them and explicitly listed all values as
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
|
| + } |
| +} |
| + |
| +void AwContentBrowserClient::CancelPermissionRequest( |
| + content::PermissionType permission, |
| content::WebContents* web_contents, |
| int bridge_id, |
| - const GURL& requesting_frame, |
| - bool user_gesture, |
| - base::Callback<void(bool)> result_callback, |
| - base::Closure* cancel_callback) { |
| - // TODO(toyoshim): Android WebView is not supported yet. |
| - // See http://crbug.com/339767. |
| - result_callback.Run(false); |
| -} |
| - |
| -void AwContentBrowserClient::RequestProtectedMediaIdentifierPermission( |
| - content::WebContents* web_contents, |
| - const GURL& origin, |
| - base::Callback<void(bool)> result_callback, |
| - base::Closure* cancel_callback) { |
| + const GURL& origin) { |
| int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| AwBrowserPermissionRequestDelegate* delegate = |
| AwBrowserPermissionRequestDelegate::FromID(render_process_id, |
| render_view_id); |
| - if (delegate == NULL) { |
| - DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request"; |
| - result_callback.Run(false); |
| + if (!delegate) |
|
Peter Beverloo
2014/10/20 17:32:16
This check should be done in AwContentBrowserClien
Miguel Garcia
2014/10/21 17:17:11
Actually in RequestPermission there are already ch
|
| return; |
| + switch (permission) { |
| + case content::PERMISSION_MIDI_SYSEX: |
| + case content::PERMISSION_NOTIFICATIONS: |
| + LOG(WARNING) << "Cancel Permission request not implemented for " |
| + << permission; |
| + break; |
| + case content::PERMISSION_GEOLOCATION: |
| + delegate->CancelGeolocationPermissionRequests(origin); |
| + break; |
| + case content::PERMISSION_PROTECTED_MEDIA: |
| + delegate->CancelProtectedMediaIdentifierPermissionRequests(origin); |
| + break; |
| + default: |
| + LOG(WARNING) << "Permission not available " << permission; |
| } |
| - |
| - if (cancel_callback) { |
| - *cancel_callback = base::Bind( |
| - CancelProtectedMediaIdentifierPermissionRequests, |
| - render_process_id, render_view_id, origin); |
| - } |
| - delegate->RequestProtectedMediaIdentifierPermission(origin, result_callback); |
| } |
| bool AwContentBrowserClient::CanCreateWindow( |