diff options
author | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 16:14:25 +0000 |
---|---|---|
committer | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 16:14:25 +0000 |
commit | 7662cc667ee6fe2e4f3ad12e4448f863f4251ea2 (patch) | |
tree | 1045132653c440dfb33368a2e3fff4317bb85f9b /chrome/browser/media/media_internals.cc | |
parent | 83b688a50b68a88e9572835248cc62738ec82004 (diff) | |
download | chromium_src-7662cc667ee6fe2e4f3ad12e4448f863f4251ea2.zip chromium_src-7662cc667ee6fe2e4f3ad12e4448f863f4251ea2.tar.gz chromium_src-7662cc667ee6fe2e4f3ad12e4448f863f4251ea2.tar.bz2 |
This CL is part of https://codereview.chromium.org/11316275/, but only contains the changes related to the infobar.
The new design for the media infobar included in this patch:
# Use the confirm infobar for media, this will make the media infobar be consistent with other infobars in chrome like Geolocation.
# Remove the devices array in the media_stream_request since the infobar does not have a device dropdown any more.
# "Allow" will be sticky by default.
# Start using the device selection UI in the content settings.
Note, "Deny" is not sticky in this patch, it can't be done since the media code in content settings needs a big refactoring to handle the exceptions properly. It will be addressed in another CL.
BUG=163895
TEST=content_unittests, pyauto webrtc functional tests.
and manual tests like:
select a device via content setting media
go to https://webrtc-demos.appspot.com/html/pc1.html, and make a call.
Review URL: https://chromiumcodereview.appspot.com/11434084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/media/media_internals.cc')
-rw-r--r-- | chrome/browser/media/media_internals.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/chrome/browser/media/media_internals.cc b/chrome/browser/media/media_internals.cc index 7f6cb39..9559d80 100644 --- a/chrome/browser/media/media_internals.cc +++ b/chrome/browser/media/media_internals.cc @@ -10,6 +10,9 @@ #include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/media/media_internals_observer.h" #include "chrome/browser/media/media_stream_capture_indicator.h" +#include "chrome/browser/prefs/scoped_user_pref_update.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_ui.h" #include "media/base/media_log.h" @@ -17,6 +20,64 @@ using content::BrowserThread; +namespace media { + +namespace { + +const content::MediaStreamDevice* FindDefaultDeviceWithId( + const content::MediaStreamDevices& devices, + const std::string& device_id) { + if (devices.empty()) + return NULL; + + content::MediaStreamDevices::const_iterator iter = devices.begin(); + for (; iter != devices.end(); ++iter) { + if (iter->device_id == device_id) { + return &(*iter); + } + } + + return &(*devices.begin()); +}; + +} // namespace + +void GetDefaultDevicesForProfile(Profile* profile, + bool audio, + bool video, + content::MediaStreamDevices* devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(profile); + DCHECK(audio || video); + + MediaCaptureDevicesDispatcher* dispatcher = + MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher(); + PrefService* prefs = profile->GetPrefs(); + if (audio) { + std::string default_device; + default_device = prefs->GetString(prefs::kDefaultAudioCaptureDevice); + const content::MediaStreamDevices& audio_devices = + dispatcher->GetAudioCaptureDevices(); + const content::MediaStreamDevice* const device = + FindDefaultDeviceWithId(audio_devices, default_device); + if (device) + devices->push_back(*device); + } + + if (video) { + std::string default_device; + default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice); + const content::MediaStreamDevices& video_devices = + dispatcher->GetVideoCaptureDevices(); + const content::MediaStreamDevice* const device = + FindDefaultDeviceWithId(video_devices, default_device); + if (device) + devices->push_back(*device); + } +} + +} // namespace media + MediaInternals* MediaInternals::GetInstance() { return Singleton<MediaInternals>::get(); } |