| Index: chrome/browser/ui/screen_capture_infobar_delegate.cc | 
| diff --git a/chrome/browser/ui/screen_capture_infobar_delegate.cc b/chrome/browser/ui/screen_capture_infobar_delegate.cc | 
| index 3ff83c3c1116670ed3fddd6472079adff1b175d1..b451e0cfaa2ec6bec37dd6176f29eae9e0fc8627 100644 | 
| --- a/chrome/browser/ui/screen_capture_infobar_delegate.cc | 
| +++ b/chrome/browser/ui/screen_capture_infobar_delegate.cc | 
| @@ -4,77 +4,30 @@ | 
|  | 
| #include "chrome/browser/ui/screen_capture_infobar_delegate.h" | 
|  | 
| -#include "base/command_line.h" | 
| -#include "base/utf_string_conversions.h" | 
| #include "chrome/browser/api/infobars/infobar_service.h" | 
| -#include "chrome/common/chrome_switches.h" | 
| +#include "chrome/browser/ui/screen_capture_confirmation_ui_infobar.h" | 
| #include "grit/generated_resources.h" | 
| #include "ui/base/l10n/l10n_util.h" | 
|  | 
| -namespace { | 
| - | 
| -// This is a short-term solution to allow testing of the the Screen Capture API | 
| -// with Google Hangouts in M27. | 
| -// TODO(sergeyu): Remove this whitelist as soon as possible. | 
| -bool IsWhitelistedOrigin(const GURL& origin) { | 
| -#if defined(OFFICIAL_BUILD) | 
| -  return origin.spec() == "https://staging.talkgadget.google.com/" || | 
| -      origin.spec() == "https://plus.google.com/"; | 
| -#else | 
| -  return false; | 
| -#endif | 
| -} | 
| - | 
| -}  // namespace | 
| - | 
| -// static | 
| -void ScreenCaptureInfoBarDelegate::Create( | 
| -    content::WebContents* web_contents, | 
| -    const content::MediaStreamRequest& request, | 
| -    const content::MediaResponseCallback& callback) { | 
| -  bool screen_capture_enabled = CommandLine::ForCurrentProcess()->HasSwitch( | 
| -      switches::kEnableUserMediaScreenCapturing) || | 
| -      IsWhitelistedOrigin(request.security_origin); | 
| -  // Deny request automatically in the following cases: | 
| -  //  1. Screen capturing is not enabled via command line switch. | 
| -  //  2. Audio capture was requested (it's not supported yet). | 
| -  //  3. Request from a page that was not loaded from a secure origin. | 
| -  if (!screen_capture_enabled || | 
| -      request.audio_type != content::MEDIA_NO_SERVICE || | 
| -      !request.security_origin.SchemeIsSecure()) { | 
| -    callback.Run(content::MediaStreamDevices()); | 
| -    return; | 
| -  } | 
| - | 
| -  InfoBarService* infobar_service = | 
| -      InfoBarService::FromWebContents(web_contents); | 
| -  infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 
| -      new ScreenCaptureInfoBarDelegate(infobar_service, request, callback))); | 
| -} | 
| - | 
| ScreenCaptureInfoBarDelegate::ScreenCaptureInfoBarDelegate( | 
| InfoBarService* infobar_service, | 
| -    const content::MediaStreamRequest& request, | 
| -    const content::MediaResponseCallback& callback) | 
| +    const string16& page_title, | 
| +    ScreenCaptureConfirmationUIInfobar* result_handler) | 
| : ConfirmInfoBarDelegate(infobar_service), | 
| -      request_(request), | 
| -      callback_(callback) { | 
| -  DCHECK_EQ(content::MEDIA_SCREEN_VIDEO_CAPTURE, request.video_type); | 
| +      result_handler_(result_handler), | 
| +      page_title_(page_title) { | 
| } | 
|  | 
| ScreenCaptureInfoBarDelegate::~ScreenCaptureInfoBarDelegate() { | 
| -} | 
| - | 
| -// Needed to avoid having more than one infobar with the same request. | 
| -bool ScreenCaptureInfoBarDelegate::EqualsDelegate( | 
| -    InfoBarDelegate* delegate) const { | 
| -  ScreenCaptureInfoBarDelegate* other = | 
| -      delegate->AsScreenCaptureInfoBarDelegate(); | 
| -  return other && other->request_.security_origin == request_.security_origin; | 
| +  // Notify the handler if it hasn't been notified yet (e.g. if the tab is being | 
| +  // closed). | 
| +  if (result_handler_) | 
| +    result_handler_->OnInfobarResult(false); | 
| } | 
|  | 
| void ScreenCaptureInfoBarDelegate::InfoBarDismissed() { | 
| -  Deny(); | 
| +  result_handler_->OnInfobarResult(false); | 
| +  result_handler_ = NULL; | 
| } | 
|  | 
| InfoBarDelegate::Type ScreenCaptureInfoBarDelegate::GetInfoBarType() const { | 
| @@ -87,9 +40,7 @@ ScreenCaptureInfoBarDelegate* | 
| } | 
|  | 
| string16 ScreenCaptureInfoBarDelegate::GetMessageText() const { | 
| -  return l10n_util::GetStringFUTF16( | 
| -      IDS_MEDIA_CAPTURE_SCREEN, | 
| -      UTF8ToUTF16(request_.security_origin.spec())); | 
| +  return l10n_util::GetStringFUTF16(IDS_MEDIA_CAPTURE_SCREEN, page_title_); | 
| } | 
|  | 
| string16 ScreenCaptureInfoBarDelegate::GetButtonLabel( | 
| @@ -99,21 +50,13 @@ string16 ScreenCaptureInfoBarDelegate::GetButtonLabel( | 
| } | 
|  | 
| bool ScreenCaptureInfoBarDelegate::Accept() { | 
| -  content::MediaStreamDevices devices; | 
| - | 
| -  // Add screen capturer source if it was requested. | 
| -  devices.push_back(content::MediaStreamDevice( | 
| -      content::MEDIA_SCREEN_VIDEO_CAPTURE, std::string(), "Screen")); | 
| - | 
| -  callback_.Run(devices); | 
| +  result_handler_->OnInfobarResult(true); | 
| +  result_handler_ = NULL; | 
| return true; | 
| } | 
|  | 
| bool ScreenCaptureInfoBarDelegate::Cancel() { | 
| -  Deny(); | 
| +  result_handler_->OnInfobarResult(false); | 
| +  result_handler_ = NULL; | 
| return true; | 
| } | 
| - | 
| -void ScreenCaptureInfoBarDelegate::Deny() { | 
| -  callback_.Run(content::MediaStreamDevices()); | 
| -} | 
|  |