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 02029c3300c9603966d9266fc3009a98e8356aa3..a7a59e64d0c8abea9f534fd11f2317cd5178be14 100644 |
| --- a/android_webview/browser/aw_content_browser_client.cc |
| +++ b/android_webview/browser/aw_content_browser_client.cc |
| @@ -27,6 +27,7 @@ |
| #include "content/public/browser/browser_message_filter.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/child_process_security_policy.h" |
| +#include "content/public/browser/permission_type.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -140,17 +141,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 +392,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 +401,65 @@ 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); |
| + switch (permission) { |
| + case content::PERMISSION_GEOLOCATION: |
| + if (!delegate) { |
| + DVLOG(0) << "Dropping GeolocationPermission request"; |
| + result_callback.Run(false); |
| + return; |
| + } |
| + delegate->RequestGeolocationPermission(origin, result_callback); |
| + break; |
| + case content::PERMISSION_PROTECTED_MEDIA: |
| + if (!delegate) { |
| + DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request"; |
| + result_callback.Run(false); |
| + return; |
| + } |
| + delegate->RequestProtectedMediaIdentifierPermission(origin, |
| + result_callback); |
| + break; |
| + case content::PERMISSION_MIDI_SYSEX: |
| + case content::PERMISSION_NOTIFICATIONS: |
| + case content::PERMISSION_PUSH_MESSAGING: |
|
Bernhard Bauer
2014/10/23 08:38:01
Nit: these three permissions are valid, but not im
Miguel Garcia
2014/10/23 12:48:11
Done.
|
| + case content::PERMISSION_UNKNOWN: |
| + case content::PERMISSION_NUM: |
| + LOG(WARNING) << "Permission Request not implemented for " << permission; |
| + break; |
| + } |
| } |
| -void AwContentBrowserClient::RequestMidiSysExPermission( |
| +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) |
| 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: |
|
Bernhard Bauer
2014/10/23 08:38:01
Can you also write out the other values here, and
Miguel Garcia
2014/10/23 12:48:11
Done.
|
| + 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( |