Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
|
no longer working on chromium
2012/06/20 17:24:38
To joaodasilva: We need to include this header fil
| |
| 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: |
| 26 MediaStreamInfoBarDelegate( | 21 MediaStreamInfoBarDelegate( |
| 27 InfoBarTabHelper* tab_helper, | 22 InfoBarTabHelper* tab_helper, |
| 28 const content::MediaStreamRequest* request, | 23 MediaStreamDevicesController* controller); |
| 29 const content::MediaResponseCallback& callback); | |
| 30 | 24 |
| 31 virtual ~MediaStreamInfoBarDelegate(); | 25 virtual ~MediaStreamInfoBarDelegate(); |
| 32 | 26 |
| 33 // These tell whether the user has to select audio and/or video devices. | 27 // These tell whether the user has to select audio and/or video devices. |
| 34 bool has_audio() const { return has_audio_; } | 28 bool HasAudio() const; |
| 35 bool has_video() const { return has_video_; } | 29 bool HasVideo() const; |
| 36 | 30 |
| 37 // Returns lists of audio and/or video devices from which the user will have | 31 // Returns lists of audio and/or video devices from which the user will have |
| 38 // to choose. | 32 // to choose. |
| 39 content::MediaStreamDevices GetAudioDevices() const; | 33 content::MediaStreamDevices GetAudioDevices() const; |
| 40 content::MediaStreamDevices GetVideoDevices() const; | 34 content::MediaStreamDevices GetVideoDevices() const; |
| 41 | 35 |
| 42 // Returns the security origin (e.g. "www.html5rocks.com") at the origin | 36 // Returns the security origin (e.g. "www.html5rocks.com") at the origin |
| 43 // of this request. | 37 // of this request. |
| 44 const GURL& GetSecurityOrigin() const; | 38 const GURL& GetSecurityOrigin() const; |
| 45 | 39 |
| 40 | |
| 46 // Callbacks to handle accepting devices or denying the request. |audio_id| | 41 // 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. | 42 // and |video_id| are the device IDs of the accepted audio and video devices. |
| 43 // |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 | 44 // The |audio_id| or |video_id| values are ignored if the request did not ask |
| 49 // for audio or video devices respectively. | 45 // for audio or video devices respectively. |
| 50 void Accept(const std::string& audio_id, const std::string& video_id); | 46 void Accept(const std::string& audio_id, |
| 47 const std::string& video_id, | |
| 48 bool always_allow); | |
| 51 void Deny(); | 49 void Deny(); |
| 52 | 50 |
| 53 private: | 51 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: | 52 // InfoBarDelegate: |
| 61 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; | 53 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; |
| 62 virtual void InfoBarDismissed() OVERRIDE; | 54 virtual void InfoBarDismissed() OVERRIDE; |
| 63 virtual gfx::Image* GetIcon() const OVERRIDE; | 55 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 64 virtual Type GetInfoBarType() const OVERRIDE; | 56 virtual Type GetInfoBarType() const OVERRIDE; |
| 65 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE; | 57 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE; |
| 66 | 58 |
| 67 // The original request for access to devices. | |
| 68 const content::MediaStreamRequest* request_; | |
| 69 | 59 |
| 70 // The callback that needs to be Run to notify WebRTC of whether access to | 60 private: |
| 71 // audio/video devices was granted or not. | 61 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 | 62 |
| 78 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate); |
| 79 }; | 64 }; |
| 80 | 65 |
| 81 #endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_ | 66 #endif // CHROME_BROWSER_UI_MEDIA_STREAM_INFOBAR_DELEGATE_H_ |
| OLD | NEW |