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

Side by Side Diff: chrome/browser/media/public_session_media_access_handler.h

Issue 2552203007: Public Sessions - prompt the user for pageCapture requests (Closed)
Patch Set: Nitfix 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_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"
14 15
15 // MediaAccessHandler for extension capturing requests in Public Sessions. This 16 // MediaAccessHandler for extension capturing requests in Public Sessions. This
16 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It 17 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It
17 // allows for finer access control to audioCapture/videoCapture manifest 18 // allows for finer access control to audioCapture/videoCapture manifest
18 // permission features inside of Public Sessions. 19 // permission features inside of Public Sessions.
19 // 20 //
20 // In Public Sessions, apps and extensions are force-installed by admin policy 21 // In Public Sessions, apps and extensions are force-installed by admin policy
21 // so the user does not get a chance to review the permissions for these apps. 22 // so the user does not get a chance to review the permissions for these apps.
22 // This is not acceptable from a security/privacy standpoint, so when an app 23 // This is not acceptable from a security/privacy standpoint, so when an app
23 // uses the capture APIs for the first time, we show the user a dialog where 24 // uses the capture APIs for the first time, we show the user a dialog where
(...skipping 14 matching lines...) Expand all
38 content::MediaStreamType type, 39 content::MediaStreamType type,
39 const extensions::Extension* extension) override; 40 const extensions::Extension* extension) override;
40 void HandleRequest(content::WebContents* web_contents, 41 void HandleRequest(content::WebContents* web_contents,
41 const content::MediaStreamRequest& request, 42 const content::MediaStreamRequest& request,
42 const content::MediaResponseCallback& callback, 43 const content::MediaResponseCallback& callback,
43 const extensions::Extension* extension) override; 44 const extensions::Extension* extension) override;
44 45
45 private: 46 private:
46 // Helper function used to chain the HandleRequest call into the original 47 // Helper function used to chain the HandleRequest call into the original
47 // inside of ExtensionMediaAccessHandler. 48 // inside of ExtensionMediaAccessHandler.
48 void ChainHandleRequest(content::WebContents* web_contents, 49 void ChainHandleRequest(
49 const content::MediaStreamRequest& request, 50 content::WebContents* web_contents,
50 const content::MediaResponseCallback& callback, 51 const content::MediaStreamRequest& request,
51 const extensions::Extension* extension); 52 const content::MediaResponseCallback& callback,
53 const extensions::Extension* extension,
54 const extensions::PermissionIDSet& allowed_permissions);
52 55
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_;
80 ExtensionMediaAccessHandler extension_media_access_handler_; 56 ExtensionMediaAccessHandler extension_media_access_handler_;
81 57
82 DISALLOW_COPY_AND_ASSIGN(PublicSessionMediaAccessHandler); 58 DISALLOW_COPY_AND_ASSIGN(PublicSessionMediaAccessHandler);
83 }; 59 };
84 60
85 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_ 61 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698