Chromium Code Reviews| 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/bad_message.h" | |
| 16 #include "content/browser/renderer_host/media/media_stream_manager.h" | |
| 17 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | |
| 18 #include "media/audio/audio_device_description.h" | |
| 19 #include "media/audio/audio_manager.h" | |
| 20 #include "media/base/audio_parameters.h" | |
| 21 #include "media/base/output_device_info.h" | |
| 22 | |
| 23 namespace content { | |
| 24 class AudioOutputAuthorizationHandler { | |
| 25 public: | |
| 26 using AuthorizationCompletedCallback = | |
| 27 base::Callback<void(media::OutputDeviceStatus, | |
| 28 media::AudioParameters, | |
| 29 const std::string&)>; | |
| 30 | |
| 31 using BadMessageHandler = | |
| 32 base::Callback<void(content::bad_message::BadMessageReason)>; | |
| 33 | |
| 34 AudioOutputAuthorizationHandler(MediaStreamManager* media_stream_manager, | |
| 35 int render_process_id_, | |
| 36 const std::string& salt); | |
| 37 | |
| 38 ~AudioOutputAuthorizationHandler(); | |
| 39 | |
| 40 // Checks authorization of the device with device_id for the given | |
| 41 // render frame id and security origin, or uses session_id | |
| 42 // for authorization. | |
| 43 void RequestDeviceAuthorization(int render_frame_id, | |
| 44 int session_id, | |
| 45 const std::string& device_id, | |
| 46 const url::Origin& security_origin, | |
| 47 AuthorizationCompletedCallback cb); | |
|
o1ka
2016/10/27 13:58:09
everywhere: pass the callback around as const refe
Max Morin
2016/10/28 11:16:07
How would we guarantee that it's alive in that cas
| |
| 48 | |
| 49 // In case an invalid request is recieved, this handler will be called. | |
| 50 void SetBadMessageHandler(BadMessageHandler handler) { | |
| 51 bad_message_handler_ = std::move(handler); | |
| 52 } | |
| 53 | |
| 54 private: | |
| 55 void CheckOutputDeviceAccess(AuthorizationCompletedCallback cb, | |
| 56 int render_frame_id, | |
| 57 const std::string& device_id, | |
| 58 const url::Origin& security_origin); | |
| 59 | |
| 60 void AccessChecked(AuthorizationCompletedCallback cb, | |
| 61 std::unique_ptr<MediaStreamUIProxy> ui_proxy, | |
| 62 const std::string& device_id, | |
| 63 const url::Origin& security_origin, | |
| 64 bool have_access); | |
| 65 | |
| 66 void TranslateDeviceID(AuthorizationCompletedCallback cb, | |
| 67 const std::string& device_id, | |
| 68 const url::Origin& security_origin, | |
| 69 const MediaDeviceEnumeration& enumeration); | |
| 70 | |
| 71 void DeviceParametersReceived(AuthorizationCompletedCallback cb, | |
| 72 bool device_found, | |
| 73 const std::string& unique_id, | |
| 74 media::AudioParameters output_params); | |
| 75 | |
| 76 MediaStreamManager* const media_stream_manager_; | |
| 77 const int render_process_id_; | |
| 78 const std::string salt_; | |
| 79 BadMessageHandler bad_message_handler_; | |
| 80 base::WeakPtrFactory<AudioOutputAuthorizationHandler> weak_factory; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(AudioOutputAuthorizationHandler); | |
| 83 }; | |
| 84 } // namespace content | |
| 85 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLE R_H_ | |
| OLD | NEW |