OLD | NEW |
(Empty) | |
| 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 "base/callback.h" |
| 11 #include "chrome/browser/media/media_access_handler.h" |
| 12 #include "content/public/browser/media_request_state.h" |
| 13 #include "content/public/common/media_stream_request.h" |
| 14 |
| 15 // Base class for DesktopCaptureAccessHandler and TabCaptureAccessHandler. This |
| 16 // class tracks active capturing sessions, and provides API to check if there is |
| 17 // ongoing insecure video capturing. |
| 18 class CaptureAccessHandlerBase : public MediaAccessHandler { |
| 19 public: |
| 20 CaptureAccessHandlerBase(); |
| 21 ~CaptureAccessHandlerBase() override; |
| 22 |
| 23 // MediaAccessHandler implementation. |
| 24 void UpdateMediaRequestState(int render_process_id, |
| 25 int render_frame_id, |
| 26 int page_request_id, |
| 27 content::MediaStreamType stream_type, |
| 28 content::MediaRequestState state) override; |
| 29 |
| 30 // TODO(xjz): To be removed after |
| 31 // MediaCaptureDevicesDispatcher::IsDesktopCaptureInProgress() is removed. |
| 32 bool IsCaptureInProgress(); |
| 33 |
| 34 // Return true if there is any ongoing insecured capturing. The capturing is |
| 35 // deemed secure if all connected video sinks are reported secure and the |
| 36 // connections to the sinks are being managed by a trusted extension. |
| 37 bool IsInsecureCapturingInProgress(int render_process_id, |
| 38 int render_frame_id); |
| 39 |
| 40 void UpdateCapturingLinkSecured(int render_process_id, |
| 41 int render_frame_id, |
| 42 int page_request_id, |
| 43 bool is_secure); |
| 44 |
| 45 protected: |
| 46 static bool IsExtensionWhitelistedForScreenCapture( |
| 47 const extensions::Extension* extension); |
| 48 |
| 49 static bool IsBuiltInExtension(const GURL& origin); |
| 50 |
| 51 void UpdateExtensionTrusted(const content::MediaStreamRequest& request, |
| 52 const extensions::Extension* extension); |
| 53 |
| 54 private: |
| 55 // Tracks MEDIA_DESKTOP/TAB_VIDEO_CAPTURE sessions. Sessions are removed when |
| 56 // MEDIA_REQUEST_STATE_CLOSING is encountered. |
| 57 struct Session { |
| 58 int render_process_id; |
| 59 int render_frame_id; |
| 60 int page_request_id; |
| 61 // Extensions control the routing of the captured MediaStream content. |
| 62 // Therefore, only built-in extensions (and certain whitelisted ones) can be |
| 63 // trusted to set-up secure links. |
| 64 bool is_extension_trusted; |
| 65 |
| 66 // This is true only if all connected video sinks are reported secure. |
| 67 bool is_capturing_link_secure; |
| 68 }; |
| 69 |
| 70 void AddCaptureSession(int render_process_id, |
| 71 int render_frame_id, |
| 72 int page_request_id, |
| 73 bool is_extension_trusted); |
| 74 |
| 75 void RemoveCaptureSession(int render_process_id, |
| 76 int render_frame_id, |
| 77 int page_request_id); |
| 78 |
| 79 std::list<Session>::iterator FindSession(int render_process_id, |
| 80 int render_frame_id, |
| 81 int page_request_id); |
| 82 |
| 83 std::list<Session> sessions_; |
| 84 }; |
| 85 |
| 86 #endif // CHROME_BROWSER_MEDIA_CAPTURE_ACCESS_HANDLER_BASE_H_ |
OLD | NEW |