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

Unified Diff: chrome/browser/download/download_manager.h

Issue 351029: Support dragging a virtual file out of the browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 12 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/download_file.cc ('k') | chrome/browser/download/download_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager.h
===================================================================
--- chrome/browser/download/download_manager.h (revision 35459)
+++ chrome/browser/download/download_manager.h (working copy)
@@ -95,6 +95,9 @@
public:
virtual void OnDownloadUpdated(DownloadItem* download) = 0;
+ // Called when a downloaded file has been completed.
+ virtual void OnDownloadFileCompleted(DownloadItem* download) = 0;
+
// Called when a downloaded file has been opened.
virtual void OnDownloadOpened(DownloadItem* download) = 0;
@@ -119,7 +122,8 @@
int request_id,
bool is_dangerous,
bool save_as,
- bool is_extension_install);
+ bool is_extension_install,
+ bool is_temporary);
~DownloadItem();
@@ -133,6 +137,9 @@
// Notifies our observers periodically.
void UpdateObservers();
+ // Notifies our observers the downloaded file has been completed.
+ void NotifyObserversDownloadFileCompleted();
+
// Notifies our observers the downloaded file has been opened.
void NotifyObserversDownloadOpened();
@@ -217,6 +224,12 @@
void set_original_name(const FilePath& name) { original_name_ = name; }
bool save_as() const { return save_as_; }
bool is_extension_install() const { return is_extension_install_; }
+ bool name_finalized() const { return name_finalized_; }
+ void set_name_finalized(bool name_finalized) {
+ name_finalized_ = name_finalized;
+ }
+ bool is_temporary() const { return is_temporary_; }
+ void set_is_temporary(bool is_temporary) { is_temporary_ = is_temporary; }
// Returns the file-name that should be reported to the user, which is
// file_name_ for safe downloads and original_name_ for dangerous ones with
@@ -305,6 +318,12 @@
// True if the item was downloaded for an extension installation.
bool is_extension_install_;
+ // True if the filename is finalized.
+ bool name_finalized_;
+
+ // True if the item was downloaded temporarily.
+ bool is_temporary_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadItem);
};
@@ -347,6 +366,10 @@
void GetDownloads(Observer* observer,
const std::wstring& search_text);
+ // Return all temporary downloads that reside in the specified directory.
+ void GetTemporaryDownloads(Observer* observer,
+ const FilePath& dir_path);
+
// Returns true if initialized properly.
bool Init(Profile* profile);
@@ -387,6 +410,15 @@
const std::string& referrer_encoding,
TabContents* tab_contents);
+ // Download the object at the URL and save it to the specified path. The
+ // download is treated as the temporary download and thus will not appear
+ // in the download history. Used in cases such as drag and drop.
+ void DownloadUrlToFile(const GURL& url,
+ const GURL& referrer,
+ const std::string& referrer_encoding,
+ const FilePath& save_file_path,
+ TabContents* tab_contents);
+
// Allow objects to observe the download creation process.
void AddObserver(Observer* observer);
@@ -440,7 +472,7 @@
bool IsExecutableFile(const FilePath& path) const;
// Tests if a file type is considered executable.
- bool IsExecutableExtension(const FilePath::StringType& extension) const;
+ static bool IsExecutableExtension(const FilePath::StringType& extension);
// Resets the automatic open preference.
void ResetAutoOpenFiles();
@@ -462,14 +494,21 @@
// Used to make sure we have a safe file extension and filename for a
// download. |file_name| can either be just the file name or it can be a
// full path to a file.
- void GenerateSafeFilename(const std::string& mime_type,
- FilePath* file_name);
+ static void GenerateSafeFileName(const std::string& mime_type,
+ FilePath* file_name);
// Runs the network cancel. Must be called on the IO thread.
static void OnCancelDownloadRequest(ResourceDispatcherHost* rdh,
int render_process_id,
int request_id);
+ // Create a file name based on the response from the server.
+ static void GenerateFileName(const GURL& url,
+ const std::string& content_disposition,
+ const std::string& referrer_charset,
+ const std::string& mime_type,
+ FilePath* generated_name);
+
private:
friend class base::RefCountedThreadSafe<DownloadManager>;
@@ -508,12 +547,13 @@
const base::Time remove_before);
// Create an extension based on the file name and mime type.
- void GenerateExtension(const FilePath& file_name,
- const std::string& mime_type,
- FilePath::StringType* generated_extension);
+ static void GenerateExtension(const FilePath& file_name,
+ const std::string& mime_type,
+ FilePath::StringType* generated_extension);
// Create a file name based on the response from the server.
- void GenerateFilename(DownloadCreateInfo* info, FilePath* generated_name);
+ static void GenerateFileNameFromInfo(DownloadCreateInfo* info,
+ FilePath* generated_name);
// Persist the automatic opening preference.
void SaveAutoOpens();
@@ -619,9 +659,6 @@
typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet;
AutoOpenSet auto_open_;
- // Set of file extensions that are executables and shouldn't be auto opened.
- std::set<std::string> exe_types_;
-
// Keep track of downloads that are completed before the user selects the
// destination, so that observers are appropriately notified of completion
// after this determination is made.
« no previous file with comments | « chrome/browser/download/download_file.cc ('k') | chrome/browser/download/download_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698