| 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..062d2905595b1e29a5df60b04bf5083290cb6eab
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/screen_capture_confirmation_ui_infobar.cc
|
| @@ -0,0 +1,42 @@
|
| +// 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)),
|
| + delegate_(NULL) {
|
| +}
|
| +
|
| +ScreenCaptureConfirmationUIInfobar::~ScreenCaptureConfirmationUIInfobar() {
|
| + if (delegate_)
|
| + infobar_service_->RemoveInfoBar(delegate_);
|
| +}
|
| +
|
| +bool ScreenCaptureConfirmationUIInfobar::Show(
|
| + const ResultCallback& result_callback,
|
| + const string16& title) {
|
| + if (!infobar_service_)
|
| + return false;
|
| + result_callback_ = result_callback;
|
| + scoped_ptr<ScreenCaptureInfoBarDelegate> delegate(
|
| + new ScreenCaptureInfoBarDelegate(infobar_service_, title, 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);
|
| +}
|
|
|