xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_MEDIA_CAPTURE_ACCESS_HANDLER_BASE_H_ |
| 6 | #define CHROME_BROWSER_MEDIA_CAPTURE_ACCESS_HANDLER_BASE_H_ |
| 7 | |
| 8 | #include <list> |
| 9 | |
| 10 | #include "chrome/browser/media/media_access_handler.h" |
| 11 | #include "content/public/browser/media_request_state.h" |
Guido Urdaneta | 73fa663 | 2019-01-14 18:46:26 | [diff] [blame] | 12 | #include "third_party/blink/public/common/mediastream/media_stream_request.h" |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 13 | |
| 14 | // Base class for DesktopCaptureAccessHandler and TabCaptureAccessHandler. This |
| 15 | // class tracks active capturing sessions, and provides API to check if there is |
| 16 | // ongoing insecure video capturing. |
| 17 | class CaptureAccessHandlerBase : public MediaAccessHandler { |
| 18 | public: |
| 19 | CaptureAccessHandlerBase(); |
| 20 | ~CaptureAccessHandlerBase() override; |
| 21 | |
| 22 | // MediaAccessHandler implementation. |
| 23 | void UpdateMediaRequestState(int render_process_id, |
| 24 | int render_frame_id, |
| 25 | int page_request_id, |
Guido Urdaneta | 73fa663 | 2019-01-14 18:46:26 | [diff] [blame] | 26 | blink::MediaStreamType stream_type, |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 27 | content::MediaRequestState state) override; |
| 28 | |
Xiaohan Wang | 4e3fdc9 | 2019-01-16 04:58:08 | [diff] [blame^] | 29 | // Returns true if there is any ongoing insecured capturing. Returns false |
| 30 | // otherwise, e.g. there is no capturing, or all capturing are secure. A |
| 31 | // capturing is deemed secure if all connected video sinks are reported secure |
| 32 | // and the connections to the sinks are also secure, e.g. being managed by a |
| 33 | // trusted extension. |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 34 | bool IsInsecureCapturingInProgress(int render_process_id, |
Emircan Uysaler | 0dd972a | 2018-08-14 05:15:37 | [diff] [blame] | 35 | int render_frame_id) override; |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 36 | |
Xiaohan Wang | 4e3fdc9 | 2019-01-16 04:58:08 | [diff] [blame^] | 37 | // Updates video screen capture status with whether it |is_secure| or not. |
| 38 | void UpdateVideoScreenCaptureStatus(int render_process_id, |
| 39 | int render_frame_id, |
| 40 | int page_request_id, |
| 41 | bool is_secure) override; |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 42 | |
| 43 | protected: |
| 44 | static bool IsExtensionWhitelistedForScreenCapture( |
| 45 | const extensions::Extension* extension); |
| 46 | |
| 47 | static bool IsBuiltInExtension(const GURL& origin); |
| 48 | |
| 49 | void UpdateExtensionTrusted(const content::MediaStreamRequest& request, |
| 50 | const extensions::Extension* extension); |
| 51 | |
Emircan Uysaler | 0dd972a | 2018-08-14 05:15:37 | [diff] [blame] | 52 | void UpdateTrusted(const content::MediaStreamRequest& request, |
| 53 | bool is_trusted); |
| 54 | |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 55 | private: |
| 56 | struct Session; |
| 57 | |
| 58 | void AddCaptureSession(int render_process_id, |
| 59 | int render_frame_id, |
| 60 | int page_request_id, |
Emircan Uysaler | 0dd972a | 2018-08-14 05:15:37 | [diff] [blame] | 61 | bool is_trusted); |
xjz | f6f63a8 | 2016-05-11 18:35:29 | [diff] [blame] | 62 | |
| 63 | void RemoveCaptureSession(int render_process_id, |
| 64 | int render_frame_id, |
| 65 | int page_request_id); |
| 66 | |
| 67 | std::list<Session>::iterator FindSession(int render_process_id, |
| 68 | int render_frame_id, |
| 69 | int page_request_id); |
| 70 | |
| 71 | std::list<Session> sessions_; |
| 72 | |
| 73 | DISALLOW_COPY_AND_ASSIGN(CaptureAccessHandlerBase); |
| 74 | }; |
| 75 | |
| 76 | #endif // CHROME_BROWSER_MEDIA_CAPTURE_ACCESS_HANDLER_BASE_H_ |