Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: chrome/browser/media/webrtc/public_session_tab_capture_access_handler.h

Issue 2558843002: Public Sessions - prompt the user for tabCapture requests (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER_H_
7
8 #include "base/macros.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/media/capture_access_handler_base.h"
11 #include "chrome/browser/media/webrtc/tab_capture_access_handler.h"
12 #include "content/public/common/media_stream_request.h"
13 #include "extensions/common/extension_id.h"
14
15 // MediaAccessHandler for TabCapture API in Public Sessions. This class is
16 // implemented as a wrapper around TabCaptureAccessHandler. It allows for finer
17 // access control to the TabCapture manifest permission feature inside of Public
18 // Sessions.
19 //
20 // In Public Sessions, extensions (and apps) are force-installed by admin policy
21 // so the user does not get a chance to review the permissions for these
22 // extensions. This is not acceptable from a security/privacy standpoint, so
23 // when an extension uses the TabCapture API for the first time, we show the
24 // user a dialog where they can choose whether to allow the extension access to
25 // the API.
26 //
27 // TODO(isandrk): Refactor common code out of this class and
28 // PublicSessionMediaAccessHandler (crbug.com/672620).
29 class PublicSessionTabCaptureAccessHandler : public CaptureAccessHandlerBase {
30 public:
31 PublicSessionTabCaptureAccessHandler();
32 ~PublicSessionTabCaptureAccessHandler() override;
33
34 // MediaAccessHandler implementation.
35 bool SupportsStreamType(const content::MediaStreamType type,
36 const extensions::Extension* extension) override;
37 bool CheckMediaAccessPermission(
38 content::WebContents* web_contents,
39 const GURL& security_origin,
40 content::MediaStreamType type,
41 const extensions::Extension* extension) override;
42 void HandleRequest(content::WebContents* web_contents,
43 const content::MediaStreamRequest& request,
44 const content::MediaResponseCallback& callback,
45 const extensions::Extension* extension) override;
46
47 private:
48 // Helper function used to chain the HandleRequest call into the original
49 // inside of TabCaptureAccessHandler.
50 void ChainHandleRequest(content::WebContents* web_contents,
51 const content::MediaStreamRequest& request,
52 const content::MediaResponseCallback& callback,
53 const extensions::Extension* extension);
54
55 // Function used to resolve user decision regarding allowing tab capture.
56 void ResolvePermissionPrompt(content::WebContents* web_contents,
57 const content::MediaStreamRequest& request,
58 const content::MediaResponseCallback& callback,
59 const extensions::Extension* extension,
60 ExtensionInstallPrompt::Result prompt_result);
61
62 // Class used to cache user choice regarding allowing tab capture.
63 class UserChoice {
64 public:
65 // Helper function for checking if tab capture is allowed by user choice.
66 bool IsAllowed() const;
67 // Helper function which returns true if user choice wasn't prompted yet.
68 bool NeedsPrompting() const;
69 void Set(bool allowed);
70 void SetPrompted();
71
72 private:
73 bool tab_capture_prompted_ = false;
74 bool tab_capture_allowed_ = false;
75 };
76
77 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_;
78 std::map<extensions::ExtensionId, std::unique_ptr<ExtensionInstallPrompt>>
79 extension_install_prompt_map_;
80 TabCaptureAccessHandler tab_capture_access_handler_;
81
82 DISALLOW_COPY_AND_ASSIGN(PublicSessionTabCaptureAccessHandler);
83 };
84
85 #endif // CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698