| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "chrome/browser/prefs/pref_member.h" | 12 #include "chrome/browser/prefs/pref_member.h" |
| 13 | 13 |
| 14 namespace download_test_util { |
| 15 class ScopedDefaultDownloadDirectory; |
| 16 } |
| 17 |
| 14 class PrefService; | 18 class PrefService; |
| 15 | 19 |
| 16 // Stores all download-related preferences. | 20 // Stores all download-related preferences. |
| 17 class DownloadPrefs { | 21 class DownloadPrefs { |
| 18 public: | 22 public: |
| 19 explicit DownloadPrefs(PrefService* prefs); | 23 explicit DownloadPrefs(PrefService* prefs); |
| 20 ~DownloadPrefs(); | 24 ~DownloadPrefs(); |
| 21 | 25 |
| 22 static void RegisterUserPrefs(PrefService* prefs); | 26 static void RegisterUserPrefs(PrefService* prefs); |
| 23 | 27 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 41 | 45 |
| 42 // Enables auto-open based on file extension. Returns true on success. | 46 // Enables auto-open based on file extension. Returns true on success. |
| 43 // TODO(phajdan.jr): Add WARN_UNUSED_RESULT here. | 47 // TODO(phajdan.jr): Add WARN_UNUSED_RESULT here. |
| 44 bool EnableAutoOpenBasedOnExtension(const FilePath& file_name); | 48 bool EnableAutoOpenBasedOnExtension(const FilePath& file_name); |
| 45 | 49 |
| 46 // Disables auto-open based on file extension. | 50 // Disables auto-open based on file extension. |
| 47 void DisableAutoOpenBasedOnExtension(const FilePath& file_name); | 51 void DisableAutoOpenBasedOnExtension(const FilePath& file_name); |
| 48 | 52 |
| 49 void ResetAutoOpen(); | 53 void ResetAutoOpen(); |
| 50 | 54 |
| 55 FilePath GetDefaultDownloadDirectory(); |
| 56 |
| 51 private: | 57 private: |
| 58 friend class download_test_util::ScopedDefaultDownloadDirectory; |
| 59 |
| 52 void SaveAutoOpenState(); | 60 void SaveAutoOpenState(); |
| 53 | 61 |
| 62 // This method can be used only through ScopedDefaultDownloadDirectory. |
| 63 void OverrideDefaultDownloadDirectory( |
| 64 const FilePath& override_default_download_dir); |
| 65 |
| 66 // This method can be used only through ScopedDefaultDownloadDirectory. |
| 67 void UnOverrideDefaultDownloadDirectory(); |
| 68 |
| 54 PrefService* prefs_; | 69 PrefService* prefs_; |
| 55 | 70 |
| 56 BooleanPrefMember prompt_for_download_; | 71 BooleanPrefMember prompt_for_download_; |
| 57 FilePathPrefMember download_path_; | 72 FilePathPrefMember download_path_; |
| 58 IntegerPrefMember save_file_type_; | 73 IntegerPrefMember save_file_type_; |
| 74 FilePath override_default_download_dir_; |
| 59 | 75 |
| 60 // Set of file extensions to open at download completion. | 76 // Set of file extensions to open at download completion. |
| 61 struct AutoOpenCompareFunctor { | 77 struct AutoOpenCompareFunctor { |
| 62 bool operator()(const FilePath::StringType& a, | 78 bool operator()(const FilePath::StringType& a, |
| 63 const FilePath::StringType& b) const; | 79 const FilePath::StringType& b) const; |
| 64 }; | 80 }; |
| 65 typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; | 81 typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; |
| 66 AutoOpenSet auto_open_; | 82 AutoOpenSet auto_open_; |
| 67 | 83 |
| 68 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); | 84 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); |
| 69 }; | 85 }; |
| 70 | 86 |
| 71 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ | 87 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ |
| OLD | NEW |