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

Side by Side Diff: chrome/browser/ui/media_stream_infobar_delegate.h

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

Powered by Google App Engine
This is Rietveld 408576698