diff options
author | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 17:00:53 +0000 |
---|---|---|
committer | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 17:00:53 +0000 |
commit | 4afde5c8aaf0a8b0557c8627a1d633361be79190 (patch) | |
tree | cba802056227b4c9176abd2497bb9d7bc722da51 /chrome/browser/ui/media_stream_infobar_delegate.cc | |
parent | c1788f0e4ddda9a36b88731a786243f194394282 (diff) | |
download | chromium_src-4afde5c8aaf0a8b0557c8627a1d633361be79190.zip chromium_src-4afde5c8aaf0a8b0557c8627a1d633361be79190.tar.gz chromium_src-4afde5c8aaf0a8b0557c8627a1d633361be79190.tar.bz2 |
Feature1:
User goes to http://neave.com/webcam/html5/
The url displayed is the security origin, just like maps.google.com
User needs to allow or deny access to his camera and microphone. Some sites will require only the mic or only the webcam.
User can open an options drop down. The drop down needs to be clicked for every modification. A divide line separates microphones and webcams.
User can also decide to Always allow. The decision will also remember the devices chosen.
Details:
The "Always allow" option will remember both the decision and the devices chosen.
If "Always allow" is selected and Deny is pressed, access is denied. Upon the next visit, the infobar will be displayed again.
If a a website is Allowed and "Always allowed":
...And devices disappears from the computer. It will show the infobar and ask the user to choose devices.
Feature2:
Settings => Privacy => Content Settings
We want to add a new section called Media to cover the getUserMedia decisions.
And we are able to see and remove the exception lists there.
BUG=132075,10532048
TEST=go to https://apprtc.appspot.com; click "always allow this site to use this device" option; go to content setting/privacy/media, try ask/block settings and remove exceptions.
Review URL: https://chromiumcodereview.appspot.com/10537099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/media_stream_infobar_delegate.cc')
-rw-r--r-- | chrome/browser/ui/media_stream_infobar_delegate.cc | 97 |
1 files changed, 20 insertions, 77 deletions
diff --git a/chrome/browser/ui/media_stream_infobar_delegate.cc b/chrome/browser/ui/media_stream_infobar_delegate.cc index 91e5bea..3668a38 100644 --- a/chrome/browser/ui/media_stream_infobar_delegate.cc +++ b/chrome/browser/ui/media_stream_infobar_delegate.cc @@ -2,110 +2,53 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <algorithm> -#include <functional> +#include "chrome/browser/ui/media_stream_infobar_delegate.h" #include "base/logging.h" -#include "chrome/browser/ui/media_stream_infobar_delegate.h" -#include "content/public/common/media_stream_request.h" #include "googleurl/src/gurl.h" #include "grit/theme_resources_standard.h" #include "ui/base/resource/resource_bundle.h" -namespace { - -// A predicate that checks if a StreamDeviceInfo object has the same ID as the -// device ID specified at construction. -class DeviceIdEquals { - public: - explicit DeviceIdEquals(const std::string& device_id) - : device_id_(device_id) { - } - - bool operator() (const content::MediaStreamDevice& device) { - return device.device_id == device_id_; - } - - private: - std::string device_id_; -}; - -} // namespace - MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( InfoBarTabHelper* tab_helper, - const content::MediaStreamRequest* request, - const content::MediaResponseCallback& callback) + MediaStreamDevicesController* controller) : InfoBarDelegate(tab_helper), - request_(request), - callback_(callback) { - DCHECK(request_); - has_audio_ = request_->devices.count( - content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) != 0; - has_video_ = request_->devices.count( - content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) != 0; + controller_(controller) { + DCHECK(controller_.get()); +} + +MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {} + +bool MediaStreamInfoBarDelegate::HasAudio() const { + return controller_->has_audio(); } -MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() { +bool MediaStreamInfoBarDelegate::HasVideo() const { + return controller_->has_video(); } content::MediaStreamDevices MediaStreamInfoBarDelegate::GetAudioDevices() const { - if (!has_audio_) - return content::MediaStreamDevices(); - content::MediaStreamDeviceMap::const_iterator it = - request_->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); - DCHECK(it != request_->devices.end()); - return it->second; + return controller_->GetAudioDevices(); } content::MediaStreamDevices MediaStreamInfoBarDelegate::GetVideoDevices() const { - if (!has_video_) - return content::MediaStreamDevices(); - content::MediaStreamDeviceMap::const_iterator it = - request_->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); - DCHECK(it != request_->devices.end()); - return it->second; + return controller_->GetVideoDevices(); } const GURL& MediaStreamInfoBarDelegate::GetSecurityOrigin() const { - return request_->security_origin; + return controller_->GetSecurityOrigin(); } void MediaStreamInfoBarDelegate::Accept(const std::string& audio_id, - const std::string& video_id) { - content::MediaStreamDevices devices; - - if (has_audio_) { - AddDeviceWithId(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, - audio_id, &devices); - } - if (has_video_) { - AddDeviceWithId(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, - video_id, &devices); - } - - callback_.Run(devices); + const std::string& video_id, + bool always_allow) { + controller_->Accept(audio_id, video_id, always_allow); } void MediaStreamInfoBarDelegate::Deny() { - callback_.Run(content::MediaStreamDevices()); -} - -void MediaStreamInfoBarDelegate::AddDeviceWithId( - content::MediaStreamDeviceType type, - const std::string& id, - content::MediaStreamDevices* devices) { - DCHECK(devices); - content::MediaStreamDeviceMap::const_iterator device_it = - request_->devices.find(type); - if (device_it != request_->devices.end()) { - content::MediaStreamDevices::const_iterator it = std::find_if( - device_it->second.begin(), device_it->second.end(), DeviceIdEquals(id)); - if (it != device_it->second.end()) - devices->push_back(*it); - } + controller_->Deny(); } // MediaStreamInfoBarDelegate::CreateInfoBar is implemented in platform-specific @@ -118,7 +61,7 @@ void MediaStreamInfoBarDelegate::InfoBarDismissed() { } gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const { - return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(has_video_ ? + return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(HasVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA : IDR_INFOBAR_MEDIA_STREAM_MIC); } |