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

Side by Side Diff: content/browser/renderer_host/media/media_stream_ui_proxy.h

Issue 1928493002: Use url::Origin to represent security origins in MediaStream-related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_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 "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/common/media_stream_request.h" 14 #include "content/public/common/media_stream_request.h"
15 15
16 namespace url {
17 class Origin;
18 }
19
16 namespace content { 20 namespace content {
17 21
18 class RenderFrameHostDelegate; 22 class RenderFrameHostDelegate;
19 23
20 // MediaStreamUIProxy proxies calls to media stream UI between IO thread and UI 24 // MediaStreamUIProxy proxies calls to media stream UI between IO thread and UI
21 // thread. One instance of this class is create per MediaStream object. It must 25 // thread. One instance of this class is create per MediaStream object. It must
22 // be created, used and destroyed on IO thread. 26 // be created, used and destroyed on IO thread.
23 class CONTENT_EXPORT MediaStreamUIProxy { 27 class CONTENT_EXPORT MediaStreamUIProxy {
24 public: 28 public:
25 typedef base::Callback< 29 typedef base::Callback<
26 void (const MediaStreamDevices& devices, 30 void(const MediaStreamDevices& devices,
27 content::MediaStreamRequestResult result)> 31 content::MediaStreamRequestResult result)>
28 ResponseCallback; 32 ResponseCallback;
29 33
30 typedef base::Callback<void(gfx::NativeViewId window_id)> WindowIdCallback; 34 typedef base::Callback<void(gfx::NativeViewId window_id)> WindowIdCallback;
31 35
32 static std::unique_ptr<MediaStreamUIProxy> Create(); 36 static std::unique_ptr<MediaStreamUIProxy> Create();
33 static std::unique_ptr<MediaStreamUIProxy> CreateForTests( 37 static std::unique_ptr<MediaStreamUIProxy> CreateForTests(
34 RenderFrameHostDelegate* render_delegate); 38 RenderFrameHostDelegate* render_delegate);
35 39
36 virtual ~MediaStreamUIProxy(); 40 virtual ~MediaStreamUIProxy();
37 41
38 // Requests access for the MediaStream by calling 42 // Requests access for the MediaStream by calling
39 // WebContentsDelegate::RequestMediaAccessPermission(). The specified 43 // WebContentsDelegate::RequestMediaAccessPermission(). The specified
40 // |response_callback| is called when the WebContentsDelegate approves or 44 // |response_callback| is called when the WebContentsDelegate approves or
41 // denies request. 45 // denies request.
42 virtual void RequestAccess(std::unique_ptr<MediaStreamRequest> request, 46 virtual void RequestAccess(std::unique_ptr<MediaStreamRequest> request,
43 const ResponseCallback& response_callback); 47 const ResponseCallback& response_callback);
44 48
45 // Checks if we have permission to access the microphone or camera. Note that 49 // Checks if we have permission to access the microphone or camera. Note that
46 // this does not query the user, it checks any stored settings such as policy 50 // this does not query the user, it checks any stored settings such as policy
47 // or extension permissions. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE 51 // or extension permissions. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE
48 // or MEDIA_DEVICE_VIDEO_CAPTURE. 52 // or MEDIA_DEVICE_VIDEO_CAPTURE.
49 virtual void CheckAccess(const GURL& security_origin, 53 virtual void CheckAccess(const url::Origin& security_origin,
50 MediaStreamType type, 54 MediaStreamType type,
51 int render_process_id, 55 int render_process_id,
52 int render_frame_id, 56 int render_frame_id,
53 const base::Callback<void(bool)>& callback); 57 const base::Callback<void(bool)>& callback);
54 58
55 // Notifies the UI that the MediaStream has been started. Must be called after 59 // Notifies the UI that the MediaStream has been started. Must be called after
56 // access has been approved using RequestAccess(). |stop_callback| is be 60 // access has been approved using RequestAccess(). |stop_callback| is be
57 // called on the IO thread after the user has requests the stream to be 61 // called on the IO thread after the user has requests the stream to be
58 // stopped. |window_id_callback| is called on the IO thread with the platform- 62 // stopped. |window_id_callback| is called on the IO thread with the platform-
59 // dependent window ID of the UI. 63 // dependent window ID of the UI.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 explicit FakeMediaStreamUIProxy(); 97 explicit FakeMediaStreamUIProxy();
94 ~FakeMediaStreamUIProxy() override; 98 ~FakeMediaStreamUIProxy() override;
95 99
96 void SetAvailableDevices(const MediaStreamDevices& devices); 100 void SetAvailableDevices(const MediaStreamDevices& devices);
97 void SetMicAccess(bool access); 101 void SetMicAccess(bool access);
98 void SetCameraAccess(bool access); 102 void SetCameraAccess(bool access);
99 103
100 // MediaStreamUIProxy overrides. 104 // MediaStreamUIProxy overrides.
101 void RequestAccess(std::unique_ptr<MediaStreamRequest> request, 105 void RequestAccess(std::unique_ptr<MediaStreamRequest> request,
102 const ResponseCallback& response_callback) override; 106 const ResponseCallback& response_callback) override;
103 void CheckAccess(const GURL& security_origin, 107 void CheckAccess(const url::Origin& security_origin,
104 MediaStreamType type, 108 MediaStreamType type,
105 int render_process_id, 109 int render_process_id,
106 int render_frame_id, 110 int render_frame_id,
107 const base::Callback<void(bool)>& callback) override; 111 const base::Callback<void(bool)>& callback) override;
108 void OnStarted(const base::Closure& stop_callback, 112 void OnStarted(const base::Closure& stop_callback,
109 const WindowIdCallback& window_id_callback) override; 113 const WindowIdCallback& window_id_callback) override;
110 114
111 private: 115 private:
112 // This is used for RequestAccess(). 116 // This is used for RequestAccess().
113 MediaStreamDevices devices_; 117 MediaStreamDevices devices_;
114 118
115 // These are used for CheckAccess(). 119 // These are used for CheckAccess().
116 bool mic_access_; 120 bool mic_access_;
117 bool camera_access_; 121 bool camera_access_;
118 122
119 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); 123 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy);
120 }; 124 };
121 125
122 } // namespace content 126 } // namespace content
123 127
124 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ 128 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698