blob: 0477b8f5c9fb3aa63c727e57022fcd4dcb416781 [file] [log] [blame]
xjzf6f63a82016-05-11 18:35:291// 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 Urdaneta73fa6632019-01-14 18:46:2612#include "third_party/blink/public/common/mediastream/media_stream_request.h"
xjzf6f63a82016-05-11 18:35:2913
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.
17class 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 Urdaneta73fa6632019-01-14 18:46:2626 blink::MediaStreamType stream_type,
xjzf6f63a82016-05-11 18:35:2927 content::MediaRequestState state) override;
28
Xiaohan Wang4e3fdc92019-01-16 04:58:0829 // 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.
xjzf6f63a82016-05-11 18:35:2934 bool IsInsecureCapturingInProgress(int render_process_id,
Emircan Uysaler0dd972a2018-08-14 05:15:3735 int render_frame_id) override;
xjzf6f63a82016-05-11 18:35:2936
Xiaohan Wang4e3fdc92019-01-16 04:58:0837 // 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;
xjzf6f63a82016-05-11 18:35:2942
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 Uysaler0dd972a2018-08-14 05:15:3752 void UpdateTrusted(const content::MediaStreamRequest& request,
53 bool is_trusted);
54
xjzf6f63a82016-05-11 18:35:2955 private:
56 struct Session;
57
58 void AddCaptureSession(int render_process_id,
59 int render_frame_id,
60 int page_request_id,
Emircan Uysaler0dd972a2018-08-14 05:15:3761 bool is_trusted);
xjzf6f63a82016-05-11 18:35:2962
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_