| 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 #ifndef CHROME_BROWSER_MEDIA_MEDIA_ACCESS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_ACCESS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_MEDIA_ACCESS_HANDLER_H_ | 6 #define CHROME_BROWSER_MEDIA_MEDIA_ACCESS_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/public/browser/media_request_state.h" | 9 #include "content/public/browser/media_request_state.h" |
| 10 #include "content/public/common/media_stream_request.h" | 10 #include "content/public/common/media_stream_request.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 class WebContents; | 13 class WebContents; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 class Extension; | 17 class Extension; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // Interface for handling media access requests that are propagated from | 20 // Interface for handling media access requests that are propagated from |
| 21 // MediaCaptureDevicesDispatcher. | 21 // MediaCaptureDevicesDispatcher. |
| 22 class MediaAccessHandler { | 22 class MediaAccessHandler { |
| 23 public: | 23 public: |
| 24 MediaAccessHandler() {} | 24 MediaAccessHandler() {} |
| 25 virtual ~MediaAccessHandler() {} | 25 virtual ~MediaAccessHandler() {} |
| 26 | 26 |
| 27 // Check if the media stream type is supported by MediaAccessHandler. | 27 // Check if the media stream type is supported by MediaAccessHandler. |
| 28 virtual bool SupportsStreamType(const content::MediaStreamType type, | 28 virtual bool SupportsStreamType(content::WebContents* web_contents, |
| 29 const content::MediaStreamType type, |
| 29 const extensions::Extension* extension) = 0; | 30 const extensions::Extension* extension) = 0; |
| 30 // Check media access permission. |extension| is set to NULL if request was | 31 // Check media access permission. |extension| is set to NULL if request was |
| 31 // made from a drive-by page. | 32 // made from a drive-by page. |
| 32 virtual bool CheckMediaAccessPermission( | 33 virtual bool CheckMediaAccessPermission( |
| 33 content::WebContents* web_contents, | 34 content::WebContents* web_contents, |
| 34 const GURL& security_origin, | 35 const GURL& security_origin, |
| 35 content::MediaStreamType type, | 36 content::MediaStreamType type, |
| 36 const extensions::Extension* extension) = 0; | 37 const extensions::Extension* extension) = 0; |
| 37 // Process media access requests. |extension| is set to NULL if request was | 38 // Process media access requests. |extension| is set to NULL if request was |
| 38 // made from a drive-by page. | 39 // made from a drive-by page. |
| 39 virtual void HandleRequest(content::WebContents* web_contents, | 40 virtual void HandleRequest(content::WebContents* web_contents, |
| 40 const content::MediaStreamRequest& request, | 41 const content::MediaStreamRequest& request, |
| 41 const content::MediaResponseCallback& callback, | 42 const content::MediaResponseCallback& callback, |
| 42 const extensions::Extension* extension) = 0; | 43 const extensions::Extension* extension) = 0; |
| 43 // Update media request state. Called on UI thread. | 44 // Update media request state. Called on UI thread. |
| 44 virtual void UpdateMediaRequestState(int render_process_id, | 45 virtual void UpdateMediaRequestState(int render_process_id, |
| 45 int render_frame_id, | 46 int render_frame_id, |
| 46 int page_request_id, | 47 int page_request_id, |
| 47 content::MediaStreamType stream_type, | 48 content::MediaStreamType stream_type, |
| 48 content::MediaRequestState state) {} | 49 content::MediaRequestState state) {} |
| 50 |
| 51 protected: |
| 52 // Helper function for derived classes which takes in whether audio/video |
| 53 // permissions are allowed and queries for the requested devices, running the |
| 54 // callback with the appropriate device list and status. |
| 55 static void CheckDevicesAndRunCallback( |
| 56 content::WebContents* web_contents, |
| 57 const content::MediaStreamRequest& request, |
| 58 const content::MediaResponseCallback& callback, |
| 59 bool audio_allowed, |
| 60 bool video_allowed); |
| 49 }; | 61 }; |
| 50 | 62 |
| 51 #endif // CHROME_BROWSER_MEDIA_MEDIA_ACCESS_HANDLER_H_ | 63 #endif // CHROME_BROWSER_MEDIA_MEDIA_ACCESS_HANDLER_H_ |
| OLD | NEW |