| 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 OpenFilesOfExtension(const FilePath::StringType& extension, bool open); | 422 void OpenFilesBasedOnExtension(const FilePath& path, 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 ShouldOpenFileExtension(const FilePath::StringType& extension); | 425 bool ShouldOpenFileBasedOnExtension(const FilePath& path) const; |
| 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 |
| 430 // Tests if a file type is considered executable. | 433 // Tests if a file type is considered executable. |
| 431 bool IsExecutable(const FilePath::StringType& extension); | 434 bool IsExecutableExtension(const FilePath::StringType& extension) const; |
| 432 | 435 |
| 433 // Resets the automatic open preference. | 436 // Resets the automatic open preference. |
| 434 void ResetAutoOpenFiles(); | 437 void ResetAutoOpenFiles(); |
| 435 | 438 |
| 436 // Returns true if there are automatic handlers registered for any file | 439 // Returns true if there are automatic handlers registered for any file |
| 437 // types. | 440 // types. |
| 438 bool HasAutoOpenFileTypesRegistered() const; | 441 bool HasAutoOpenFileTypesRegistered() const; |
| 439 | 442 |
| 440 // Overridden from SelectFileDialog::Listener: | 443 // Overridden from SelectFileDialog::Listener: |
| 441 virtual void FileSelected(const FilePath& path, int index, void* params); | 444 virtual void FileSelected(const FilePath& path, int index, void* params); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 601 |
| 599 // User preferences | 602 // User preferences |
| 600 BooleanPrefMember prompt_for_download_; | 603 BooleanPrefMember prompt_for_download_; |
| 601 StringPrefMember download_path_; | 604 StringPrefMember download_path_; |
| 602 | 605 |
| 603 // The user's last choice for download directory. This is only used when the | 606 // The user's last choice for download directory. This is only used when the |
| 604 // user wants us to prompt for a save location for each download. | 607 // user wants us to prompt for a save location for each download. |
| 605 FilePath last_download_path_; | 608 FilePath last_download_path_; |
| 606 | 609 |
| 607 // Set of file extensions to open at download completion. | 610 // Set of file extensions to open at download completion. |
| 608 std::set<FilePath::StringType> auto_open_; | 611 struct AutoOpenCompareFunctor { |
| 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_; |
| 609 | 619 |
| 610 // Set of file extensions that are executables and shouldn't be auto opened. | 620 // Set of file extensions that are executables and shouldn't be auto opened. |
| 611 std::set<std::string> exe_types_; | 621 std::set<std::string> exe_types_; |
| 612 | 622 |
| 613 // Keep track of downloads that are completed before the user selects the | 623 // Keep track of downloads that are completed before the user selects the |
| 614 // destination, so that observers are appropriately notified of completion | 624 // destination, so that observers are appropriately notified of completion |
| 615 // after this determination is made. | 625 // after this determination is made. |
| 616 // The map is of download_id->remaining size (bytes), both of which are | 626 // The map is of download_id->remaining size (bytes), both of which are |
| 617 // required when calling DownloadFinished. | 627 // required when calling DownloadFinished. |
| 618 typedef std::map<int32, int64> PendingFinishedMap; | 628 typedef std::map<int32, int64> PendingFinishedMap; |
| 619 PendingFinishedMap pending_finished_downloads_; | 629 PendingFinishedMap pending_finished_downloads_; |
| 620 | 630 |
| 621 // The "Save As" dialog box used to ask the user where a file should be | 631 // The "Save As" dialog box used to ask the user where a file should be |
| 622 // saved. | 632 // saved. |
| 623 scoped_refptr<SelectFileDialog> select_file_dialog_; | 633 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 624 | 634 |
| 625 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 635 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 626 }; | 636 }; |
| 627 | 637 |
| 628 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 638 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |