| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/media/webrtc/tab_capture_access_handler.h" | 5 #include "chrome/browser/media/webrtc/tab_capture_access_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 9 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| 10 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 10 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 void TabCaptureAccessHandler::HandleRequest( | 37 void TabCaptureAccessHandler::HandleRequest( |
| 38 content::WebContents* web_contents, | 38 content::WebContents* web_contents, |
| 39 const content::MediaStreamRequest& request, | 39 const content::MediaStreamRequest& request, |
| 40 const content::MediaResponseCallback& callback, | 40 const content::MediaResponseCallback& callback, |
| 41 const extensions::Extension* extension) { | 41 const extensions::Extension* extension) { |
| 42 content::MediaStreamDevices devices; | 42 content::MediaStreamDevices devices; |
| 43 std::unique_ptr<content::MediaStreamUI> ui; | 43 std::unique_ptr<content::MediaStreamUI> ui; |
| 44 | 44 |
| 45 if (!extension) | 45 if (!extension) { |
| 46 callback.Run(devices, content::MEDIA_DEVICE_TAB_CAPTURE_FAILURE, | 46 callback.Run(devices, content::MEDIA_DEVICE_TAB_CAPTURE_FAILURE, |
| 47 std::move(ui)); | 47 std::move(ui)); |
| 48 return; |
| 49 } |
| 48 | 50 |
| 49 Profile* profile = | 51 Profile* profile = |
| 50 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 52 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 51 extensions::TabCaptureRegistry* tab_capture_registry = | 53 extensions::TabCaptureRegistry* tab_capture_registry = |
| 52 extensions::TabCaptureRegistry::Get(profile); | 54 extensions::TabCaptureRegistry::Get(profile); |
| 53 if (!tab_capture_registry) { | 55 if (!tab_capture_registry) { |
| 54 NOTREACHED(); | 56 NOTREACHED(); |
| 55 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui)); | 57 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui)); |
| 56 return; | 58 return; |
| 57 } | 59 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 if (!devices.empty()) { | 79 if (!devices.empty()) { |
| 78 ui = MediaCaptureDevicesDispatcher::GetInstance() | 80 ui = MediaCaptureDevicesDispatcher::GetInstance() |
| 79 ->GetMediaStreamCaptureIndicator() | 81 ->GetMediaStreamCaptureIndicator() |
| 80 ->RegisterMediaStream(web_contents, devices); | 82 ->RegisterMediaStream(web_contents, devices); |
| 81 } | 83 } |
| 82 UpdateExtensionTrusted(request, extension); | 84 UpdateExtensionTrusted(request, extension); |
| 83 callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE | 85 callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE |
| 84 : content::MEDIA_DEVICE_OK, | 86 : content::MEDIA_DEVICE_OK, |
| 85 std::move(ui)); | 87 std::move(ui)); |
| 86 } | 88 } |
| OLD | NEW |