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

Side by Side Diff: content/browser/media/media_devices_permission_checker.h

Issue 2436113002: Introduce MediaDevicesPermissionChecker. (Closed)
Patch Set: Created 4 years, 2 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
(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 CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_
xhwang 2016/10/28 17:14:56 OOC, can we put this file in content/browser/rende
Guido Urdaneta 2016/10/29 19:34:38 That would be my preference, but the .cc includes
xhwang 2016/10/30 16:18:27 I see. I am not familiar with this part. A content
6 #define CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "content/browser/renderer_host/media/media_devices_manager.h"
12 #include "content/common/content_export.h"
13
14 namespace url {
15 class Origin;
16 }
17
18 namespace content {
19
20 // This class provides has various utility functions to check if a render frame
xhwang 2016/10/28 17:14:56 "provides has"?
Guido Urdaneta 2016/10/29 19:34:38 Done.
21 // has permission to access media devices. Note that none of the methods
22 // prompts the user to request permission.
23 class CONTENT_EXPORT MediaDevicesPermissionChecker {
24 public:
25 MediaDevicesPermissionChecker();
26
27 // Checks if the origin |security_origin| associated to a render frame
28 // identified by |render_process_id| and |routing_id| is allowed to access
29 // the media device type |device_type|.
30 // This method must be called on the UI thread.
31 bool CheckPermission(MediaDeviceType device_type,
xhwang 2016/10/28 17:14:56 Does this make sense to name this CheckPermissionO
Guido Urdaneta 2016/10/29 19:34:37 Done.
32 int render_process_id,
33 int routing_id,
xhwang 2016/10/28 17:14:56 It seems less ambiguouse to use render_frame_id wh
Guido Urdaneta 2016/10/29 19:34:37 Done.
34 const url::Origin& security_origin);
35
36 // Checks if the origin |security_origin| associated to a render frame
37 // identified by |render_process_id| and |routing_id| is allowed to access
38 // the media device type |device_type|. The result is passed to |callback|.
39 // This method can be called on any thread.
xhwang 2016/10/28 17:14:56 nit: might worth commenting that the |callback| wi
Guido Urdaneta 2016/10/29 19:34:38 Done.
40 void CheckPermission(MediaDeviceType device_type,
41 int render_process_id,
42 int routing_id,
43 const url::Origin& security_origin,
44 const base::Callback<void(bool)>& callback);
45
46 // Checks if the origin |security_origin| associated to a render frame
47 // identified by |render_process_id| and |routing_id| is allowed to access the
48 // media device types marked with a value of true in |requested_device_types|.
49 // The result is indexed by MediaDeviceType. Entries in the result with a
50 // value of true for requested device types indicate that the frame has
51 // permission to access devices of the corresponding types.
52 // This method must be called on the UI thread.
53 MediaDevicesManager::BoolDeviceTypes CheckPermissions(
54 MediaDevicesManager::BoolDeviceTypes requested_device_types,
55 int render_process_id,
56 int routing_id,
57 const url::Origin& security_origin);
58
59 // Checks if the origin |security_origin| associated to a render frame
60 // identified by |render_process_id| and |routing_id| is allowed to access the
61 // media device types marked with a value of true in |requested_device_types|.
62 // The result is passed to |callback|. The result is indexed by
63 // MediaDeviceType. Entries in the result with a value of true for requested
64 // device types indicate that the frame has permission to access devices of
65 // the corresponding types.
66 // This method can be called on any thread.
67 void CheckPermissions(
68 MediaDevicesManager::BoolDeviceTypes requested_device_types,
69 int render_process_id,
70 int routing_id,
71 const url::Origin& security_origin,
72 const base::Callback<void(const MediaDevicesManager::BoolDeviceTypes&)>&
73 callback);
74
75 // Forces a specific value to be returned by the permission-checking functions
76 // for all device types.
77 void OverridePermissions(bool override_value);
xhwang 2016/10/28 17:14:56 Could you please document the use case for this? I
Guido Urdaneta 2016/10/29 19:34:37 Done. Renamed the method to OverridePermissionForT
78
79 private:
80 bool use_override_;
81 bool override_value_;
82 };
83
84 } // namespace content
85
86 #endif // CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698