Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / android / deferred_download_observer.cc
blobb1c6c7de9d277c921b3db40d820bf18ad5a2cff2
1 // Copyright 2015 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.
5 #include "content/browser/android/deferred_download_observer.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "content/browser/android/download_controller_android_impl.h"
9 #include "content/public/browser/web_contents.h"
11 namespace content {
13 DeferredDownloadObserver::DeferredDownloadObserver(
14 WebContents* web_contents,
15 const base::Closure& deferred_download_cb)
16 : WebContentsObserver(web_contents),
17 deferred_download_cb_(deferred_download_cb) {
20 DeferredDownloadObserver::~DeferredDownloadObserver() {}
22 void DeferredDownloadObserver::WasShown() {
23 deferred_download_cb_.Run();
24 DownloadControllerAndroidImpl::GetInstance()->CancelDeferredDownload(this);
27 void DeferredDownloadObserver::WebContentsDestroyed() {
28 DownloadControllerAndroidImpl::GetInstance()->CancelDeferredDownload(this);
31 } // namespace content