blob: 2f5ebbda47645ca3fe53bfe486761597eaf62be4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// 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 CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_
#define CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_
#include <string>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "chrome/browser/infobars/infobar_delegate.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/media_stream_request.h"
class MessageLoop;
class TabContents;
// This class configures an infobar shown when a page requests access to a
// user's microphone and/or video camera. The user is shown a message asking
// which audio and/or video devices he wishes to use with the current page, and
// buttons to give access to the selected devices to the page, or to deny access
// to them.
class MediaStreamInfoBarDelegate : public InfoBarDelegate {
public:
MediaStreamInfoBarDelegate(
InfoBarTabHelper* tab_helper,
const content::MediaStreamRequest* request,
const content::MediaResponseCallback& callback);
virtual ~MediaStreamInfoBarDelegate();
// These tell whether the user has to select audio and/or video devices.
bool has_audio() const { return has_audio_; }
bool has_video() const { return has_video_; }
// Returns lists of audio and/or video devices from which the user will have
// to choose.
content::MediaStreamDevices GetAudioDevices() const;
content::MediaStreamDevices GetVideoDevices() const;
// Returns the security origin (e.g. "www.html5rocks.com") at the origin
// of this request.
const GURL& GetSecurityOrigin() const;
// Callbacks to handle accepting devices or denying the request. |audio_id|
// and |video_id| are the device IDs of the accepted audio and video devices.
// The |audio_id| or |video_id| values are ignored if the request did not ask
// for audio or video devices respectively.
void Accept(const std::string& audio_id, const std::string& video_id);
void Deny();
private:
// Finds a device in the current request with the specified |id| and |type|,
// and adds it to the |devices| array.
void AddDeviceWithId(content::MediaStreamDeviceType type,
const std::string& id,
content::MediaStreamDevices* devices);
// InfoBarDelegate:
virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE;
virtual void InfoBarDismissed() OVERRIDE;
virtual gfx::Image* GetIcon() const OVERRIDE;
virtual Type GetInfoBarType() const OVERRIDE;
virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE;
// The original request for access to devices.
const content::MediaStreamRequest* request_;
// The callback that needs to be Run to notify WebRTC of whether access to
// audio/video devices was granted or not.
content::MediaResponseCallback callback_;
// Whether the request is for audio and/or video devices.
bool has_audio_;
bool has_video_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate);
};
#endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_
|