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_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ | |
| 7 | |
| 8 #include "chrome/browser/extensions/extension_install_prompt.h" | |
| 9 #include "chrome/browser/media/extension_media_access_handler.h" | |
| 10 #include "content/public/common/media_stream_request.h" | |
| 11 #include "extensions/common/extension_id.h" | |
| 12 | |
| 13 // MediaAccessHandler for extension capturing requests in Public Sessions. This | |
| 14 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It | |
| 15 // allows for finer access control to audioCapture/videoCapture manifest | |
| 16 // permission features inside of Public Sessions. | |
| 17 // | |
| 18 // In Public Sessions extensions are installed by admin policy hence they can | |
| 19 // freely use the camera and microphone without the user knowing. This is not | |
| 20 // acceptable from a security/privacy standpoint so we show the user a dialog | |
| 21 // where they can choose whether to allow the extension access to camera and/or | |
| 22 // microphone. Note: camera and microphone are used through audioCapture and | |
| 23 // videoCapture manifest permissions which are limited to platform apps only. | |
| 24 class PublicSessionMediaAccessHandler : public ExtensionMediaAccessHandler { | |
|
Sergey Ulanov
2016/12/02 20:29:47
When I suggested to make PublicSessionMediaAccessH
Ivan Šandrk
2016/12/05 13:10:51
Done. I hope that's what you had in mind.
| |
| 25 public: | |
| 26 explicit PublicSessionMediaAccessHandler(); | |
|
Devlin
2016/12/02 20:40:28
no need for explicit except in single-parameter ct
Ivan Šandrk
2016/12/05 13:10:51
Done.
| |
| 27 ~PublicSessionMediaAccessHandler() override; | |
| 28 | |
| 29 // MediaAccessHandler implementation. | |
| 30 bool SupportsStreamType(const content::MediaStreamType type, | |
| 31 const extensions::Extension* extension) override; | |
| 32 bool CheckMediaAccessPermission( | |
| 33 content::WebContents* web_contents, | |
| 34 const GURL& security_origin, | |
| 35 content::MediaStreamType type, | |
| 36 const extensions::Extension* extension) override; | |
| 37 void HandleRequest(content::WebContents* web_contents, | |
| 38 const content::MediaStreamRequest& request, | |
| 39 const content::MediaResponseCallback& callback, | |
| 40 const extensions::Extension* extension) override; | |
| 41 | |
| 42 private: | |
| 43 // Helper function used to chain the HandleRequest call into the original | |
| 44 // inside of ExtensionMediaAccessHandler. | |
| 45 void ChainHandleRequest(content::WebContents* web_contents, | |
| 46 const content::MediaStreamRequest& request, | |
| 47 const content::MediaResponseCallback& callback, | |
| 48 const extensions::Extension* extension); | |
| 49 | |
| 50 // Function used to resolve user decision regarding allowing audio/video. | |
| 51 void ResolvePermissionPrompt( | |
| 52 content::WebContents* web_contents, | |
| 53 const content::MediaStreamRequest& request, | |
| 54 const content::MediaResponseCallback& callback, | |
| 55 const extensions::Extension* extension, | |
| 56 const std::unique_ptr<ExtensionInstallPrompt>& prompt, | |
| 57 ExtensionInstallPrompt::Result prompt_result); | |
| 58 | |
| 59 // Class used to cache user choice regarding allowing audio/video capture. | |
| 60 class UserChoice { | |
| 61 public: | |
| 62 // Helper function for checking if audio/video is allowed by user choice. | |
| 63 bool IsAllowed(content::MediaStreamType type) const; | |
| 64 // Helper function which returns true if audio/video wasn't prompted yet. | |
| 65 bool NeedsPrompting(content::MediaStreamType type) const; | |
| 66 void Set(content::MediaStreamType type, bool allowed); | |
| 67 | |
| 68 private: | |
| 69 bool audio_prompted_ = false; | |
| 70 bool audio_allowed_ = false; | |
| 71 bool video_prompted_ = false; | |
| 72 bool video_allowed_ = false; | |
| 73 }; | |
| 74 | |
| 75 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_; | |
|
Sergey Ulanov
2016/12/02 20:29:47
I'm not very familiar with public sessions. Is it
Devlin
2016/12/02 20:40:28
DISALLOW_COPY_AND_ASSIGN()
Andrew T Wilson (Slow)
2016/12/04 19:57:01
The profile is destroyed across sessions (the brow
Ivan Šandrk
2016/12/05 13:10:51
Done.
Ivan Šandrk
2016/12/05 13:10:51
Yes it's possible, and yes it needs resetting. I w
| |
| 76 }; | |
| 77 | |
| 78 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ | |
| OLD | NEW |