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

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: use only content settings, added a device controller, addressed all the comments 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/content_browser_client.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 typedef TabContents TabContentsWrapper; 15 typedef TabContents TabContentsWrapper;
19 16
20 // This class configures an infobar shown when a page requests access to a 17 // This class configures an infobar shown when a page requests access to a
21 // user's microphone and/or video camera. The user is shown a message asking 18 // user's microphone and/or video camera. The user is shown a message asking
22 // which audio and/or video devices he wishes to use with the current page, and 19 // which audio and/or video devices he wishes to use with the current page, and
23 // buttons to give access to the selected devices to the page, or to deny access 20 // buttons to give access to the selected devices to the page, or to deny access
24 // to them. 21 // to them.
25 class MediaStreamInfoBarDelegate : public InfoBarDelegate { 22 class MediaStreamInfoBarDelegate : public InfoBarDelegate {
26 public: 23 public:
27 MediaStreamInfoBarDelegate( 24 MediaStreamInfoBarDelegate(
28 InfoBarTabHelper* tab_helper, 25 InfoBarTabHelper* tab_helper,
29 const content::MediaStreamRequest* request, 26 MediaStreamDevicesController* controller);
30 const content::MediaResponseCallback& callback);
31 27
32 virtual ~MediaStreamInfoBarDelegate(); 28 virtual ~MediaStreamInfoBarDelegate();
33 29
34 // These tell whether the user has to select audio and/or video devices. 30 // These tell whether the user has to select audio and/or video devices.
35 bool has_audio() const { return has_audio_; } 31 bool has_audio() const;
36 bool has_video() const { return has_video_; } 32 bool has_video() const;
Ivan Korotkov 2012/06/14 17:14:12 If it's easy to rename them to HasVideo/Audio, ple
no longer working on chromium 2012/06/15 16:52:07 Done.
37 33
38 // Returns lists of audio and/or video devices from which the user will have 34 // Returns lists of audio and/or video devices from which the user will have
39 // to choose. 35 // to choose.
40 content::MediaStreamDevices GetAudioDevices() const; 36 content::MediaStreamDevices GetAudioDevices() const;
41 content::MediaStreamDevices GetVideoDevices() const; 37 content::MediaStreamDevices GetVideoDevices() const;
42 38
43 // Returns the security origin (e.g. "www.html5rocks.com") at the origin 39 // Returns the security origin (e.g. "www.html5rocks.com") at the origin
44 // of this request. 40 // of this request.
45 const GURL& GetSecurityOrigin() const; 41 const GURL& GetSecurityOrigin() const;
46 42
43
47 // Callbacks to handle accepting devices or denying the request. |audio_id| 44 // Callbacks to handle accepting devices or denying the request. |audio_id|
48 // and |video_id| are the device IDs of the accepted audio and video devices. 45 // and |video_id| are the device IDs of the accepted audio and video devices.
46 // |always_allow| is true if the "always allow" option is checked.
49 // The |audio_id| or |video_id| values are ignored if the request did not ask 47 // The |audio_id| or |video_id| values are ignored if the request did not ask
50 // for audio or video devices respectively. 48 // for audio or video devices respectively.
51 void Accept(const std::string& audio_id, const std::string& video_id); 49 void Accept(const std::string& audio_id, const std::string& video_id,
Ivan Korotkov 2012/06/14 17:14:12 Should be one line per argument.
no longer working on chromium 2012/06/15 16:52:07 Done.
50 bool always_allow);
52 void Deny(); 51 void Deny();
53 52
54 private: 53 private:
55 // Finds a device in the current request with the specified |id| and |type|,
56 // and adds it to the |devices| array.
57 void AddDeviceWithId(content::MediaStreamDeviceType type,
58 const std::string& id,
59 content::MediaStreamDevices* devices);
60
61 // InfoBarDelegate: 54 // InfoBarDelegate:
62 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; 55 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE;
63 virtual void InfoBarDismissed() OVERRIDE; 56 virtual void InfoBarDismissed() OVERRIDE;
64 virtual gfx::Image* GetIcon() const OVERRIDE; 57 virtual gfx::Image* GetIcon() const OVERRIDE;
65 virtual Type GetInfoBarType() const OVERRIDE; 58 virtual Type GetInfoBarType() const OVERRIDE;
66 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE; 59 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE;
67 60
68 // The original request for access to devices.
69 const content::MediaStreamRequest* request_;
70 61
71 // The callback that needs to be Run to notify WebRTC of whether access to 62 private:
72 // audio/video devices was granted or not. 63 scoped_ptr<MediaStreamDevicesController> controller_;
73 content::MediaResponseCallback callback_;
74
75 // Whether the request is for audio and/or video devices.
76 bool has_audio_;
77 bool has_video_;
78 64
79 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate); 65 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate);
80 }; 66 };
81 67
82 #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