| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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 #include "chrome/browser/ui/screen_capture_confirmation_ui_infobar.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/browser/api/infobars/infobar_service.h" |
| 9 #include "chrome/browser/ui/screen_capture_infobar_delegate.h" |
| 10 |
| 11 ScreenCaptureConfirmationUIInfobar::ScreenCaptureConfirmationUIInfobar( |
| 12 content::WebContents* web_contents) |
| 13 : infobar_service_(InfoBarService::FromWebContents(web_contents)), |
| 14 delegate_(NULL) { |
| 15 } |
| 16 |
| 17 ScreenCaptureConfirmationUIInfobar::~ScreenCaptureConfirmationUIInfobar() { |
| 18 if (delegate_) |
| 19 infobar_service_->RemoveInfoBar(delegate_); |
| 20 } |
| 21 |
| 22 bool ScreenCaptureConfirmationUIInfobar::Show( |
| 23 const ResultCallback& result_callback, |
| 24 const string16& title) { |
| 25 if (!infobar_service_) |
| 26 return false; |
| 27 result_callback_ = result_callback; |
| 28 scoped_ptr<ScreenCaptureInfoBarDelegate> delegate( |
| 29 new ScreenCaptureInfoBarDelegate(infobar_service_, title, this)); |
| 30 delegate_ = delegate.get(); |
| 31 infobar_service_->AddInfoBar(delegate.PassAs<InfoBarDelegate>()); |
| 32 return true; |
| 33 } |
| 34 |
| 35 void ScreenCaptureConfirmationUIInfobar::OnInfobarResult(bool allow) { |
| 36 DCHECK(!result_callback_.is_null()); |
| 37 |
| 38 ScreenCaptureConfirmationUI::ResultCallback callback = result_callback_; |
| 39 result_callback_.Reset(); |
| 40 delegate_ = NULL; |
| 41 callback.Run(allow ? ALLOW : DENY); |
| 42 } |
| OLD | NEW |