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

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

Issue 2872913003: Do not pass the origin to MediaDevicesDispatcherHost. (Closed)
Patch Set: Add tests with unique origin Created 3 years, 7 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 CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_
6 #define CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_ 6 #define CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "content/browser/renderer_host/media/media_devices_manager.h" 12 #include "content/browser/renderer_host/media/media_devices_manager.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 14
15 namespace url {
16 class Origin;
17 }
18
19 namespace content { 15 namespace content {
20 16
21 // This class provides various utility functions to check if a render frame 17 // This class provides various utility functions to check if a render frame
22 // has permission to access media devices. Note that none of the methods 18 // has permission to access media devices. Note that none of the methods
23 // prompts the user to request permission. 19 // prompts the user to request permission.
24 class CONTENT_EXPORT MediaDevicesPermissionChecker { 20 class CONTENT_EXPORT MediaDevicesPermissionChecker {
25 public: 21 public:
26 MediaDevicesPermissionChecker(); 22 MediaDevicesPermissionChecker();
27 // This constructor creates a MediaDevicesPermissionChecker that replies 23 // This constructor creates a MediaDevicesPermissionChecker that replies
28 // |override_value| to all permission requests. Use only for testing. 24 // |override_value| to all permission requests. Use only for testing.
29 explicit MediaDevicesPermissionChecker(bool override_value); 25 explicit MediaDevicesPermissionChecker(bool override_value);
30 26
31 // Checks if the origin |security_origin| associated to a render frame 27 // Checks if the origin associated to a render frame identified by
32 // identified by |render_process_id| and |render_frame_id| is allowed to 28 // |render_process_id| and |render_frame_id| is allowed to access the media
33 // access the media device type |device_type|. 29 // device type |device_type|.
34 // This method must be called on the UI thread. 30 // This method must be called on the UI thread.
35 bool CheckPermissionOnUIThread(MediaDeviceType device_type, 31 bool CheckPermissionOnUIThread(MediaDeviceType device_type,
36 int render_process_id, 32 int render_process_id,
37 int render_frame_id, 33 int render_frame_id) const;
38 const url::Origin& security_origin) const;
39 34
40 // Checks if the origin |security_origin| associated to a render frame 35 // Checks if the origin associated to a render frame identified by
41 // identified by |render_process_id| and |render_frame_id| is allowed to 36 // |render_process_id| and |render_frame_id| is allowed to access the media
42 // access the media device type |device_type|. The result is passed to 37 // device type |device_type|. The result is passed to |callback|.
43 // |callback|.
44 // This method can be called on any thread. |callback| is fired on the same 38 // This method can be called on any thread. |callback| is fired on the same
45 // thread this method is called on. 39 // thread this method is called on.
46 void CheckPermission(MediaDeviceType device_type, 40 void CheckPermission(MediaDeviceType device_type,
47 int render_process_id, 41 int render_process_id,
48 int render_frame_id, 42 int render_frame_id,
49 const url::Origin& security_origin,
50 const base::Callback<void(bool)>& callback) const; 43 const base::Callback<void(bool)>& callback) const;
51 44
52 // Checks if the origin |security_origin| associated to a render frame 45 // Checks if the origin associated to a render frame identified by
53 // identified by |render_process_id| and |render_frame_id| is allowed to 46 // |render_process_id| and |render_frame_id| is allowed to access the media
54 // access the media device types marked with a value of true in 47 // device types marked with a value of true in |requested_device_types|. The
55 // |requested_device_types|. The result is passed to |callback|. The result is 48 // result is passed to |callback|. The result is indexed by MediaDeviceType.
56 // indexed by MediaDeviceType. Entries in the result with a value of true for 49 // Entries in the result with a value of true for requested device types
57 // requested device types indicate that the frame has permission to access 50 // indicate that the frame has permission to access devices of the
58 // devices of the corresponding types. 51 // corresponding types.
59 // This method can be called on any thread. |callback| is fired on the same 52 // This method can be called on any thread. |callback| is fired on the same
60 // thread this method is called on. 53 // thread this method is called on.
61 void CheckPermissions( 54 void CheckPermissions(
62 MediaDevicesManager::BoolDeviceTypes requested_device_types, 55 MediaDevicesManager::BoolDeviceTypes requested_device_types,
63 int render_process_id, 56 int render_process_id,
64 int render_frame_id, 57 int render_frame_id,
65 const url::Origin& security_origin,
66 const base::Callback<void(const MediaDevicesManager::BoolDeviceTypes&)>& 58 const base::Callback<void(const MediaDevicesManager::BoolDeviceTypes&)>&
67 callback) const; 59 callback) const;
68 60
69 private: 61 private:
70 const bool use_override_; 62 const bool use_override_;
71 const bool override_value_; 63 const bool override_value_;
72 64
73 DISALLOW_COPY_AND_ASSIGN(MediaDevicesPermissionChecker); 65 DISALLOW_COPY_AND_ASSIGN(MediaDevicesPermissionChecker);
74 }; 66 };
75 67
76 } // namespace content 68 } // namespace content
77 69
78 #endif // CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_ 70 #endif // CONTENT_BROWSER_MEDIA_MEDIA_DEVICES_PERMISSION_CHECKER_H_
OLDNEW
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/media/media_devices_permission_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698