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

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

Issue 7277073: Support for adding save page download items into downloads history. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/save_package.h
===================================================================
--- content/browser/download/save_package.h (revision 95268)
+++ content/browser/download/save_package.h (working copy)
@@ -17,11 +17,10 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/task.h"
+#include "chrome/browser/download/download_manager.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
#include "googleurl/src/gurl.h"
-class DownloadItem;
-class DownloadManager;
class GURL;
class MessageLoop;
class PrefService;
@@ -53,6 +52,7 @@
// saving job, and exist for the duration of one tab's life time.
class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
public TabContentsObserver,
+ public DownloadItem::Observer,
public base::SupportsWeakPtr<SavePackage> {
public:
enum SavePackageType {
@@ -160,8 +160,18 @@
void DoSavingProcess();
// TabContentsObserver implementation.
- virtual bool OnMessageReceived(const IPC::Message& message);
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ // DownloadItem::Observer implementation.
+ virtual void OnDownloadUpdated(DownloadItem* download) OVERRIDE;
+ virtual void OnDownloadOpened(DownloadItem* download) OVERRIDE {}
+
+ // Update the download history of this item upon completion.
+ void FinalizeDownloadEntry();
+
+ // Detach from DownloadManager.
+ void StopObservation();
+
// Return max length of a path for a specific base directory.
// This is needed on POSIX, which restrict the length of file names in
// addition to the restriction on the length of path names.
@@ -211,10 +221,6 @@
const std::string& data,
int32 status);
- // Convenience function.
- DownloadManager* GetDownloadManager();
-
-
typedef base::hash_map<std::string, SaveItem*> SaveUrlItemMap;
// in_progress_items_ is map of all saving job in in-progress state.
SaveUrlItemMap in_progress_items_;
@@ -265,8 +271,8 @@
// Non-owning pointer for handling file writing on the file thread.
SaveFileManager* file_manager_;
- // We use a fake DownloadItem here in order to reuse the DownloadItemView.
- // This class owns the pointer.
+ // DownloadManager owns the DownloadItem and handles history and UI.
+ DownloadManager* download_manager_;
DownloadItem* download_;
// The URL of the page the user wants to save.
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698