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

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

Issue 2532323003: Public Sessions - prompt the user for audioCapture/videoCapture requests (Closed)
Patch Set: Update comment, erase map entry Created 4 years 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
(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 "base/macros.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/media/extension_media_access_handler.h"
11 #include "chrome/browser/media/media_access_handler.h"
12 #include "content/public/common/media_stream_request.h"
13 #include "extensions/common/extension_id.h"
14
15 // MediaAccessHandler for extension capturing requests in Public Sessions. This
16 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It
17 // allows for finer access control to audioCapture/videoCapture manifest
18 // permission features inside of Public Sessions.
19 //
20 // 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 // 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 // they can choose whether to allow the extension access to camera and/or
25 // microphone. Note: camera and microphone are used through audioCapture and
26 // videoCapture manifest permissions which are limited to platform apps only.
27 class PublicSessionMediaAccessHandler : public MediaAccessHandler {
28 public:
29 PublicSessionMediaAccessHandler();
30 ~PublicSessionMediaAccessHandler() override;
31
32 // MediaAccessHandler implementation.
33 bool SupportsStreamType(const content::MediaStreamType type,
34 const extensions::Extension* extension) override;
35 bool CheckMediaAccessPermission(
36 content::WebContents* web_contents,
37 const GURL& security_origin,
38 content::MediaStreamType type,
39 const extensions::Extension* extension) override;
40 void HandleRequest(content::WebContents* web_contents,
41 const content::MediaStreamRequest& request,
42 const content::MediaResponseCallback& callback,
43 const extensions::Extension* extension) override;
44
45 private:
46 // Helper function used to chain the HandleRequest call into the original
47 // inside of ExtensionMediaAccessHandler.
48 void ChainHandleRequest(content::WebContents* web_contents,
49 const content::MediaStreamRequest& request,
50 const content::MediaResponseCallback& callback,
51 const extensions::Extension* extension);
52
53 // Function used to resolve user decision regarding allowing audio/video.
54 void ResolvePermissionPrompt(
55 content::WebContents* web_contents,
56 const content::MediaStreamRequest& request,
57 const content::MediaResponseCallback& callback,
58 const extensions::Extension* extension,
59 ExtensionInstallPrompt::Result prompt_result);
60
61 // Class used to cache user choice regarding allowing audio/video capture.
62 class UserChoice {
63 public:
64 // Helper function for checking if audio/video is allowed by user choice.
65 bool IsAllowed(content::MediaStreamType type) const;
66 // Helper function which returns true if audio/video wasn't prompted yet.
67 bool NeedsPrompting(content::MediaStreamType type) const;
68 void Set(content::MediaStreamType type, bool allowed);
69 void SetPrompted(content::MediaStreamType type);
70
71 private:
72 bool audio_prompted_ = false;
73 bool audio_allowed_ = false;
74 bool video_prompted_ = false;
75 bool video_allowed_ = false;
76 };
77
78 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_;
79 std::map<extensions::ExtensionId, std::unique_ptr<ExtensionInstallPrompt>>
80 extension_install_prompt_map_;
81 ExtensionMediaAccessHandler extension_media_access_handler_;
82
83 DISALLOW_COPY_AND_ASSIGN(PublicSessionMediaAccessHandler);
84 };
85
86 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698