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

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

Issue 2552203007: Public Sessions - prompt the user for pageCapture requests (Closed)
Patch Set: Devlin's comments, added other files Created 3 years, 10 months 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER_H_ 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_ 6 #define CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/media/capture_access_handler_base.h" 10 #include "chrome/browser/media/capture_access_handler_base.h"
11 #include "chrome/browser/media/webrtc/tab_capture_access_handler.h" 11 #include "chrome/browser/media/webrtc/tab_capture_access_handler.h"
12 #include "content/public/common/media_stream_request.h" 12 #include "content/public/common/media_stream_request.h"
13 #include "extensions/common/extension_id.h" 13 #include "extensions/common/extension_id.h"
14 14
15 // MediaAccessHandler for TabCapture API in Public Sessions. This class is 15 // MediaAccessHandler for TabCapture API in Public Sessions. This class is
16 // implemented as a wrapper around TabCaptureAccessHandler. It allows for finer 16 // implemented as a wrapper around TabCaptureAccessHandler. It allows for finer
17 // access control to the TabCapture manifest permission feature inside of Public 17 // access control to the TabCapture manifest permission feature inside of Public
18 // Sessions. 18 // Sessions.
19 // 19 //
20 // In Public Sessions, extensions (and apps) are force-installed by admin policy 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 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 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 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 24 // user a dialog where they can choose whether to allow the extension access to
25 // the API. 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 { 26 class PublicSessionTabCaptureAccessHandler : public CaptureAccessHandlerBase {
30 public: 27 public:
31 PublicSessionTabCaptureAccessHandler(); 28 PublicSessionTabCaptureAccessHandler();
32 ~PublicSessionTabCaptureAccessHandler() override; 29 ~PublicSessionTabCaptureAccessHandler() override;
33 30
34 // MediaAccessHandler implementation. 31 // MediaAccessHandler implementation.
35 bool SupportsStreamType(const content::MediaStreamType type, 32 bool SupportsStreamType(const content::MediaStreamType type,
36 const extensions::Extension* extension) override; 33 const extensions::Extension* extension) override;
37 bool CheckMediaAccessPermission( 34 bool CheckMediaAccessPermission(
38 content::WebContents* web_contents, 35 content::WebContents* web_contents,
39 const GURL& security_origin, 36 const GURL& security_origin,
40 content::MediaStreamType type, 37 content::MediaStreamType type,
41 const extensions::Extension* extension) override; 38 const extensions::Extension* extension) override;
42 void HandleRequest(content::WebContents* web_contents, 39 void HandleRequest(content::WebContents* web_contents,
43 const content::MediaStreamRequest& request, 40 const content::MediaStreamRequest& request,
44 const content::MediaResponseCallback& callback, 41 const content::MediaResponseCallback& callback,
45 const extensions::Extension* extension) override; 42 const extensions::Extension* extension) override;
46 43
47 private: 44 private:
48 // Helper function used to chain the HandleRequest call into the original 45 // Helper function used to chain the HandleRequest call into the original
49 // inside of TabCaptureAccessHandler. 46 // inside of TabCaptureAccessHandler.
50 void ChainHandleRequest(content::WebContents* web_contents, 47 void ChainHandleRequest(content::WebContents* web_contents,
51 const content::MediaStreamRequest& request, 48 const content::MediaStreamRequest& request,
52 const content::MediaResponseCallback& callback, 49 const content::MediaResponseCallback& callback,
53 const extensions::Extension* extension); 50 const extensions::Extension* extension);
54 51
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_; 52 TabCaptureAccessHandler tab_capture_access_handler_;
81 53
82 DISALLOW_COPY_AND_ASSIGN(PublicSessionTabCaptureAccessHandler); 54 DISALLOW_COPY_AND_ASSIGN(PublicSessionTabCaptureAccessHandler);
83 }; 55 };
84 56
85 #endif // CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER _H_ 57 #endif // CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698