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

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

Issue 2065383003: Revert of Make default media device ID salts random by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // MediaStreamManager is used to open/enumerate media capture devices (video 5 // MediaStreamManager is used to open/enumerate media capture devices (video
6 // supported now). Call flow: 6 // supported now). Call flow:
7 // 1. GenerateStream is called when a render process wants to use a capture 7 // 1. GenerateStream is called when a render process wants to use a capture
8 // device. 8 // device.
9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to 9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to
10 // use devices and for which device to use. 10 // use devices and for which device to use.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const url::Origin& security_origin, 112 const url::Origin& security_origin,
113 const MediaRequestResponseCallback& callback); 113 const MediaRequestResponseCallback& callback);
114 114
115 // GenerateStream opens new media devices according to |components|. It 115 // GenerateStream opens new media devices according to |components|. It
116 // creates a new request which is identified by a unique string that's 116 // creates a new request which is identified by a unique string that's
117 // returned to the caller. |render_process_id| and |render_frame_id| are used 117 // returned to the caller. |render_process_id| and |render_frame_id| are used
118 // to determine where the infobar will appear to the user. 118 // to determine where the infobar will appear to the user.
119 void GenerateStream(MediaStreamRequester* requester, 119 void GenerateStream(MediaStreamRequester* requester,
120 int render_process_id, 120 int render_process_id,
121 int render_frame_id, 121 int render_frame_id,
122 const std::string& salt, 122 const ResourceContext::SaltCallback& sc,
123 int page_request_id, 123 int page_request_id,
124 const StreamControls& controls, 124 const StreamControls& controls,
125 const url::Origin& security_origin, 125 const url::Origin& security_origin,
126 bool user_gesture); 126 bool user_gesture);
127 127
128 void CancelRequest(int render_process_id, 128 void CancelRequest(int render_process_id,
129 int render_frame_id, 129 int render_frame_id,
130 int page_request_id); 130 int page_request_id);
131 131
132 // Cancel an open request identified by |label|. 132 // Cancel an open request identified by |label|.
(...skipping 11 matching lines...) Expand all
144 // Gets a list of devices of |type|, which must be MEDIA_DEVICE_AUDIO_CAPTURE 144 // Gets a list of devices of |type|, which must be MEDIA_DEVICE_AUDIO_CAPTURE
145 // or MEDIA_DEVICE_VIDEO_CAPTURE. 145 // or MEDIA_DEVICE_VIDEO_CAPTURE.
146 // The request is identified using the string returned to the caller. 146 // The request is identified using the string returned to the caller.
147 // When the |requester| is NULL, MediaStreamManager will enumerate both audio 147 // When the |requester| is NULL, MediaStreamManager will enumerate both audio
148 // and video devices and also start monitoring device changes, such as 148 // and video devices and also start monitoring device changes, such as
149 // plug/unplug. The new device lists will be delivered via media observer to 149 // plug/unplug. The new device lists will be delivered via media observer to
150 // MediaCaptureDevicesDispatcher. 150 // MediaCaptureDevicesDispatcher.
151 virtual std::string EnumerateDevices(MediaStreamRequester* requester, 151 virtual std::string EnumerateDevices(MediaStreamRequester* requester,
152 int render_process_id, 152 int render_process_id,
153 int render_frame_id, 153 int render_frame_id,
154 const std::string& salt, 154 const ResourceContext::SaltCallback& sc,
155 int page_request_id, 155 int page_request_id,
156 MediaStreamType type, 156 MediaStreamType type,
157 const url::Origin& security_origin); 157 const url::Origin& security_origin);
158 158
159 // Open a device identified by |device_id|. |type| must be either 159 // Open a device identified by |device_id|. |type| must be either
160 // MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE. 160 // MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE.
161 // The request is identified using string returned to the caller. 161 // The request is identified using string returned to the caller.
162 void OpenDevice(MediaStreamRequester* requester, 162 void OpenDevice(MediaStreamRequester* requester,
163 int render_process_id, 163 int render_process_id,
164 int render_frame_id, 164 int render_frame_id,
165 const std::string& salt, 165 const ResourceContext::SaltCallback& sc,
166 int page_request_id, 166 int page_request_id,
167 const std::string& device_id, 167 const std::string& device_id,
168 MediaStreamType type, 168 MediaStreamType type,
169 const url::Origin& security_origin); 169 const url::Origin& security_origin);
170 170
171 // Finds and returns the device id corresponding to the given 171 // Finds and returns the device id corresponding to the given
172 // |source_id|. Returns true if there was a raw device id that matched the 172 // |source_id|. Returns true if there was a raw device id that matched the
173 // given |source_id|, false if nothing matched it. 173 // given |source_id|, false if nothing matched it.
174 bool TranslateSourceIdToDeviceId(MediaStreamType stream_type, 174 bool TranslateSourceIdToDeviceId(MediaStreamType stream_type,
175 const std::string& salt, 175 const ResourceContext::SaltCallback& rc,
176 const url::Origin& security_origin, 176 const url::Origin& security_origin,
177 const std::string& source_id, 177 const std::string& source_id,
178 std::string* device_id) const; 178 std::string* device_id) const;
179 179
180 // Find |device_id| in the list of |requests_|, and returns its session id, 180 // Find |device_id| in the list of |requests_|, and returns its session id,
181 // or StreamDeviceInfo::kNoId if not found. 181 // or StreamDeviceInfo::kNoId if not found.
182 int VideoDeviceIdToSessionId(const std::string& device_id) const; 182 int VideoDeviceIdToSessionId(const std::string& device_id) const;
183 183
184 // Called by UI to make sure the device monitor is started so that UI receive 184 // Called by UI to make sure the device monitor is started so that UI receive
185 // notifications about device changes. 185 // notifications about device changes.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // It is an error to try to subscribe a |subscriber| that is already 235 // It is an error to try to subscribe a |subscriber| that is already
236 // subscribed or to cancel the subscription of a |subscriber| that is not 236 // subscribed or to cancel the subscription of a |subscriber| that is not
237 // subscribed. Also, subscribers must make sure to invoke 237 // subscribed. Also, subscribers must make sure to invoke
238 // CancelDeviceChangeNotifications() before destruction. Otherwise, dangling 238 // CancelDeviceChangeNotifications() before destruction. Otherwise, dangling
239 // pointers and use-after-destruction problems will occur. 239 // pointers and use-after-destruction problems will occur.
240 void SubscribeToDeviceChangeNotifications(MediaStreamRequester* subscriber); 240 void SubscribeToDeviceChangeNotifications(MediaStreamRequester* subscriber);
241 void CancelDeviceChangeNotifications(MediaStreamRequester* subscriber); 241 void CancelDeviceChangeNotifications(MediaStreamRequester* subscriber);
242 242
243 // Generates a hash of a device's unique ID usable by one 243 // Generates a hash of a device's unique ID usable by one
244 // particular security origin. 244 // particular security origin.
245 static std::string GetHMACForMediaDeviceID(const std::string& salt, 245 static std::string GetHMACForMediaDeviceID(
246 const url::Origin& security_origin, 246 const ResourceContext::SaltCallback& sc,
247 const std::string& raw_unique_id); 247 const url::Origin& security_origin,
248 const std::string& raw_unique_id);
248 249
249 // Convenience method to check if |device_guid| is an HMAC of 250 // Convenience method to check if |device_guid| is an HMAC of
250 // |raw_device_id| for |security_origin|. 251 // |raw_device_id| for |security_origin|.
251 static bool DoesMediaDeviceIDMatchHMAC(const std::string& salt, 252 static bool DoesMediaDeviceIDMatchHMAC(
252 const url::Origin& security_origin, 253 const ResourceContext::SaltCallback& sc,
253 const std::string& device_guid, 254 const url::Origin& security_origin,
254 const std::string& raw_unique_id); 255 const std::string& device_guid,
256 const std::string& raw_unique_id);
255 257
256 // Returns true if the renderer process identified with |render_process_id| 258 // Returns true if the renderer process identified with |render_process_id|
257 // is allowed to access |origin|. 259 // is allowed to access |origin|.
258 static bool IsOriginAllowed(int render_process_id, const url::Origin& origin); 260 static bool IsOriginAllowed(int render_process_id, const url::Origin& origin);
259 261
260 // Set whether the capturing is secure for the capturing session with given 262 // Set whether the capturing is secure for the capturing session with given
261 // |session_id|, |render_process_id|, and the MediaStreamType |type|. 263 // |session_id|, |render_process_id|, and the MediaStreamType |type|.
262 void SetCapturingLinkSecured(int render_process_id, 264 void SetCapturingLinkSecured(int render_process_id,
263 int session_id, 265 int session_id,
264 content::MediaStreamType type, 266 content::MediaStreamType type,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 void StartMonitoringOnUIThread(); 398 void StartMonitoringOnUIThread();
397 #endif 399 #endif
398 400
399 // Picks a device ID from a list of required and alternate device IDs, 401 // Picks a device ID from a list of required and alternate device IDs,
400 // presented as part of a TrackControls structure. 402 // presented as part of a TrackControls structure.
401 // Either the required device ID is picked (if present), or the first 403 // Either the required device ID is picked (if present), or the first
402 // valid alternate device ID. 404 // valid alternate device ID.
403 // Returns false if the required device ID is present and invalid. 405 // Returns false if the required device ID is present and invalid.
404 // Otherwise, if no valid device is found, device_id is unchanged. 406 // Otherwise, if no valid device is found, device_id is unchanged.
405 bool PickDeviceId(MediaStreamType type, 407 bool PickDeviceId(MediaStreamType type,
406 const std::string& salt, 408 const ResourceContext::SaltCallback& salt_callback,
407 const url::Origin& security_origin, 409 const url::Origin& security_origin,
408 const TrackControls& controls, 410 const TrackControls& controls,
409 std::string* device_id) const; 411 std::string* device_id) const;
410 412
411 // Finds the requested device id from request. The requested device type 413 // Finds the requested device id from request. The requested device type
412 // must be MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE. 414 // must be MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE.
413 bool GetRequestedDeviceCaptureId(const DeviceRequest* request, 415 bool GetRequestedDeviceCaptureId(const DeviceRequest* request,
414 MediaStreamType type, 416 MediaStreamType type,
415 std::string* device_id) const; 417 std::string* device_id) const;
416 418
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 469
468 // Objects subscribed to changes in the set of media devices. 470 // Objects subscribed to changes in the set of media devices.
469 std::vector<MediaStreamRequester*> device_change_subscribers_; 471 std::vector<MediaStreamRequester*> device_change_subscribers_;
470 472
471 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); 473 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager);
472 }; 474 };
473 475
474 } // namespace content 476 } // namespace content
475 477
476 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ 478 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698