| OLD | NEW |
| 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_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ | 6 #define CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_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/extension_media_access_handler.h" | 10 #include "chrome/browser/media/extension_media_access_handler.h" |
| 11 #include "chrome/browser/media/media_access_handler.h" | 11 #include "chrome/browser/media/media_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 #include "extensions/common/permissions/api_permission_set.h" | |
| 15 | 14 |
| 16 // MediaAccessHandler for extension capturing requests in Public Sessions. This | 15 // MediaAccessHandler for extension capturing requests in Public Sessions. This |
| 17 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It | 16 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It |
| 18 // allows for finer access control to audioCapture/videoCapture manifest | 17 // allows for finer access control to audioCapture/videoCapture manifest |
| 19 // permission features inside of Public Sessions. | 18 // permission features inside of Public Sessions. |
| 20 // | 19 // |
| 21 // In Public Sessions, apps and extensions are force-installed by admin policy | 20 // In Public Sessions, apps and extensions are force-installed by admin policy |
| 22 // so the user does not get a chance to review the permissions for these apps. | 21 // so the user does not get a chance to review the permissions for these apps. |
| 23 // This is not acceptable from a security/privacy standpoint, so when an app | 22 // This is not acceptable from a security/privacy standpoint, so when an app |
| 24 // uses the capture APIs for the first time, we show the user a dialog where | 23 // uses the capture APIs for the first time, we show the user a dialog where |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 content::MediaStreamType type, | 38 content::MediaStreamType type, |
| 40 const extensions::Extension* extension) override; | 39 const extensions::Extension* extension) override; |
| 41 void HandleRequest(content::WebContents* web_contents, | 40 void HandleRequest(content::WebContents* web_contents, |
| 42 const content::MediaStreamRequest& request, | 41 const content::MediaStreamRequest& request, |
| 43 const content::MediaResponseCallback& callback, | 42 const content::MediaResponseCallback& callback, |
| 44 const extensions::Extension* extension) override; | 43 const extensions::Extension* extension) override; |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 // Helper function used to chain the HandleRequest call into the original | 46 // Helper function used to chain the HandleRequest call into the original |
| 48 // inside of ExtensionMediaAccessHandler. | 47 // inside of ExtensionMediaAccessHandler. |
| 49 void ChainHandleRequest( | 48 void ChainHandleRequest(content::WebContents* web_contents, |
| 50 content::WebContents* web_contents, | 49 const content::MediaStreamRequest& request, |
| 51 const content::MediaStreamRequest& request, | 50 const content::MediaResponseCallback& callback, |
| 52 const content::MediaResponseCallback& callback, | 51 const extensions::Extension* extension); |
| 53 const extensions::Extension* extension, | |
| 54 const extensions::PermissionIDSet& allowed_permissions); | |
| 55 | 52 |
| 53 // Function used to resolve user decision regarding allowing audio/video. |
| 54 void ResolvePermissionPrompt(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 audio/video capture. |
| 61 class UserChoice { |
| 62 public: |
| 63 // Helper function for checking if audio/video is allowed by user choice. |
| 64 bool IsAllowed(content::MediaStreamType type) const; |
| 65 // Helper function which returns true if audio/video wasn't prompted yet. |
| 66 bool NeedsPrompting(content::MediaStreamType type) const; |
| 67 void Set(content::MediaStreamType type, bool allowed); |
| 68 void SetPrompted(content::MediaStreamType type); |
| 69 |
| 70 private: |
| 71 bool audio_prompted_ = false; |
| 72 bool audio_allowed_ = false; |
| 73 bool video_prompted_ = false; |
| 74 bool video_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_; |
| 56 ExtensionMediaAccessHandler extension_media_access_handler_; | 80 ExtensionMediaAccessHandler extension_media_access_handler_; |
| 57 | 81 |
| 58 DISALLOW_COPY_AND_ASSIGN(PublicSessionMediaAccessHandler); | 82 DISALLOW_COPY_AND_ASSIGN(PublicSessionMediaAccessHandler); |
| 59 }; | 83 }; |
| 60 | 84 |
| 61 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ | 85 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ |
| OLD | NEW |