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

Side by Side Diff: content/browser/renderer_host/media/audio_output_authorization_handler.h

Issue 2424163004: Factor out authorization from AudioRendererHost. (Closed)
Patch Set: . Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(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 {
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.
25 public:
26 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
27 base::Callback<void(media::OutputDeviceStatus,
28 const media::AudioParameters&,
29 const std::string&)>;
30
31 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.
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);
48
49 // 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.
50 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.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698