Chromium Code Reviews| 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 #include "chrome/browser/download/download_test_util.h" | |
|
Paweł Hajdan Jr.
2011/06/15 09:31:33
This #include shouldn't be here. I don't think it'
haraken1
2011/06/15 10:39:45
Done. Instead, I added "namespace download_test_ut
| |
| 13 | 14 |
| 14 class PrefService; | 15 class PrefService; |
| 15 | 16 |
| 16 // Stores all download-related preferences. | 17 // Stores all download-related preferences. |
| 17 class DownloadPrefs { | 18 class DownloadPrefs { |
| 18 public: | 19 public: |
| 19 explicit DownloadPrefs(PrefService* prefs); | 20 explicit DownloadPrefs(PrefService* prefs); |
| 20 ~DownloadPrefs(); | 21 ~DownloadPrefs(); |
| 21 | 22 |
| 22 static void RegisterUserPrefs(PrefService* prefs); | 23 static void RegisterUserPrefs(PrefService* prefs); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 41 | 42 |
| 42 // Enables auto-open based on file extension. Returns true on success. | 43 // Enables auto-open based on file extension. Returns true on success. |
| 43 // TODO(phajdan.jr): Add WARN_UNUSED_RESULT here. | 44 // TODO(phajdan.jr): Add WARN_UNUSED_RESULT here. |
| 44 bool EnableAutoOpenBasedOnExtension(const FilePath& file_name); | 45 bool EnableAutoOpenBasedOnExtension(const FilePath& file_name); |
| 45 | 46 |
| 46 // Disables auto-open based on file extension. | 47 // Disables auto-open based on file extension. |
| 47 void DisableAutoOpenBasedOnExtension(const FilePath& file_name); | 48 void DisableAutoOpenBasedOnExtension(const FilePath& file_name); |
| 48 | 49 |
| 49 void ResetAutoOpen(); | 50 void ResetAutoOpen(); |
| 50 | 51 |
| 52 FilePath GetDefaultDownloadDirectory(); | |
| 53 | |
| 51 private: | 54 private: |
| 55 friend class download_test_util::ScopedDefaultDownloadDirectory; | |
| 56 | |
| 52 void SaveAutoOpenState(); | 57 void SaveAutoOpenState(); |
| 53 | 58 |
| 59 // This method can be used only through ScopedDefaultDownloadDirectory. | |
| 60 void OverrideDefaultDownloadDirectory(const FilePath& override_path); | |
| 61 | |
| 62 // This method can be used only through ScopedDefaultDownloadDirectory. | |
| 63 void UnOverrideDefaultDownloadDirectory(); | |
| 64 | |
| 54 PrefService* prefs_; | 65 PrefService* prefs_; |
| 55 | 66 |
| 56 BooleanPrefMember prompt_for_download_; | 67 BooleanPrefMember prompt_for_download_; |
| 57 FilePathPrefMember download_path_; | 68 FilePathPrefMember download_path_; |
| 58 IntegerPrefMember save_file_type_; | 69 IntegerPrefMember save_file_type_; |
| 70 FilePath override_path_; | |
|
Paweł Hajdan Jr.
2011/06/15 09:31:33
nit: override_default_download_directory_? "path"
haraken1
2011/06/15 10:39:45
I renamed it to |override_default_download_dir_|.
| |
| 59 | 71 |
| 60 // Set of file extensions to open at download completion. | 72 // Set of file extensions to open at download completion. |
| 61 struct AutoOpenCompareFunctor { | 73 struct AutoOpenCompareFunctor { |
| 62 bool operator()(const FilePath::StringType& a, | 74 bool operator()(const FilePath::StringType& a, |
| 63 const FilePath::StringType& b) const; | 75 const FilePath::StringType& b) const; |
| 64 }; | 76 }; |
| 65 typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; | 77 typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; |
| 66 AutoOpenSet auto_open_; | 78 AutoOpenSet auto_open_; |
| 67 | 79 |
| 68 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); | 80 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); |
| 69 }; | 81 }; |
| 70 | 82 |
| 71 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ | 83 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ |
| OLD | NEW |