| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/public/common/media_stream_request.h" | 12 #include "content/public/common/media_stream_request.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 class RenderViewHostDelegate; | 16 class RenderFrameHostDelegate; |
| 17 | 17 |
| 18 // MediaStreamUIProxy proxies calls to media stream UI between IO thread and UI | 18 // MediaStreamUIProxy proxies calls to media stream UI between IO thread and UI |
| 19 // thread. One instance of this class is create per MediaStream object. It must | 19 // thread. One instance of this class is create per MediaStream object. It must |
| 20 // be create, used and destroyed on IO thread. | 20 // be created, used and destroyed on IO thread. |
| 21 class CONTENT_EXPORT MediaStreamUIProxy { | 21 class CONTENT_EXPORT MediaStreamUIProxy { |
| 22 public: | 22 public: |
| 23 typedef base::Callback< | 23 typedef base::Callback< |
| 24 void (const MediaStreamDevices& devices, | 24 void (const MediaStreamDevices& devices, |
| 25 content::MediaStreamRequestResult result)> | 25 content::MediaStreamRequestResult result)> |
| 26 ResponseCallback; | 26 ResponseCallback; |
| 27 | 27 |
| 28 typedef base::Callback<void(gfx::NativeViewId window_id)> WindowIdCallback; | 28 typedef base::Callback<void(gfx::NativeViewId window_id)> WindowIdCallback; |
| 29 | 29 |
| 30 static scoped_ptr<MediaStreamUIProxy> Create(); | 30 static scoped_ptr<MediaStreamUIProxy> Create(); |
| 31 static scoped_ptr<MediaStreamUIProxy> CreateForTests( | 31 static scoped_ptr<MediaStreamUIProxy> CreateForTests( |
| 32 RenderViewHostDelegate* render_delegate); | 32 RenderFrameHostDelegate* render_delegate); |
| 33 | 33 |
| 34 virtual ~MediaStreamUIProxy(); | 34 virtual ~MediaStreamUIProxy(); |
| 35 | 35 |
| 36 // Requests access for the MediaStream by calling | 36 // Requests access for the MediaStream by calling |
| 37 // WebContentsDelegate::RequestMediaAccessPermission(). The specified | 37 // WebContentsDelegate::RequestMediaAccessPermission(). The specified |
| 38 // |response_callback| is called when the WebContentsDelegate approves or | 38 // |response_callback| is called when the WebContentsDelegate approves or |
| 39 // denies request. | 39 // denies request. |
| 40 virtual void RequestAccess(const MediaStreamRequest& request, | 40 virtual void RequestAccess(const MediaStreamRequest& request, |
| 41 const ResponseCallback& response_callback); | 41 const ResponseCallback& response_callback); |
| 42 | 42 |
| 43 // Notifies the UI that the MediaStream has been started. Must be called after | 43 // Notifies the UI that the MediaStream has been started. Must be called after |
| 44 // access has been approved using RequestAccess(). |stop_callback| is be | 44 // access has been approved using RequestAccess(). |stop_callback| is be |
| 45 // called on the IO thread after the user has requests the stream to be | 45 // called on the IO thread after the user has requests the stream to be |
| 46 // stopped. |window_id_callback| is called on the IO thread with the platform- | 46 // stopped. |window_id_callback| is called on the IO thread with the platform- |
| 47 // dependent window ID of the UI. | 47 // dependent window ID of the UI. |
| 48 virtual void OnStarted(const base::Closure& stop_callback, | 48 virtual void OnStarted(const base::Closure& stop_callback, |
| 49 const WindowIdCallback& window_id_callback); | 49 const WindowIdCallback& window_id_callback); |
| 50 | 50 |
| 51 void SetRenderViewHostDelegateForTests(RenderViewHostDelegate* delegate); | 51 void SetRenderFrameHostDelegateForTests(RenderFrameHostDelegate* delegate); |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 MediaStreamUIProxy(RenderViewHostDelegate* test_render_delegate); | 54 explicit MediaStreamUIProxy(RenderFrameHostDelegate* test_render_delegate); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 class Core; | 57 class Core; |
| 58 friend class Core; | 58 friend class Core; |
| 59 friend class FakeMediaStreamUIProxy; | 59 friend class FakeMediaStreamUIProxy; |
| 60 | 60 |
| 61 void ProcessAccessRequestResponse( | 61 void ProcessAccessRequestResponse( |
| 62 const MediaStreamDevices& devices, | 62 const MediaStreamDevices& devices, |
| 63 content::MediaStreamRequestResult result); | 63 content::MediaStreamRequestResult result); |
| 64 void ProcessStopRequestFromUI(); | 64 void ProcessStopRequestFromUI(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 MediaStreamDevices devices_; | 92 MediaStreamDevices devices_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); | 94 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace content | 97 } // namespace content |
| 98 | 98 |
| 99 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ | 99 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ |
| OLD | NEW |