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 #ifndef CONTENT_BROWSER_ANDROID_DEFERRED_DOWNLOAD_OBSERVER_H_
6 #define CONTENT_BROWSER_ANDROID_DEFERRED_DOWNLOAD_OBSERVER_H_
8 #include "base/callback.h"
9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "content/public/browser/web_contents_observer.h"
15 // Class for handling deferred downloads inside a WebContents. In document
16 // mode, it is possible that a download starts before ContentViewCore gets
17 // created. This class listens to the WebContentsObserver::WasShown() method
18 // before running the download tasks to make sure ContentViewCore is attached
20 // TODO(qinmin): Remove this when java Tab object creation is no longer pending
21 // on Activity creation.
22 class DeferredDownloadObserver
: public WebContentsObserver
{
24 DeferredDownloadObserver(WebContents
* web_contents
,
25 const base::Closure
& deferred_download_cb
);
26 ~DeferredDownloadObserver() override
;
28 // WebContentsObserver method.
29 void WasShown() override
;
30 void WebContentsDestroyed() override
;
33 // Callback to run when WebContents gets shown.
34 base::Closure deferred_download_cb_
;
36 DISALLOW_COPY_AND_ASSIGN(DeferredDownloadObserver
);
39 } // namespace content
41 #endif // CONTENT_BROWSER_ANDROID_DEFERRED_DOWNLOAD_OBSERVER_H_