Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: content/browser/renderer_host/media/audio_output_authorization_handler.h

Issue 2424163004: Factor out authorization from AudioRendererHost. (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..801a8dd529251dcd8fdaa07a6a01c78ac09b10ba
--- /dev/null
+++ b/content/browser/renderer_host/media/audio_output_authorization_handler.h
@@ -0,0 +1,85 @@
+// 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/bad_message.h"
+#include "content/browser/renderer_host/media/media_stream_manager.h"
+#include "content/browser/renderer_host/media/media_stream_ui_proxy.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 {
+class AudioOutputAuthorizationHandler {
Guido Urdaneta 2016/10/28 15:17:29 Is this class really necessary in the context of m
Max Morin 2016/11/01 11:26:20 The class isn't strictly necessary, but I want to
Guido Urdaneta 2016/11/01 13:49:16 Now that I understand it, I like it. Maybe you sho
Max Morin 2016/11/01 14:47:19 Done.
+ public:
+ using AuthorizationCompletedCallback =
Guido Urdaneta 2016/10/28 15:17:29 This callback type looks not trivial. You should h
Max Morin 2016/11/01 11:26:20 OnceCallback makes sense, but it is not possible t
+ base::Callback<void(media::OutputDeviceStatus,
+ const media::AudioParameters&,
+ const std::string&)>;
+
+ using BadMessageHandler =
Guido Urdaneta 2016/10/28 15:17:28 Why is a BadMessageHandler needed? Can't you just
Max Morin 2016/11/01 11:26:20 Done.
+ base::Callback<void(content::bad_message::BadMessageReason)>;
+
+ AudioOutputAuthorizationHandler(MediaStreamManager* media_stream_manager,
+ int render_process_id_,
+ const std::string& salt);
+
+ ~AudioOutputAuthorizationHandler();
+
+ // Checks authorization of the device with device_id for the given
+ // render frame id and security origin, or uses session_id
+ // for authorization.
+ void RequestDeviceAuthorization(int render_frame_id,
+ int session_id,
+ const std::string& device_id,
+ const url::Origin& security_origin,
+ AuthorizationCompletedCallback cb);
+
+ // In case an invalid request is recieved, this handler will be called.
Guido Urdaneta 2016/10/28 15:17:29 typo: recieved -> received
Max Morin 2016/11/01 11:26:20 Done.
+ void SetBadMessageHandler(BadMessageHandler handler) {
Guido Urdaneta 2016/10/28 15:17:28 If you're going to use a handler, why not pass it
Max Morin 2016/11/01 11:26:20 Removed handler.
+ bad_message_handler_ = std::move(handler);
+ }
+
+ private:
+ void CheckOutputDeviceAccess(AuthorizationCompletedCallback cb,
+ int render_frame_id,
+ const std::string& device_id,
+ const url::Origin& security_origin);
+
+ void AccessChecked(AuthorizationCompletedCallback cb,
+ std::unique_ptr<MediaStreamUIProxy> ui_proxy,
+ 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,
+ media::AudioParameters output_params);
+
+ MediaStreamManager* const media_stream_manager_;
+ const int render_process_id_;
+ const std::string salt_;
+ BadMessageHandler bad_message_handler_;
+ base::WeakPtrFactory<AudioOutputAuthorizationHandler> weak_factory;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioOutputAuthorizationHandler);
+};
+} // namespace content
+#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_AUTHORIZATION_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698