Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
Andrew T Wilson (Slow)
2016/12/14 16:07:46
nit: to the TabCapture manifest permission
Ivan Šandrk
2016/12/14 17:44:02
Done.
| |
| 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 { | |
|
Andrew T Wilson (Slow)
2016/12/14 16:07:45
You have a bug for refactoring this code to share
Ivan Šandrk
2016/12/14 17:44:02
Done.
| |
| 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(content::WebContents* web_contents, | |
| 54 const content::MediaStreamRequest& request, | |
| 55 const content::MediaResponseCallback& callback, | |
| 56 const extensions::Extension* extension, | |
| 57 ExtensionInstallPrompt::Result prompt_result); | |
| 58 | |
| 59 // Class used to cache user choice regarding allowing tab capture. | |
| 60 class UserChoice { | |
| 61 public: | |
| 62 // Helper function for checking if tab capture is allowed by user choice. | |
| 63 bool IsAllowed() const; | |
| 64 // Helper function which returns true if user choice wasn't prompted yet. | |
| 65 bool NeedsPrompting() const; | |
| 66 void Set(bool allowed); | |
| 67 void SetPrompted(); | |
| 68 | |
| 69 private: | |
| 70 bool tab_capture_prompted_ = false; | |
| 71 bool tab_capture_allowed_ = false; | |
| 72 }; | |
| 73 | |
| 74 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_; | |
| 75 std::map<extensions::ExtensionId, std::unique_ptr<ExtensionInstallPrompt>> | |
| 76 extension_install_prompt_map_; | |
| 77 TabCaptureAccessHandler tab_capture_access_handler_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(PublicSessionTabCaptureAccessHandler); | |
| 80 }; | |
| 81 | |
| 82 #endif // CHROME_BROWSER_MEDIA_WEBRTC_PUBLIC_SESSION_TAB_CAPTURE_ACCESS_HANDLER _H_ | |
| OLD | NEW |