Chromium Code Reviews| Index: chrome/browser/media/public_session_media_access_handler.h |
| diff --git a/chrome/browser/media/public_session_media_access_handler.h b/chrome/browser/media/public_session_media_access_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..677cbf63366c179209b57f6f6e4facb3f087fa00 |
| --- /dev/null |
| +++ b/chrome/browser/media/public_session_media_access_handler.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ |
| +#define CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ |
| + |
| +#include "chrome/browser/extensions/extension_install_prompt.h" |
| +#include "chrome/browser/media/extension_media_access_handler.h" |
| +#include "content/public/common/media_stream_request.h" |
| +#include "extensions/common/extension_id.h" |
| + |
| +// MediaAccessHandler for extension capturing requests in Public Sessions. This |
| +// class is implemented as a wrapper around ExtensionMediaAccessHandler. It |
| +// allows for finer access control to audioCapture/videoCapture manifest |
| +// permission features inside of Public Sessions. |
| +// |
| +// In Public Sessions extensions are installed by admin policy hence they can |
| +// freely use the camera and microphone without the user knowing. This is not |
| +// acceptable from a security/privacy standpoint so we show the user a dialog |
| +// where they can choose whether to allow the extension access to camera and/or |
| +// microphone. Note: camera and microphone are used through audioCapture and |
| +// videoCapture manifest permissions which are limited to platform apps only. |
| +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.
|
| + public: |
| + 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.
|
| + ~PublicSessionMediaAccessHandler() override; |
| + |
| + // MediaAccessHandler implementation. |
| + bool SupportsStreamType(const content::MediaStreamType type, |
| + const extensions::Extension* extension) override; |
| + bool CheckMediaAccessPermission( |
| + content::WebContents* web_contents, |
| + const GURL& security_origin, |
| + content::MediaStreamType type, |
| + const extensions::Extension* extension) override; |
| + void HandleRequest(content::WebContents* web_contents, |
| + const content::MediaStreamRequest& request, |
| + const content::MediaResponseCallback& callback, |
| + const extensions::Extension* extension) override; |
| + |
| + private: |
| + // Helper function used to chain the HandleRequest call into the original |
| + // inside of ExtensionMediaAccessHandler. |
| + void ChainHandleRequest(content::WebContents* web_contents, |
| + const content::MediaStreamRequest& request, |
| + const content::MediaResponseCallback& callback, |
| + const extensions::Extension* extension); |
| + |
| + // Function used to resolve user decision regarding allowing audio/video. |
| + void ResolvePermissionPrompt( |
| + content::WebContents* web_contents, |
| + const content::MediaStreamRequest& request, |
| + const content::MediaResponseCallback& callback, |
| + const extensions::Extension* extension, |
| + const std::unique_ptr<ExtensionInstallPrompt>& prompt, |
| + ExtensionInstallPrompt::Result prompt_result); |
| + |
| + // Class used to cache user choice regarding allowing audio/video capture. |
| + class UserChoice { |
| + public: |
| + // Helper function for checking if audio/video is allowed by user choice. |
| + bool IsAllowed(content::MediaStreamType type) const; |
| + // Helper function which returns true if audio/video wasn't prompted yet. |
| + bool NeedsPrompting(content::MediaStreamType type) const; |
| + void Set(content::MediaStreamType type, bool allowed); |
| + |
| + private: |
| + bool audio_prompted_ = false; |
| + bool audio_allowed_ = false; |
| + bool video_prompted_ = false; |
| + bool video_allowed_ = false; |
| + }; |
| + |
| + 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
|
| +}; |
| + |
| +#endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ |