summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_item.h
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 18:16:39 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 18:16:39 +0000
commitaa033af5a4a6415200781d0704a36fe724ecd803 (patch)
treed1e8b8bfc2fe0498e1720ac1147a48a75823ae27 /chrome/browser/download/download_item.h
parentbfb19b64630633eef3dd8fea3bb88bfb02485b67 (diff)
downloadchromium_src-aa033af5a4a6415200781d0704a36fe724ecd803.zip
chromium_src-aa033af5a4a6415200781d0704a36fe724ecd803.tar.gz
chromium_src-aa033af5a4a6415200781d0704a36fe724ecd803.tar.bz2
Download code cleanup:
- make the code more object-oriented, make the object expose less accessors - make some parts of code look more obvious, use existing helpers - make the public interfaces slightly better (less ctor parameters) - make some names slightly better TEST=unit_tests, browser_tests, ui_tests BUG=48913 Review URL: http://codereview.chromium.org/3029025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_item.h')
-rw-r--r--chrome/browser/download/download_item.h59
1 files changed, 33 insertions, 26 deletions
diff --git a/chrome/browser/download/download_item.h b/chrome/browser/download/download_item.h
index f8c71d0..1a9a5ef 100644
--- a/chrome/browser/download/download_item.h
+++ b/chrome/browser/download/download_item.h
@@ -65,33 +65,22 @@ class DownloadItem {
};
// Constructing from persistent store:
- explicit DownloadItem(const DownloadCreateInfo& info);
+ DownloadItem(DownloadManager* download_manager,
+ const DownloadCreateInfo& info);
- // Constructing from user action:
- DownloadItem(int32 download_id,
+ // Constructing for a regular download:
+ DownloadItem(DownloadManager* download_manager,
+ const DownloadCreateInfo& info,
+ bool is_otr);
+
+ // Constructing for the "Save Page As..." feature:
+ DownloadItem(DownloadManager* download_manager,
const FilePath& path,
- int path_uniquifier,
const GURL& url,
- const GURL& referrer_url,
- const std::string& mime_type,
- const std::string& original_mime_type,
- const FilePath& original_name,
- const base::Time start_time,
- int64 download_size,
- int render_process_id,
- int request_id,
- bool is_dangerous,
- bool save_as,
- bool is_otr,
- bool is_extension_install,
- bool is_temporary);
+ bool is_otr);
~DownloadItem();
- void Init(bool start_timer);
-
- // Public API
-
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -101,8 +90,26 @@ class DownloadItem {
// Notifies our observers the downloaded file has been completed.
void NotifyObserversDownloadFileCompleted();
- // Notifies our observers the downloaded file has been opened.
- void NotifyObserversDownloadOpened();
+ // Whether it is OK to open this download.
+ bool CanOpenDownload();
+
+ // Tests if a file type should be opened automatically.
+ bool ShouldOpenFileBasedOnExtension();
+
+ // Registers this file extension for automatic opening upon download
+ // completion if 'open' is true, or prevents the extension from automatic
+ // opening if 'open' is false.
+ void OpenFilesBasedOnExtension(bool open);
+
+ // Open the file associated with this download (wait for the download to
+ // complete if it is in progress).
+ void OpenDownload();
+
+ // Show the download via the OS shell.
+ void ShowDownloadInShell();
+
+ // Called when the user has validated the download of a dangerous file.
+ void DangerousDownloadValidated();
// Received a new chunk of data
void Update(int64 bytes_so_far);
@@ -163,8 +170,6 @@ class DownloadItem {
base::Time start_time() const { return start_time_; }
void set_db_handle(int64 handle) { db_handle_ = handle; }
int64 db_handle() const { return db_handle_; }
- DownloadManager* manager() const { return manager_; }
- void set_manager(DownloadManager* manager) { manager_ = manager; }
bool is_paused() const { return is_paused_; }
void set_is_paused(bool pause) { is_paused_ = pause; }
bool open_when_complete() const { return open_when_complete_; }
@@ -194,6 +199,8 @@ class DownloadItem {
FilePath GetFileName() const;
private:
+ void Init(bool start_timer);
+
// Internal helper for maintaining consistent received and total sizes.
void UpdateSize(int64 size);
@@ -252,7 +259,7 @@ class DownloadItem {
base::RepeatingTimer<DownloadItem> update_timer_;
// Our owning object
- DownloadManager* manager_;
+ DownloadManager* download_manager_;
// In progress downloads may be paused by the user, we note it here
bool is_paused_;