From a93670ab34b8f1cea9a9126f2bc97e3b4c4ec7dc Mon Sep 17 00:00:00 2001 From: "macourteau@chromium.org" Date: Fri, 24 Feb 2012 03:46:39 +0000 Subject: Preparation work for adding the Media Stream infobar. The behaviour is the same as without this patch (and everything is still behind a flag). BUG=105115 TEST= Review URL: http://codereview.chromium.org/9360018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123418 0039d316-1c4b-4281-b951-d872f2087c98 --- content/public/browser/content_browser_client.h | 13 +++++ content/public/common/media_stream_request.cc | 30 +++++++++++ content/public/common/media_stream_request.h | 72 +++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 content/public/common/media_stream_request.cc create mode 100644 content/public/common/media_stream_request.h (limited to 'content/public') diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index dab9721..bd7cff1a 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -12,6 +12,7 @@ #include "base/callback_forward.h" #include "content/public/common/content_client.h" +#include "content/public/common/media_stream_request.h" #include "content/public/common/window_container_type.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h" @@ -68,6 +69,9 @@ class BrowserContext; class ResourceContext; class WebUIControllerFactory; +typedef base::Callback< void(const content::MediaStreamDeviceArray&) > + MediaResponseCallback; + // Embedder API (or SPI) for participating in browser logic, to be implemented // by the client of the content browser. See ChromeContentBrowserClient for the // principal implementation. The methods are assumed to be called on the UI @@ -258,6 +262,15 @@ class ContentBrowserClient { int render_process_id, int render_view_id) = 0; + // Asks permission to use the camera and/or microphone. If permission is + // granted, a call should be made to |callback| with the devices. If the + // request is denied, a call should be made to |callback| with an empty list + // of devices. |request| has the details of the request (e.g. which of audio + // and/or video devices are requested, and lists of available devices). + virtual void RequestMediaAccessPermission( + const content::MediaStreamRequest* request, + const MediaResponseCallback& callback) = 0; + // Asks permission to show desktop notifications. virtual void RequestDesktopNotificationPermission( const GURL& source_origin, diff --git a/content/public/common/media_stream_request.cc b/content/public/common/media_stream_request.cc new file mode 100644 index 0000000..936094e --- /dev/null +++ b/content/public/common/media_stream_request.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/public/common/media_stream_request.h" + +namespace content { + +MediaStreamDevice::MediaStreamDevice( + MediaStreamDeviceType type, + const std::string& device_id, + const std::string& name) + : type(type), + device_id(device_id), + name(name) { +} + +MediaStreamRequest::MediaStreamRequest( + int render_process_id, + int render_view_id, + const std::string& security_origin) + : render_process_id(render_process_id), + render_view_id(render_view_id), + security_origin(security_origin) { +} + +MediaStreamRequest::~MediaStreamRequest() { +} + +} // namespace content diff --git a/content/public/common/media_stream_request.h b/content/public/common/media_stream_request.h new file mode 100644 index 0000000..7a5eceb --- /dev/null +++ b/content/public/common/media_stream_request.h @@ -0,0 +1,72 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_COMMON_MEDIA_STREAM_REQUEST_H_ +#define CONTENT_PUBLIC_COMMON_MEDIA_STREAM_REQUEST_H_ + +#include +#include +#include + +#include "base/basictypes.h" +#include "content/common/content_export.h" + +namespace content { + +// Types of media streams. +enum MediaStreamDeviceType { + MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE = 0, + MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, + MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, + NUM_MEDIA_STREAM_DEVICE_TYPES +}; + +// Represents one device in a request for media stream(s). +struct CONTENT_EXPORT MediaStreamDevice { + MediaStreamDevice( + MediaStreamDeviceType type, + const std::string& device_id, + const std::string& name); + + // The device's type. + MediaStreamDeviceType type; + + // The device's unique ID. + std::string device_id; + + // The device's "friendly" name. Not guaranteed to be unique. + std::string name; +}; + +typedef std::vector MediaStreamDeviceArray; + +typedef std::map + MediaStreamDeviceMap; + +// Represents a request for media streams (audio/video). +struct CONTENT_EXPORT MediaStreamRequest { + MediaStreamRequest( + int render_process_id, + int render_view_id, + const std::string& security_origin); + + ~MediaStreamRequest(); + + // The render process id generating this request. + int render_process_id; + + // The render view id generating this request. + int render_view_id; + + // The WebKit security origin for the current request (e.g. "html5rocks.com"). + std::string security_origin; + + // A list of devices present on the user's computer, for each device type + // requested. + MediaStreamDeviceMap devices; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_MEDIA_STREAM_REQUEST_H_ -- cgit v1.1