| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/media_capture_util.h" | 5 #include "extensions/shell/browser/media_capture_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/public/browser/media_capture_devices.h" | 11 #include "content/public/browser/media_capture_devices.h" |
| 12 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
| 13 | 13 |
| 14 using content::MediaCaptureDevices; | 14 using content::MediaCaptureDevices; |
| 15 using content::MediaStreamDevice; | 15 using content::MediaStreamDevice; |
| 16 using content::MediaStreamDevices; | 16 using content::MediaStreamDevices; |
| 17 using content::MediaStreamUI; | 17 using content::MediaStreamUI; |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 const MediaStreamDevice* GetRequestedDeviceOrDefault( | 21 const MediaStreamDevice* GetRequestedDeviceOrDefault( |
| 22 const MediaStreamDevices& devices, | 22 const MediaStreamDevices& devices, |
| 23 const std::string& requested_device_id) { | 23 const std::string& requested_device_id) { |
| 24 if (!requested_device_id.empty()) | 24 if (!requested_device_id.empty()) |
| 25 return devices.FindById(requested_device_id); | 25 return devices.FindById(requested_device_id); |
| 26 | 26 |
| 27 if (!devices.empty()) | 27 if (!devices.empty()) |
| 28 return &devices[0]; | 28 return &devices[0]; |
| 29 | 29 |
| 30 return NULL; | 30 return nullptr; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace media_capture_util { | 33 namespace media_capture_util { |
| 34 | 34 |
| 35 // See also Chrome's MediaCaptureDevicesDispatcher. | 35 // See also Chrome's MediaCaptureDevicesDispatcher. |
| 36 void GrantMediaStreamRequest(content::WebContents* web_contents, | 36 void GrantMediaStreamRequest(content::WebContents* web_contents, |
| 37 const content::MediaStreamRequest& request, | 37 const content::MediaStreamRequest& request, |
| 38 const content::MediaResponseCallback& callback, | 38 const content::MediaResponseCallback& callback, |
| 39 const Extension* extension) { | 39 const Extension* extension) { |
| 40 // app_shell only supports audio and video capture, not tab or screen capture. | 40 // app_shell only supports audio and video capture, not tab or screen capture. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 << "Audio capture request but no audioCapture permission in manifest."; | 79 << "Audio capture request but no audioCapture permission in manifest."; |
| 80 } else { | 80 } else { |
| 81 DCHECK(type == content::MEDIA_DEVICE_VIDEO_CAPTURE); | 81 DCHECK(type == content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 82 CHECK(permissions_data->HasAPIPermission(APIPermission::kVideoCapture)) | 82 CHECK(permissions_data->HasAPIPermission(APIPermission::kVideoCapture)) |
| 83 << "Video capture request but no videoCapture permission in manifest."; | 83 << "Video capture request but no videoCapture permission in manifest."; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace media_capture_util | 87 } // namespace media_capture_util |
| 88 } // namespace extensions | 88 } // namespace extensions |
| OLD | NEW |