Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: content/browser/download/save_package.cc

Issue 11640007: Make the UI an observer of downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android clang build Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/download/save_package.cc
diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc
index 6125ea571b81cd36b482f5840a6fe99346f19d22..45195e0298670937ce14de7d00143f0d40d6da03 100644
--- a/content/browser/download/save_package.cc
+++ b/content/browser/download/save_package.cc
@@ -105,6 +105,31 @@ bool CanSaveAsComplete(const std::string& contents_mime_type) {
contents_mime_type == "application/xhtml+xml";
}
+// Request handle for SavePackage downloads. Currently doesn't support
+// pause/resume/cancel, but returns a WebContents.
+class SavePackageRequestHandle : public DownloadRequestHandleInterface {
+ public:
+ SavePackageRequestHandle(base::WeakPtr<SavePackage> save_package)
+ : save_package_(save_package) {}
+
+ // DownloadRequestHandleInterface
+ virtual WebContents* GetWebContents() const OVERRIDE {
+ return save_package_.get() ? save_package_->web_contents() : NULL;
+ }
+ virtual DownloadManager* GetDownloadManager() const OVERRIDE {
+ return NULL;
+ }
+ virtual void PauseRequest() const OVERRIDE {}
+ virtual void ResumeRequest() const OVERRIDE {}
+ virtual void CancelRequest() const OVERRIDE {}
+ virtual std::string DebugString() const OVERRIDE {
+ return "SavePackage DownloadRequestHandle";
+ }
+
+ private:
+ base::WeakPtr<SavePackage> save_package_;
+};
+
} // namespace
const base::FilePath::CharType SavePackage::kDefaultHtmlExtension[] =
@@ -285,12 +310,15 @@ bool SavePackage::Init(
return false;
}
+ scoped_ptr<DownloadRequestHandleInterface> request_handle(
+ new SavePackageRequestHandle(AsWeakPtr()));
// The download manager keeps ownership but adds us as an observer.
download_ = download_manager_->CreateSavePackageDownloadItem(
saved_main_file_path_,
page_url_,
((save_type_ == SAVE_PAGE_TYPE_AS_MHTML) ?
"multipart/related" : "text/html"),
+ request_handle.Pass(),
this);
// Confirm above didn't delete the tab out from under us.
if (!download_created_callback.is_null())

Powered by Google App Engine
This is Rietveld 408576698