| OLD | NEW | 
|    1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4 // |    4 // | 
|    5 // The DownloadManager object manages the process of downloading, including |    5 // The DownloadManager object manages the process of downloading, including | 
|    6 // updates to the history system and providing the information for displaying |    6 // updates to the history system and providing the information for displaying | 
|    7 // the downloads view in the Destinations tab. There is one DownloadManager per |    7 // the downloads view in the Destinations tab. There is one DownloadManager per | 
|    8 // active profile in Chrome. |    8 // active profile in Chrome. | 
|    9 // |    9 // | 
|   10 // Each download is represented by a DownloadItem, and all DownloadItems |   10 // Each download is represented by a DownloadItem, and all DownloadItems | 
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  412   FilePath download_path() { |  412   FilePath download_path() { | 
|  413     return FilePath::FromWStringHack(*download_path_); |  413     return FilePath::FromWStringHack(*download_path_); | 
|  414   } |  414   } | 
|  415  |  415  | 
|  416   // Clears the last download path, used to initialize "save as" dialogs. |  416   // Clears the last download path, used to initialize "save as" dialogs. | 
|  417   void ClearLastDownloadPath(); |  417   void ClearLastDownloadPath(); | 
|  418  |  418  | 
|  419   // Registers this file extension for automatic opening upon download |  419   // Registers this file extension for automatic opening upon download | 
|  420   // completion if 'open' is true, or prevents the extension from automatic |  420   // completion if 'open' is true, or prevents the extension from automatic | 
|  421   // opening if 'open' is false. |  421   // opening if 'open' is false. | 
|  422   void OpenFilesBasedOnExtension(const FilePath& path, bool open); |  422   void OpenFilesOfExtension(const FilePath::StringType& extension, bool open); | 
|  423  |  423  | 
|  424   // Tests if a file type should be opened automatically. |  424   // Tests if a file type should be opened automatically. | 
|  425   bool ShouldOpenFileBasedOnExtension(const FilePath& path) const; |  425   bool ShouldOpenFileExtension(const FilePath::StringType& extension); | 
|  426  |  426  | 
|  427   // Tests if we think the server means for this mime_type to be executable. |  427   // Tests if we think the server means for this mime_type to be executable. | 
|  428   static bool IsExecutableMimeType(const std::string& mime_type); |  428   static bool IsExecutableMimeType(const std::string& mime_type); | 
|  429  |  429  | 
|  430   // Tests if a file is considered executable, based on its type. |  | 
|  431   bool IsExecutableFile(const FilePath& path) const; |  | 
|  432  |  | 
|  433   // Tests if a file type is considered executable. |  430   // Tests if a file type is considered executable. | 
|  434   bool IsExecutableExtension(const FilePath::StringType& extension) const; |  431   bool IsExecutable(const FilePath::StringType& extension); | 
|  435  |  432  | 
|  436   // Resets the automatic open preference. |  433   // Resets the automatic open preference. | 
|  437   void ResetAutoOpenFiles(); |  434   void ResetAutoOpenFiles(); | 
|  438  |  435  | 
|  439   // Returns true if there are automatic handlers registered for any file |  436   // Returns true if there are automatic handlers registered for any file | 
|  440   // types. |  437   // types. | 
|  441   bool HasAutoOpenFileTypesRegistered() const; |  438   bool HasAutoOpenFileTypesRegistered() const; | 
|  442  |  439  | 
|  443   // Overridden from SelectFileDialog::Listener: |  440   // Overridden from SelectFileDialog::Listener: | 
|  444   virtual void FileSelected(const FilePath& path, int index, void* params); |  441   virtual void FileSelected(const FilePath& path, int index, void* params); | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  601  |  598  | 
|  602   // User preferences |  599   // User preferences | 
|  603   BooleanPrefMember prompt_for_download_; |  600   BooleanPrefMember prompt_for_download_; | 
|  604   StringPrefMember download_path_; |  601   StringPrefMember download_path_; | 
|  605  |  602  | 
|  606   // The user's last choice for download directory. This is only used when the |  603   // The user's last choice for download directory. This is only used when the | 
|  607   // user wants us to prompt for a save location for each download. |  604   // user wants us to prompt for a save location for each download. | 
|  608   FilePath last_download_path_; |  605   FilePath last_download_path_; | 
|  609  |  606  | 
|  610   // Set of file extensions to open at download completion. |  607   // Set of file extensions to open at download completion. | 
|  611   struct AutoOpenCompareFunctor { |  608   std::set<FilePath::StringType> auto_open_; | 
|  612     inline bool operator()(const FilePath::StringType& a, |  | 
|  613                            const FilePath::StringType& b) const { |  | 
|  614       return FilePath::CompareLessIgnoreCase(a, b); |  | 
|  615     } |  | 
|  616   }; |  | 
|  617   typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; |  | 
|  618   AutoOpenSet auto_open_; |  | 
|  619  |  609  | 
|  620   // Set of file extensions that are executables and shouldn't be auto opened. |  610   // Set of file extensions that are executables and shouldn't be auto opened. | 
|  621   std::set<std::string> exe_types_; |  611   std::set<std::string> exe_types_; | 
|  622  |  612  | 
|  623   // Keep track of downloads that are completed before the user selects the |  613   // Keep track of downloads that are completed before the user selects the | 
|  624   // destination, so that observers are appropriately notified of completion |  614   // destination, so that observers are appropriately notified of completion | 
|  625   // after this determination is made. |  615   // after this determination is made. | 
|  626   // The map is of download_id->remaining size (bytes), both of which are |  616   // The map is of download_id->remaining size (bytes), both of which are | 
|  627   // required when calling DownloadFinished. |  617   // required when calling DownloadFinished. | 
|  628   typedef std::map<int32, int64> PendingFinishedMap; |  618   typedef std::map<int32, int64> PendingFinishedMap; | 
|  629   PendingFinishedMap pending_finished_downloads_; |  619   PendingFinishedMap pending_finished_downloads_; | 
|  630  |  620  | 
|  631   // The "Save As" dialog box used to ask the user where a file should be |  621   // The "Save As" dialog box used to ask the user where a file should be | 
|  632   // saved. |  622   // saved. | 
|  633   scoped_refptr<SelectFileDialog> select_file_dialog_; |  623   scoped_refptr<SelectFileDialog> select_file_dialog_; | 
|  634  |  624  | 
|  635   DISALLOW_COPY_AND_ASSIGN(DownloadManager); |  625   DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 
|  636 }; |  626 }; | 
|  637  |  627  | 
|  638 #endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |  628 #endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 
| OLD | NEW |