OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // MediaPermission implementation which dispatches queries/requests to Mojo |
| 6 // PermissionService. It relies on its base class MediaPermissionDispatcher to |
| 7 // manage pending callbacks. Non-UI threads could create |
| 8 // MediaPermissionDispatcherProxy by calling CreateProxy such that calls will be |
| 9 // executed on the UI thread which is where this object lives. |
| 10 |
| 11 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_ |
| 12 #define CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_ |
| 13 |
| 14 #include <map> |
| 15 |
| 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/thread_checker.h" |
| 18 #include "content/common/content_export.h" |
| 19 #include "content/common/permission_service.mojom.h" |
| 20 #include "content/public/renderer/render_frame_observer.h" |
| 21 #include "content/renderer/media/media_permission_dispatcher.h" |
| 22 #include "media/base/media_permission.h" |
| 23 |
| 24 namespace content { |
| 25 |
| 26 class CONTENT_EXPORT MediaPermissionDispatcherImpl |
| 27 : public MediaPermissionDispatcher, |
| 28 public RenderFrameObserver { |
| 29 public: |
| 30 explicit MediaPermissionDispatcherImpl(RenderFrame* render_frame); |
| 31 ~MediaPermissionDispatcherImpl() override; |
| 32 |
| 33 // media::MediaPermission implementation. |
| 34 void HasPermission(Type type, |
| 35 const GURL& security_origin, |
| 36 const PermissionStatusCB& permission_status_cb) override; |
| 37 |
| 38 // MediaStreamDevicePermissionContext doesn't support RequestPermission yet |
| 39 // and will always return CONTENT_SETTING_BLOCK. |
| 40 void RequestPermission( |
| 41 Type type, |
| 42 const GURL& security_origin, |
| 43 const PermissionStatusCB& permission_status_cb) override; |
| 44 |
| 45 // Create MediaPermissionDispatcherProxy object which will dispatch the |
| 46 // callback between the |caller_task_runner| and |task_runner_| in a thread |
| 47 // safe way. This can be called from non-UI thread. |
| 48 scoped_ptr<media::MediaPermission> CreateProxy( |
| 49 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner); |
| 50 |
| 51 private: |
| 52 // Callback for |permission_service_| calls. |
| 53 void OnPermissionStatus(uint32_t request_id, PermissionStatus status); |
| 54 |
| 55 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 56 |
| 57 PermissionServicePtr permission_service_; |
| 58 |
| 59 base::WeakPtrFactory<MediaPermissionDispatcherImpl> weak_ptr_factory_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(MediaPermissionDispatcherImpl); |
| 62 }; |
| 63 |
| 64 } // namespace content |
| 65 |
| 66 #endif // CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_ |
OLD | NEW |