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

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: Added a new class for handling media access in Public Sessions 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 "chrome/browser/extensions/extension_install_prompt.h"
9 #include "chrome/browser/media/extension_media_access_handler.h"
10 #include "chrome/browser/media/media_access_handler.h"
11 #include "content/public/common/media_stream_request.h"
12 #include "extensions/common/extension_id.h"
13
14 // MediaAccessHandler for extension capturing requests in Public Sessions. This
15 // class is implemented as a wrapper around ExtensionMediaAccessHandler. It
16 // allows for finer access control to audioCapture/videoCapture manifest
17 // permission features inside of Public Sessions.
18 //
19 // In Public Sessions extensions are installed by admin policy hence they can
20 // freely use the camera and microphone without the user knowing. This is not
21 // acceptable from a security/privacy standpoint so we show the user a dialog
22 // where he can choose whether to allow the extension access to camera and/or
Devlin 2016/11/30 19:02:48 drive-by nit: prefer "they" (I wonder why this was
Ivan Šandrk 2016/12/01 17:32:04 Done.
23 // microphone. Note: camera and microphone are used through audioCapture and
24 // videoCapture manifest permissions which are limited to platform apps only.
25 class PublicSessionMediaAccessHandler : public MediaAccessHandler {
Devlin 2016/11/30 19:02:48 What's the lifetime of this object?
Ivan Šandrk 2016/12/01 17:32:05 Let's merge this discussion with the one regarding
26 public:
27 explicit PublicSessionMediaAccessHandler(
28 ExtensionMediaAccessHandler& extension_media_access_handler);
Devlin 2016/11/30 19:02:48 we disallow non-const references passed into funct
Ivan Šandrk 2016/12/01 17:32:05 Acknowledged.
29 ~PublicSessionMediaAccessHandler() override;
30
31 // MediaAccessHandler implementation.
32 bool SupportsStreamType(const content::MediaStreamType type,
33 const extensions::Extension* extension) override;
34 bool CheckMediaAccessPermission(
35 content::WebContents* web_contents,
36 const GURL& security_origin,
37 content::MediaStreamType type,
38 const extensions::Extension* extension) override;
39 void HandleRequest(content::WebContents* web_contents,
40 const content::MediaStreamRequest& request,
41 const content::MediaResponseCallback& callback,
42 const extensions::Extension* extension) override;
43
44 private:
45 // Helper function used to chain the HandleRequest call into the original
46 // inside of ExtensionMediaAccessHandler.
47 void ChainHandleRequest(content::WebContents* web_contents,
48 const content::MediaStreamRequest& request,
49 const content::MediaResponseCallback& callback,
50 const extensions::Extension* extension);
51
52 // Function used to resolve user decision regarding allowing audio/video.
53 void ResolvePermissionPrompt(
54 content::WebContents* web_contents,
55 const content::MediaStreamRequest& request,
56 const content::MediaResponseCallback& callback,
57 const extensions::Extension* extension,
58 std::unique_ptr<ExtensionInstallPrompt> prompt,
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
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 ExtensionMediaAccessHandler& extension_media_access_handler_;
78 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_;
79 };
80
81 #endif // CHROME_BROWSER_MEDIA_PUBLIC_SESSION_MEDIA_ACCESS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698