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