| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This class implements authorization checking for AudioRendererHost. |
| 6 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLER_H
_ |
| 7 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLER_H
_ |
| 8 |
| 9 #include <memory> |
| 10 #include <string> |
| 11 #include <utility> |
| 12 |
| 13 #include "base/callback_forward.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "content/browser/media/media_devices_permission_checker.h" |
| 16 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 17 #include "media/audio/audio_device_description.h" |
| 18 #include "media/audio/audio_manager.h" |
| 19 #include "media/base/audio_parameters.h" |
| 20 #include "media/base/output_device_info.h" |
| 21 |
| 22 namespace content { |
| 23 |
| 24 // This class, which lives on the IO thread, handles the logic of a device |
| 25 // request from the renderer. It also looks up the device to use (if session_id |
| 26 // is used) and the default parameters for the selected audio device. |
| 27 class CONTENT_EXPORT AudioOutputAuthorizationHandler { |
| 28 public: |
| 29 // TODO(maxmorin): Change to OnceCallback once base:: code is ready for it. |
| 30 using AuthorizationCompletedCallback = |
| 31 base::Callback<void(media::OutputDeviceStatus, |
| 32 const media::AudioParameters&, |
| 33 const std::string&)>; |
| 34 |
| 35 AudioOutputAuthorizationHandler(MediaStreamManager* media_stream_manager, |
| 36 int render_process_id_, |
| 37 const std::string& salt); |
| 38 |
| 39 ~AudioOutputAuthorizationHandler(); |
| 40 |
| 41 // Checks authorization of the device with the hashed id device_id for the |
| 42 // given render frame id and security origin, or uses session_id for |
| 43 // authorization. Looks up device id (if session_id is used for device |
| 44 // selection) and default device parameters. |cb| will be called with the |
| 45 // result by |this| on the IO thread. |
| 46 void RequestDeviceAuthorization(int render_frame_id, |
| 47 int session_id, |
| 48 const std::string& device_id, |
| 49 const url::Origin& security_origin, |
| 50 AuthorizationCompletedCallback cb); |
| 51 |
| 52 MediaDevicesPermissionChecker& GetMediaDevicesPermissionCheckerForTesting() { |
| 53 return permission_checker_; |
| 54 } |
| 55 |
| 56 private: |
| 57 void CheckOutputDeviceAccess(AuthorizationCompletedCallback cb, |
| 58 int render_frame_id, |
| 59 const std::string& device_id, |
| 60 const url::Origin& security_origin); |
| 61 |
| 62 void AccessChecked(AuthorizationCompletedCallback cb, |
| 63 const std::string& device_id, |
| 64 const url::Origin& security_origin, |
| 65 bool have_access); |
| 66 |
| 67 void TranslateDeviceID(AuthorizationCompletedCallback cb, |
| 68 const std::string& device_id, |
| 69 const url::Origin& security_origin, |
| 70 const MediaDeviceEnumeration& enumeration); |
| 71 |
| 72 void DeviceParametersReceived(AuthorizationCompletedCallback cb, |
| 73 bool device_found, |
| 74 const std::string& unique_id, |
| 75 const media::AudioParameters& output_params); |
| 76 |
| 77 MediaStreamManager* const media_stream_manager_; |
| 78 MediaDevicesPermissionChecker permission_checker_; |
| 79 const int render_process_id_; |
| 80 const std::string salt_; |
| 81 base::WeakPtrFactory<AudioOutputAuthorizationHandler> weak_factory_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(AudioOutputAuthorizationHandler); |
| 84 }; |
| 85 } // namespace content |
| 86 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLE
R_H_ |
| OLD | NEW |