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

Side by Side Diff: chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc

Issue 143003031: Allow retrieval of media device ID salt even after ResourceContext has gone away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO about proper fix. Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h" 5 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 // We don't hash the default device name, and we always return 180 // We don't hash the default device name, and we always return
181 // "default" for the default device. There is code in SetActiveSink 181 // "default" for the default device. There is code in SetActiveSink
182 // that transforms "default" to the empty string, and code in 182 // that transforms "default" to the empty string, and code in
183 // GetActiveSink that ensures we return "default" if we get the 183 // GetActiveSink that ensures we return "default" if we get the
184 // empty string as the current device ID. 184 // empty string as the current device ID.
185 if (raw_id.empty() || raw_id == media::AudioManagerBase::kDefaultDeviceId) 185 if (raw_id.empty() || raw_id == media::AudioManagerBase::kDefaultDeviceId)
186 return media::AudioManagerBase::kDefaultDeviceId; 186 return media::AudioManagerBase::kDefaultDeviceId;
187 187
188 GURL security_origin(source_url().GetOrigin()); 188 GURL security_origin(source_url().GetOrigin());
189 return content::GetHMACForMediaDeviceID(resource_context(), 189 return content::GetHMACForMediaDeviceID(
190 security_origin, 190 resource_context()->GetMediaDeviceIDSalt(),
191 raw_id); 191 security_origin,
192 raw_id);
192 } 193 }
193 194
194 void WebrtcAudioPrivateFunction::InitResourceContext() { 195 void WebrtcAudioPrivateFunction::InitResourceContext() {
195 resource_context_ = GetProfile()->GetResourceContext(); 196 resource_context_ = GetProfile()->GetResourceContext();
196 } 197 }
197 198
198 content::ResourceContext* WebrtcAudioPrivateFunction::resource_context() const { 199 content::ResourceContext* WebrtcAudioPrivateFunction::resource_context() const {
199 DCHECK(resource_context_); // Did you forget to InitResourceContext()? 200 DCHECK(resource_context_); // Did you forget to InitResourceContext()?
200 return resource_context_; 201 return resource_context_;
201 } 202 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 GURL security_origin(params_->security_origin); 422 GURL security_origin(params_->security_origin);
422 std::string source_id_in_origin(params_->source_id_in_origin); 423 std::string source_id_in_origin(params_->source_id_in_origin);
423 424
424 // Find the raw source ID for source_id_in_origin. 425 // Find the raw source ID for source_id_in_origin.
425 std::string raw_source_id; 426 std::string raw_source_id;
426 for (AudioDeviceNames::const_iterator it = source_devices_.begin(); 427 for (AudioDeviceNames::const_iterator it = source_devices_.begin();
427 it != source_devices_.end(); 428 it != source_devices_.end();
428 ++it) { 429 ++it) {
429 const std::string& id = it->unique_id; 430 const std::string& id = it->unique_id;
430 if (content::DoesMediaDeviceIDMatchHMAC( 431 if (content::DoesMediaDeviceIDMatchHMAC(
431 resource_context(), 432 resource_context()->GetMediaDeviceIDSalt(),
432 security_origin, 433 security_origin,
433 source_id_in_origin, 434 source_id_in_origin,
434 id)) { 435 id)) {
435 raw_source_id = id; 436 raw_source_id = id;
436 DVLOG(2) << "Found raw ID " << raw_source_id 437 DVLOG(2) << "Found raw ID " << raw_source_id
437 << " for source ID in origin " << source_id_in_origin; 438 << " for source ID in origin " << source_id_in_origin;
438 break; 439 break;
439 } 440 }
440 } 441 }
441 442
(...skipping 23 matching lines...) Expand all
465 void WebrtcAudioPrivateGetAssociatedSinkFunction::OnHMACCalculated( 466 void WebrtcAudioPrivateGetAssociatedSinkFunction::OnHMACCalculated(
466 const std::string& associated_sink_id) { 467 const std::string& associated_sink_id) {
467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
468 469
469 results_.reset( 470 results_.reset(
470 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); 471 wap::GetAssociatedSink::Results::Create(associated_sink_id).release());
471 SendResponse(true); 472 SendResponse(true);
472 } 473 }
473 474
474 } // namespace extensions 475 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698