Chromium Code Reviews| Index: content/browser/media/media_devices_permission_checker.h |
| diff --git a/content/browser/media/media_devices_permission_checker.h b/content/browser/media/media_devices_permission_checker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7ac95c89c799448b1cc0b0aed15a30c6e7c54742 |
| --- /dev/null |
| +++ b/content/browser/media/media_devices_permission_checker.h |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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
|
| +#define CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/callback.h" |
| +#include "content/browser/renderer_host/media/media_devices_manager.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace url { |
| +class Origin; |
| +} |
| + |
| +namespace content { |
| + |
| +// 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.
|
| +// has permission to access media devices. Note that none of the methods |
| +// prompts the user to request permission. |
| +class CONTENT_EXPORT MediaDevicesPermissionChecker { |
| + public: |
| + MediaDevicesPermissionChecker(); |
| + |
| + // Checks if the origin |security_origin| associated to a render frame |
| + // identified by |render_process_id| and |routing_id| is allowed to access |
| + // the media device type |device_type|. |
| + // This method must be called on the UI thread. |
| + 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.
|
| + int render_process_id, |
| + 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.
|
| + const url::Origin& security_origin); |
| + |
| + // Checks if the origin |security_origin| associated to a render frame |
| + // identified by |render_process_id| and |routing_id| is allowed to access |
| + // the media device type |device_type|. The result is passed to |callback|. |
| + // 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.
|
| + void CheckPermission(MediaDeviceType device_type, |
| + int render_process_id, |
| + int routing_id, |
| + const url::Origin& security_origin, |
| + const base::Callback<void(bool)>& callback); |
| + |
| + // Checks if the origin |security_origin| associated to a render frame |
| + // identified by |render_process_id| and |routing_id| is allowed to access the |
| + // media device types marked with a value of true in |requested_device_types|. |
| + // The result is indexed by MediaDeviceType. Entries in the result with a |
| + // value of true for requested device types indicate that the frame has |
| + // permission to access devices of the corresponding types. |
| + // This method must be called on the UI thread. |
| + MediaDevicesManager::BoolDeviceTypes CheckPermissions( |
| + MediaDevicesManager::BoolDeviceTypes requested_device_types, |
| + int render_process_id, |
| + int routing_id, |
| + const url::Origin& security_origin); |
| + |
| + // Checks if the origin |security_origin| associated to a render frame |
| + // identified by |render_process_id| and |routing_id| is allowed to access the |
| + // media device types marked with a value of true in |requested_device_types|. |
| + // The result is passed to |callback|. The result is indexed by |
| + // MediaDeviceType. Entries in the result with a value of true for requested |
| + // device types indicate that the frame has permission to access devices of |
| + // the corresponding types. |
| + // This method can be called on any thread. |
| + void CheckPermissions( |
| + MediaDevicesManager::BoolDeviceTypes requested_device_types, |
| + int render_process_id, |
| + int routing_id, |
| + const url::Origin& security_origin, |
| + const base::Callback<void(const MediaDevicesManager::BoolDeviceTypes&)>& |
| + callback); |
| + |
| + // Forces a specific value to be returned by the permission-checking functions |
| + // for all device types. |
| + 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
|
| + |
| + private: |
| + bool use_override_; |
| + bool override_value_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_ |