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

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: 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" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "chrome/browser/infobars/infobar_delegate.h" 12 #include "chrome/browser/infobars/infobar_delegate.h"
13 #include "chrome/browser/media/media_stream_devices_prefs.h"
13 #include "content/public/browser/content_browser_client.h" 14 #include "content/public/browser/content_browser_client.h"
14 #include "content/public/common/media_stream_request.h" 15 #include "content/public/common/media_stream_request.h"
15 16
16 class MessageLoop; 17 class MessageLoop;
18 class PrefService;
17 class TabContents; 19 class TabContents;
18 typedef TabContents TabContentsWrapper; 20 typedef TabContents TabContentsWrapper;
19 21
20 // This class configures an infobar shown when a page requests access to a 22 // 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 23 // 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 24 // 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 25 // buttons to give access to the selected devices to the page, or to deny access
24 // to them. 26 // to them.
25 class MediaStreamInfoBarDelegate : public InfoBarDelegate { 27 class MediaStreamInfoBarDelegate : public InfoBarDelegate {
26 public: 28 public:
27 MediaStreamInfoBarDelegate( 29 MediaStreamInfoBarDelegate(
28 InfoBarTabHelper* tab_helper, 30 InfoBarTabHelper* tab_helper,
31 Profile* profile,
29 const content::MediaStreamRequest* request, 32 const content::MediaStreamRequest* request,
30 const content::MediaResponseCallback& callback); 33 const content::MediaResponseCallback& callback);
31 34
32 virtual ~MediaStreamInfoBarDelegate(); 35 virtual ~MediaStreamInfoBarDelegate();
33 36
34 // These tell whether the user has to select audio and/or video devices. 37 // These tell whether the user has to select audio and/or video devices.
35 bool has_audio() const { return has_audio_; } 38 bool has_audio() const { return has_audio_; }
36 bool has_video() const { return has_video_; } 39 bool has_video() const { return has_video_; }
37 40
38 // Returns lists of audio and/or video devices from which the user will have 41 // Returns lists of audio and/or video devices from which the user will have
39 // to choose. 42 // to choose.
40 content::MediaStreamDevices GetAudioDevices() const; 43 content::MediaStreamDevices GetAudioDevices() const;
41 content::MediaStreamDevices GetVideoDevices() const; 44 content::MediaStreamDevices GetVideoDevices() const;
42 45
43 // Returns the security origin (e.g. "www.html5rocks.com") at the origin 46 // Returns the security origin (e.g. "www.html5rocks.com") at the origin
44 // of this request. 47 // of this request.
45 const GURL& GetSecurityOrigin() const; 48 const GURL& GetSecurityOrigin() const;
46 49
50 // Returns true if we should show the infobar for this request, otherwise
51 // returns false.
52 bool ShouldShowInfoBar();
53
47 // Callbacks to handle accepting devices or denying the request. |audio_id| 54 // 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. 55 // and |video_id| are the device IDs of the accepted audio and video devices.
56 // |always_allow| is true if the option t
49 // The |audio_id| or |video_id| values are ignored if the request did not ask 57 // The |audio_id| or |video_id| values are ignored if the request did not ask
50 // for audio or video devices respectively. 58 // for audio or video devices respectively.
51 void Accept(const std::string& audio_id, const std::string& video_id); 59 void Accept(const std::string& audio_id, const std::string& video_id,
60 bool always_allow);
52 void Deny(); 61 void Deny();
53 62
54 private: 63 private:
64 // Gets an array of selected devices and add them to |devices| array.
65 void GetDevicesWithId(const std::string& audio_id,
66 const std::string& video_id,
67 content::MediaStreamDevices* devices);
68
55 // Finds a device in the current request with the specified |id| and |type|, 69 // Finds a device in the current request with the specified |id| and |type|,
56 // and adds it to the |devices| array. 70 // and adds it to the |devices| array.
57 void AddDeviceWithId(content::MediaStreamDeviceType type, 71 void AddDeviceWithId(content::MediaStreamDeviceType type,
58 const std::string& id, 72 const std::string& id,
59 content::MediaStreamDevices* devices); 73 content::MediaStreamDevices* devices);
60 74
75 // Gets the always allowed audio and/or video devices. This function is called
76 // by ShouldShowInfoBar().
77 // Returns true if the always allowed devices are available for this
78 // request, otherwise returns false.
79 bool GetAlwaysAllowedDevices(std::string* audio_id, std::string* video_id);
80
61 // InfoBarDelegate: 81 // InfoBarDelegate:
62 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; 82 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE;
63 virtual void InfoBarDismissed() OVERRIDE; 83 virtual void InfoBarDismissed() OVERRIDE;
64 virtual gfx::Image* GetIcon() const OVERRIDE; 84 virtual gfx::Image* GetIcon() const OVERRIDE;
65 virtual Type GetInfoBarType() const OVERRIDE; 85 virtual Type GetInfoBarType() const OVERRIDE;
66 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE; 86 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE;
67 87
68 // The original request for access to devices. 88 // The original request for access to devices.
69 const content::MediaStreamRequest* request_; 89 const content::MediaStreamRequest* request_;
70 90
71 // The callback that needs to be Run to notify WebRTC of whether access to 91 // The callback that needs to be Run to notify WebRTC of whether access to
72 // audio/video devices was granted or not. 92 // audio/video devices was granted or not.
73 content::MediaResponseCallback callback_; 93 content::MediaResponseCallback callback_;
74 94
75 // Whether the request is for audio and/or video devices. 95 // Whether the request is for audio and/or video devices.
76 bool has_audio_; 96 bool has_audio_;
77 bool has_video_; 97 bool has_video_;
78 98
99 private:
100 // The media stram capture devices related preferences.
101 MediaStreamDevicesPrefs prefs_;
102
79 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate); 103 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate);
80 }; 104 };
81 105
82 #endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_ 106 #endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698