Chromium Code Reviews| Index: chrome/browser/guestview/webview/webview_guest.cc |
| diff --git a/chrome/browser/guestview/webview/webview_guest.cc b/chrome/browser/guestview/webview/webview_guest.cc |
| index c05fa7cd06369e284d7644bc8a733d3264672996..0df5f8287d073d8bc33021174e968f257f9db3b0 100644 |
| --- a/chrome/browser/guestview/webview/webview_guest.cc |
| +++ b/chrome/browser/guestview/webview/webview_guest.cc |
| @@ -32,6 +32,8 @@ |
| #include "content/public/browser/storage_partition.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "content/public/browser/web_contents_delegate.h" |
| +#include "content/public/common/media_stream_request.h" |
| #include "content/public/common/page_zoom.h" |
| #include "content/public/common/result_codes.h" |
| #include "content/public/common/stop_find_action.h" |
| @@ -77,8 +79,6 @@ static std::string PermissionTypeToString(BrowserPluginPermissionType type) { |
| switch (type) { |
| case BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD: |
| return webview::kPermissionTypeDownload; |
| - case BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA: |
| - return webview::kPermissionTypeMedia; |
| case BROWSER_PLUGIN_PERMISSION_TYPE_NEW_WINDOW: |
| return webview::kPermissionTypeNewWindow; |
| case BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK: |
| @@ -95,6 +95,8 @@ static std::string PermissionTypeToString(BrowserPluginPermissionType type) { |
| return webview::kPermissionTypeLoadPlugin; |
| case WEB_VIEW_PERMISSION_TYPE_GEOLOCATION: |
| return webview::kPermissionTypeGeolocation; |
| + case WEB_VIEW_PERMISSION_TYPE_MEDIA: |
|
lazyboy
2014/04/11 20:13:20
nit: sort the case-s, here and in other places + i
Fady Samuel
2014/04/11 21:52:31
Done.
|
| + return webview::kPermissionTypeMedia; |
| } |
| NOTREACHED(); |
| } |
| @@ -195,10 +197,6 @@ void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| content::RecordAction( |
| UserMetricsAction("BrowserPlugin.PermissionAllow.Download")); |
| break; |
| - case BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA: |
| - content::RecordAction( |
| - UserMetricsAction("BrowserPlugin.PermissionAllow.Media")); |
| - break; |
| case BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK: |
| content::RecordAction( |
| UserMetricsAction("BrowserPlugin.PermissionAllow.PointerLock")); |
| @@ -225,6 +223,10 @@ void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| content::RecordAction( |
| UserMetricsAction("WebView.PermissionAllow.Geolocation")); |
| break; |
| + case WEB_VIEW_PERMISSION_TYPE_MEDIA: |
| + content::RecordAction( |
| + UserMetricsAction("WebView.PermissionAllow.Media")); |
| + break; |
| default: |
| break; |
| } |
| @@ -236,10 +238,6 @@ void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| content::RecordAction( |
| UserMetricsAction("BrowserPlugin.PermissionDeny.Download")); |
| break; |
| - case BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA: |
| - content::RecordAction( |
| - UserMetricsAction("BrowserPlugin.PermissionDeny.Media")); |
| - break; |
| case BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK: |
| content::RecordAction( |
| UserMetricsAction("BrowserPlugin.PermissionDeny.PointerLock")); |
| @@ -266,6 +264,10 @@ void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| content::RecordAction( |
| UserMetricsAction("WebView.PermissionDeny.Geolocation")); |
| break; |
| + case WEB_VIEW_PERMISSION_TYPE_MEDIA: |
| + content::RecordAction( |
| + UserMetricsAction("WebView.PermissionDeny.Media")); |
| + break; |
| default: |
| break; |
| } |
| @@ -622,6 +624,25 @@ void WebViewGuest::CancelGeolocationPermissionRequest(int bridge_id) { |
| pending_permission_requests_.erase(request_itr); |
| } |
| +void WebViewGuest::OnWebViewMediaPermissionResponse( |
| + const content::MediaStreamRequest& request, |
| + const content::MediaResponseCallback& callback, |
| + bool allow, |
| + const std::string& user_input) { |
| + if (!allow || !attached()) { |
| + // Deny the request. |
| + callback.Run(content::MediaStreamDevices(), |
| + content::MEDIA_DEVICE_INVALID_STATE, |
| + scoped_ptr<content::MediaStreamUI>()); |
| + return; |
| + } |
| + if (!embedder_web_contents()->GetDelegate()) |
| + return; |
| + |
| + embedder_web_contents()->GetDelegate()-> |
| + RequestMediaAccessPermission(embedder_web_contents(), request, callback); |
| +} |
| + |
| WebViewGuest::SetPermissionResult WebViewGuest::SetPermission( |
| int request_id, |
| PermissionResponseAction action, |
| @@ -867,6 +888,23 @@ void WebViewGuest::SizeChanged(const gfx::Size& old_size, |
| DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); |
| } |
| +void WebViewGuest::RequestMediaAccessPermission( |
| + const content::MediaStreamRequest& request, |
| + const content::MediaResponseCallback& callback) { |
| + base::DictionaryValue request_info; |
| + request_info.Set( |
| + guestview::kUrl, |
| + base::Value::CreateStringValue(request.security_origin.spec())); |
| + RequestPermission(static_cast<BrowserPluginPermissionType>( |
| + WEB_VIEW_PERMISSION_TYPE_MEDIA), |
| + request_info, |
| + base::Bind(&WebViewGuest::OnWebViewMediaPermissionResponse, |
| + base::Unretained(this), |
|
lazyboy
2014/04/11 20:13:20
nit: indent
WebViewGuest going away before the cal
Fady Samuel
2014/04/11 21:52:31
Done.
lazyboy
2014/04/11 21:56:26
Do we not need to fix the base::Unretained() issue
|
| + request, |
| + callback), |
| + false /* allowed_by_default */); |
| +} |
| + |
| #if defined(OS_CHROMEOS) |
| void WebViewGuest::OnAccessibilityStatusChanged( |
| const chromeos::AccessibilityStatusEventDetails& details) { |