blob: 0658c0f8216c439d835e6969204671b9aa8a99eb [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"
12#include "content/public/common/media_stream_request.h"
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.
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,
26 content::MediaStreamType stream_type,
27 content::MediaRequestState state) override;
28
29 // Return true if there is any ongoing insecured capturing. The capturing is
30 // deemed secure if all connected video sinks are reported secure and the
31 // connections to the sinks are being managed by a trusted extension.
32 bool IsInsecureCapturingInProgress(int render_process_id,
Emircan Uysaler0dd972a2018-08-14 05:15:3733 int render_frame_id) override;
xjzf6f63a82016-05-11 18:35:2934
35 void UpdateCapturingLinkSecured(int render_process_id,
36 int render_frame_id,
37 int page_request_id,
Emircan Uysaler0dd972a2018-08-14 05:15:3738 bool is_secure) override;
xjzf6f63a82016-05-11 18:35:2939
40 protected:
41 static bool IsExtensionWhitelistedForScreenCapture(
42 const extensions::Extension* extension);
43
44 static bool IsBuiltInExtension(const GURL& origin);
45
46 void UpdateExtensionTrusted(const content::MediaStreamRequest& request,
47 const extensions::Extension* extension);
48
Emircan Uysaler0dd972a2018-08-14 05:15:3749 void UpdateTrusted(const content::MediaStreamRequest& request,
50 bool is_trusted);
51
xjzf6f63a82016-05-11 18:35:2952 private:
53 struct Session;
54
55 void AddCaptureSession(int render_process_id,
56 int render_frame_id,
57 int page_request_id,
Emircan Uysaler0dd972a2018-08-14 05:15:3758 bool is_trusted);
xjzf6f63a82016-05-11 18:35:2959
60 void RemoveCaptureSession(int render_process_id,
61 int render_frame_id,
62 int page_request_id);
63
64 std::list<Session>::iterator FindSession(int render_process_id,
65 int render_frame_id,
66 int page_request_id);
67
68 std::list<Session> sessions_;
69
70 DISALLOW_COPY_AND_ASSIGN(CaptureAccessHandlerBase);
71};
72
73#endif // CHROME_BROWSER_MEDIA_CAPTURE_ACCESS_HANDLER_BASE_H_