Chromium Code Reviews| Index: chrome/browser/ui/screen_capture_confirmation_ui_infobar.cc |
| diff --git a/chrome/browser/ui/screen_capture_confirmation_ui_infobar.cc b/chrome/browser/ui/screen_capture_confirmation_ui_infobar.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..da09be682b01ded253edf89d2300b2727ed30ee8 |
| --- /dev/null |
| +++ b/chrome/browser/ui/screen_capture_confirmation_ui_infobar.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/screen_capture_confirmation_ui_infobar.h" |
| + |
| +#include "base/logging.h" |
| +#include "chrome/browser/api/infobars/infobar_service.h" |
| +#include "chrome/browser/ui/screen_capture_infobar_delegate.h" |
| + |
| +ScreenCaptureConfirmationUIInfobar::ScreenCaptureConfirmationUIInfobar( |
| + content::WebContents* web_contents) |
| + : infobar_service_(InfoBarService::FromWebContents(web_contents)), |
|
Nico
2013/03/22 18:39:55
nit: indent 2 more
Sergey Ulanov
2013/03/22 19:25:47
Done.
|
| + delegate_(NULL) { |
| +} |
| + |
| +ScreenCaptureConfirmationUIInfobar::~ScreenCaptureConfirmationUIInfobar() { |
| + if (delegate_) |
| + infobar_service_->RemoveInfoBar(delegate_); |
| +} |
| + |
| +bool ScreenCaptureConfirmationUIInfobar::Show( |
| + const ResultCallback& result_callback, |
| + const string16& application_name) { |
| + if (!infobar_service_) |
| + return false; |
| + result_callback_ = result_callback; |
| + scoped_ptr<ScreenCaptureInfoBarDelegate> delegate( |
| + new ScreenCaptureInfoBarDelegate(infobar_service_, application_name, |
| + this)); |
| + delegate_ = delegate.get(); |
| + infobar_service_->AddInfoBar(delegate.PassAs<InfoBarDelegate>()); |
| + return true; |
| +} |
| + |
| +void ScreenCaptureConfirmationUIInfobar::OnInfobarResult(bool allow) { |
| + DCHECK(!result_callback_.is_null()); |
| + |
| + ScreenCaptureConfirmationUI::ResultCallback callback = result_callback_; |
| + result_callback_.Reset(); |
| + delegate_ = NULL; |
| + callback.Run(allow ? ALLOW : DENY); |
| +} |