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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_INFOBAR_DELEGATE_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 12 #include "chrome/browser/media/media_stream_devices_controller.h" 13 14 15 // This class configures an infobar shown when a page requests access to a 16 // user's microphone and/or video camera. The user is shown a message asking 17 // which audio and/or video devices he wishes to use with the current page, and 18 // buttons to give access to the selected devices to the page, or to deny access 19 // to them. 20 class MediaStreamInfoBarDelegate : public ConfirmInfoBarDelegate { 21 public: 22 virtual ~MediaStreamInfoBarDelegate(); 23 24 // Handles a permission request (in |request|) for |web_contents|. If this 25 // involves prompting the user, creates a media stream infobar delegate, then 26 // checks for an existing infobar for |web_contents| and replaces it if found, 27 // or just adds the new infobar otherwise. Returns whether an infobar was 28 // created. 29 static bool Create(content::WebContents* web_contents, 30 const content::MediaStreamRequest& request, 31 const content::MediaResponseCallback& callback); 32 33 private: 34 friend class WebRtcTestBase; 35 36 MediaStreamInfoBarDelegate( 37 InfoBarService* infobar_service, 38 scoped_ptr<MediaStreamDevicesController> controller); 39 40 // ConfirmInfoBarDelegate: 41 virtual void InfoBarDismissed() OVERRIDE; 42 virtual int GetIconID() const OVERRIDE; 43 virtual Type GetInfoBarType() const OVERRIDE; 44 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate() OVERRIDE; 45 virtual string16 GetMessageText() const OVERRIDE; 46 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 47 virtual bool Accept() OVERRIDE; 48 virtual bool Cancel() OVERRIDE; 49 virtual string16 GetLinkText() const OVERRIDE; 50 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 51 52 scoped_ptr<MediaStreamDevicesController> controller_; 53 54 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarDelegate); 55 }; 56 57 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_INFOBAR_DELEGATE_H_ 58