| Index: content/browser/renderer_host/media/audio_output_authorization_handler.h
|
| diff --git a/content/browser/renderer_host/media/audio_output_authorization_handler.h b/content/browser/renderer_host/media/audio_output_authorization_handler.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..342c01702a7aa1a1b9dbd1a53fa07d750d2eb0e3
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/media/audio_output_authorization_handler.h
|
| @@ -0,0 +1,86 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// This class implements authorization checking for AudioRendererHost.
|
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLER_H_
|
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLER_H_
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +#include <utility>
|
| +
|
| +#include "base/callback_forward.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "content/browser/media/media_devices_permission_checker.h"
|
| +#include "content/browser/renderer_host/media/media_stream_manager.h"
|
| +#include "media/audio/audio_device_description.h"
|
| +#include "media/audio/audio_manager.h"
|
| +#include "media/base/audio_parameters.h"
|
| +#include "media/base/output_device_info.h"
|
| +
|
| +namespace content {
|
| +
|
| +// This class, which lives on the IO thread, handles the logic of a device
|
| +// request from the renderer. It also looks up the device to use (if session_id
|
| +// is used) and the default parameters for the selected audio device.
|
| +class CONTENT_EXPORT AudioOutputAuthorizationHandler {
|
| + public:
|
| + // TODO(maxmorin): Change to OnceCallback once base:: code is ready for it.
|
| + using AuthorizationCompletedCallback =
|
| + base::Callback<void(media::OutputDeviceStatus,
|
| + const media::AudioParameters&,
|
| + const std::string&)>;
|
| +
|
| + AudioOutputAuthorizationHandler(MediaStreamManager* media_stream_manager,
|
| + int render_process_id_,
|
| + const std::string& salt);
|
| +
|
| + ~AudioOutputAuthorizationHandler();
|
| +
|
| + // Checks authorization of the device with the hashed id device_id for the
|
| + // given render frame id and security origin, or uses session_id for
|
| + // authorization. Looks up device id (if session_id is used for device
|
| + // selection) and default device parameters. |cb| will be called with the
|
| + // result by |this| on the IO thread.
|
| + void RequestDeviceAuthorization(int render_frame_id,
|
| + int session_id,
|
| + const std::string& device_id,
|
| + const url::Origin& security_origin,
|
| + AuthorizationCompletedCallback cb);
|
| +
|
| + MediaDevicesPermissionChecker& GetMediaDevicesPermissionCheckerForTesting() {
|
| + return permission_checker_;
|
| + }
|
| +
|
| + private:
|
| + void CheckOutputDeviceAccess(AuthorizationCompletedCallback cb,
|
| + int render_frame_id,
|
| + const std::string& device_id,
|
| + const url::Origin& security_origin);
|
| +
|
| + void AccessChecked(AuthorizationCompletedCallback cb,
|
| + const std::string& device_id,
|
| + const url::Origin& security_origin,
|
| + bool have_access);
|
| +
|
| + void TranslateDeviceID(AuthorizationCompletedCallback cb,
|
| + const std::string& device_id,
|
| + const url::Origin& security_origin,
|
| + const MediaDeviceEnumeration& enumeration);
|
| +
|
| + void DeviceParametersReceived(AuthorizationCompletedCallback cb,
|
| + bool device_found,
|
| + const std::string& unique_id,
|
| + const media::AudioParameters& output_params);
|
| +
|
| + MediaStreamManager* const media_stream_manager_;
|
| + MediaDevicesPermissionChecker permission_checker_;
|
| + const int render_process_id_;
|
| + const std::string salt_;
|
| + base::WeakPtrFactory<AudioOutputAuthorizationHandler> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AudioOutputAuthorizationHandler);
|
| +};
|
| +} // namespace content
|
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLER_H_
|
|
|