Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 virtual ~MediaStreamUIProxy(); | 35 virtual ~MediaStreamUIProxy(); |
| 36 | 36 |
| 37 // Requests access for the MediaStream by calling | 37 // Requests access for the MediaStream by calling |
| 38 // WebContentsDelegate::RequestMediaAccessPermission(). The specified | 38 // WebContentsDelegate::RequestMediaAccessPermission(). The specified |
| 39 // |response_callback| is called when the WebContentsDelegate approves or | 39 // |response_callback| is called when the WebContentsDelegate approves or |
| 40 // denies request. | 40 // denies request. |
| 41 virtual void RequestAccess(const MediaStreamRequest& request, | 41 virtual void RequestAccess(const MediaStreamRequest& request, |
| 42 const ResponseCallback& response_callback); | 42 const ResponseCallback& response_callback); |
| 43 | 43 |
| 44 // Checks if we have permission to access the microphone or camera. Note that | |
| 45 // this does not query the user. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE | |
|
perkj_chrome
2014/09/15 12:06:25
Can you expand this. Ie, When should this be calle
Henrik Grunell
2014/09/15 13:45:17
I added that this checks any stored settings. Not
perkj_chrome
2014/09/15 15:08:55
I was wondering about the " Note that
45 // th
Henrik Grunell
2014/09/15 18:20:15
Yes, exactly. Either if the user has granted acces
| |
| 46 // or MEDIA_DEVICE_VIDEO_CAPTURE. | |
| 47 virtual void CheckAccess(const GURL& security_origin, | |
| 48 MediaStreamType type, | |
| 49 int render_process_id, | |
| 50 int render_frame_id, | |
| 51 const base::Callback<void(bool)>& callback); | |
| 52 | |
| 44 // Notifies the UI that the MediaStream has been started. Must be called after | 53 // Notifies the UI that the MediaStream has been started. Must be called after |
| 45 // access has been approved using RequestAccess(). |stop_callback| is be | 54 // access has been approved using RequestAccess(). |stop_callback| is be |
| 46 // called on the IO thread after the user has requests the stream to be | 55 // called on the IO thread after the user has requests the stream to be |
| 47 // stopped. |window_id_callback| is called on the IO thread with the platform- | 56 // stopped. |window_id_callback| is called on the IO thread with the platform- |
| 48 // dependent window ID of the UI. | 57 // dependent window ID of the UI. |
| 49 virtual void OnStarted(const base::Closure& stop_callback, | 58 virtual void OnStarted(const base::Closure& stop_callback, |
| 50 const WindowIdCallback& window_id_callback); | 59 const WindowIdCallback& window_id_callback); |
| 51 | 60 |
| 52 void SetRenderFrameHostDelegateForTests(RenderFrameHostDelegate* delegate); | 61 void SetRenderFrameHostDelegateForTests(RenderFrameHostDelegate* delegate); |
| 53 | 62 |
| 54 protected: | 63 protected: |
| 55 explicit MediaStreamUIProxy(RenderFrameHostDelegate* test_render_delegate); | 64 explicit MediaStreamUIProxy(RenderFrameHostDelegate* test_render_delegate); |
| 56 | 65 |
| 57 private: | 66 private: |
| 58 class Core; | 67 class Core; |
| 59 friend class Core; | 68 friend class Core; |
| 60 friend class FakeMediaStreamUIProxy; | 69 friend class FakeMediaStreamUIProxy; |
| 61 | 70 |
| 62 void ProcessAccessRequestResponse( | 71 void ProcessAccessRequestResponse( |
| 63 const MediaStreamDevices& devices, | 72 const MediaStreamDevices& devices, |
| 64 content::MediaStreamRequestResult result); | 73 content::MediaStreamRequestResult result); |
| 65 void ProcessStopRequestFromUI(); | 74 void ProcessStopRequestFromUI(); |
| 66 void OnWindowId(const WindowIdCallback& window_id_callback, | 75 void OnWindowId(const WindowIdCallback& window_id_callback, |
| 67 gfx::NativeViewId* window_id); | 76 gfx::NativeViewId* window_id); |
| 77 void OnCheckedAccess(const base::Callback<void(bool)>& callback, | |
| 78 bool have_access); | |
| 68 | 79 |
| 69 scoped_ptr<Core, content::BrowserThread::DeleteOnUIThread> core_; | 80 scoped_ptr<Core, content::BrowserThread::DeleteOnUIThread> core_; |
| 70 ResponseCallback response_callback_; | 81 ResponseCallback response_callback_; |
| 71 base::Closure stop_callback_; | 82 base::Closure stop_callback_; |
| 72 | 83 |
| 73 base::WeakPtrFactory<MediaStreamUIProxy> weak_factory_; | 84 base::WeakPtrFactory<MediaStreamUIProxy> weak_factory_; |
| 74 | 85 |
| 75 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIProxy); | 86 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIProxy); |
| 76 }; | 87 }; |
| 77 | 88 |
| 78 class CONTENT_EXPORT FakeMediaStreamUIProxy : public MediaStreamUIProxy { | 89 class CONTENT_EXPORT FakeMediaStreamUIProxy : public MediaStreamUIProxy { |
| 79 public: | 90 public: |
| 80 explicit FakeMediaStreamUIProxy(); | 91 explicit FakeMediaStreamUIProxy(); |
| 81 virtual ~FakeMediaStreamUIProxy(); | 92 virtual ~FakeMediaStreamUIProxy(); |
| 82 | 93 |
| 83 void SetAvailableDevices(const MediaStreamDevices& devices); | 94 void SetAvailableDevices(const MediaStreamDevices& devices); |
| 95 void SetMicAccess(bool access); | |
| 96 void SetCameraAccess(bool access); | |
| 84 | 97 |
| 85 // MediaStreamUIProxy overrides. | 98 // MediaStreamUIProxy overrides. |
| 86 virtual void RequestAccess( | 99 virtual void RequestAccess( |
| 87 const MediaStreamRequest& request, | 100 const MediaStreamRequest& request, |
| 88 const ResponseCallback& response_callback) OVERRIDE; | 101 const ResponseCallback& response_callback) OVERRIDE; |
| 102 virtual void CheckAccess(const GURL& security_origin, | |
| 103 MediaStreamType type, | |
| 104 int render_process_id, | |
| 105 int render_frame_id, | |
| 106 const base::Callback<void(bool)>& callback) OVERRIDE; | |
| 89 virtual void OnStarted(const base::Closure& stop_callback, | 107 virtual void OnStarted(const base::Closure& stop_callback, |
| 90 const WindowIdCallback& window_id_callback) OVERRIDE; | 108 const WindowIdCallback& window_id_callback) OVERRIDE; |
| 91 | 109 |
| 92 private: | 110 private: |
| 111 // This is used for RequestAccess(). | |
| 93 MediaStreamDevices devices_; | 112 MediaStreamDevices devices_; |
| 94 | 113 |
| 114 // These are used for CheckAccess(). | |
| 115 bool mic_access_; | |
| 116 bool camera_access_; | |
| 117 | |
| 95 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); | 118 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); |
| 96 }; | 119 }; |
| 97 | 120 |
| 98 } // namespace content | 121 } // namespace content |
| 99 | 122 |
| 100 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ | 123 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ |
| OLD | NEW |