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

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: Updated comments 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 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 class PublicSessionTabCaptureAccessHandler : public CaptureAccessHandlerBase {
27 public:
28 PublicSessionTabCaptureAccessHandler();
29 ~PublicSessionTabCaptureAccessHandler() override;
30
31 // MediaAccessHandler implementation.
32 bool SupportsStreamType(const content::MediaStreamType type,
33 const extensions::Extension* extension) override;
34 bool CheckMediaAccessPermission(
35 content::WebContents* web_contents,
36 const GURL& security_origin,
37 content::MediaStreamType type,
38 const extensions::Extension* extension) override;
39 void HandleRequest(content::WebContents* web_contents,
40 const content::MediaStreamRequest& request,
41 const content::MediaResponseCallback& callback,
42 const extensions::Extension* extension) override;
43
44 private:
45 // Helper function used to chain the HandleRequest call into the original
46 // inside of TabCaptureAccessHandler.
47 void ChainHandleRequest(content::WebContents* web_contents,
48 const content::MediaStreamRequest& request,
49 const content::MediaResponseCallback& callback,
50 const extensions::Extension* extension);
51
52 // Function used to resolve user decision regarding allowing tab capture.
53 void ResolvePermissionPrompt(
54 content::WebContents* web_contents,
55 const content::MediaStreamRequest& request,
56 const content::MediaResponseCallback& callback,
57 const extensions::Extension* extension,
58 ExtensionInstallPrompt::Result prompt_result);
59
60 // Class used to cache user choice regarding allowing tab capture.
61 class UserChoice {
62 public:
63 // Helper function for checking if tab capture is allowed by user choice.
64 bool IsAllowed() const;
65 // Helper function which returns true if user choice wasn't prompted yet.
66 bool NeedsPrompting() const;
67 void Set(bool allowed);
68 void SetPrompted();
69
70 private:
71 bool tab_capture_prompted_ = false;
72 bool tab_capture_allowed_ = false;
73 };
74
75 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_;
76 std::map<extensions::ExtensionId, std::unique_ptr<ExtensionInstallPrompt>>
77 extension_install_prompt_map_;
78 TabCaptureAccessHandler tab_capture_access_handler_;
79
80 DISALLOW_COPY_AND_ASSIGN(PublicSessionTabCaptureAccessHandler);
81 };
82
83 #endif // CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698