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

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: addressed sky's comment and replaced "Do not allow any site to" with "Do not allow sites to" Created 8 years, 5 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
16 class MessageLoop;
17 class TabContents;
18 13
19 // This class configures an infobar shown when a page requests access to a 14 // 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 15 // 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 16 // 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 17 // buttons to give access to the selected devices to the page, or to deny access
23 // to them. 18 // to them.
24 class MediaStreamInfoBarDelegate : public InfoBarDelegate { 19 class MediaStreamInfoBarDelegate : public InfoBarDelegate {
25 public: 20 public:
21 // MediaStreamInfoBarDelegate takes the ownership of the |controller|.
26 MediaStreamInfoBarDelegate( 22 MediaStreamInfoBarDelegate(
27 InfoBarTabHelper* tab_helper, 23 InfoBarTabHelper* tab_helper,
28 const content::MediaStreamRequest* request, 24 MediaStreamDevicesController* controller);
29 const content::MediaResponseCallback& callback);
30 25
31 virtual ~MediaStreamInfoBarDelegate(); 26 virtual ~MediaStreamInfoBarDelegate();
32 27
33 // These tell whether the user has to select audio and/or video devices. 28 // These tell whether the user has to select audio and/or video devices.
34 bool has_audio() const { return has_audio_; } 29 bool HasAudio() const;
35 bool has_video() const { return has_video_; } 30 bool HasVideo() const;
36 31
37 // Returns lists of audio and/or video devices from which the user will have 32 // Returns lists of audio and/or video devices from which the user will have
38 // to choose. 33 // to choose.
39 content::MediaStreamDevices GetAudioDevices() const; 34 content::MediaStreamDevices GetAudioDevices() const;
40 content::MediaStreamDevices GetVideoDevices() const; 35 content::MediaStreamDevices GetVideoDevices() const;
41 36
42 // Returns the security origin (e.g. "www.html5rocks.com") at the origin 37 // Returns the security origin (e.g. "www.html5rocks.com") at the origin
43 // of this request. 38 // of this request.
44 const GURL& GetSecurityOrigin() const; 39 const GURL& GetSecurityOrigin() const;
45 40
41
46 // Callbacks to handle accepting devices or denying the request. |audio_id| 42 // 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. 43 // and |video_id| are the device IDs of the accepted audio and video devices.
44 // |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 45 // The |audio_id| or |video_id| values are ignored if the request did not ask
49 // for audio or video devices respectively. 46 // for audio or video devices respectively.
50 void Accept(const std::string& audio_id, const std::string& video_id); 47 void Accept(const std::string& audio_id,
48 const std::string& video_id,
49 bool always_allow);
51 void Deny(); 50 void Deny();
52 51
53 private: 52 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: 53 // InfoBarDelegate:
61 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; 54 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE;
62 virtual void InfoBarDismissed() OVERRIDE; 55 virtual void InfoBarDismissed() OVERRIDE;
63 virtual gfx::Image* GetIcon() const OVERRIDE; 56 virtual gfx::Image* GetIcon() const OVERRIDE;
64 virtual Type GetInfoBarType() const OVERRIDE; 57 virtual Type GetInfoBarType() const OVERRIDE;
65 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE; 58 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE;
66 59
67 // The original request for access to devices.
68 const content::MediaStreamRequest* request_;
69 60
70 // The callback that needs to be Run to notify WebRTC of whether access to 61 private:
71 // audio/video devices was granted or not. 62 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 63
78 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate); 64 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate);
79 }; 65 };
80 66
81 #endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_ 67 #endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.cc ('k') | chrome/browser/ui/media_stream_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698