| 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 class PrefService; | 14 class PrefService; |
| 15 | 15 |
| 16 // Stores all download-related preferences. | 16 // Stores all download-related preferences. |
| 17 class DownloadPrefs { | 17 class DownloadPrefs { |
| 18 public: | 18 public: |
| 19 explicit DownloadPrefs(PrefService* prefs); | 19 explicit DownloadPrefs(PrefService* prefs); |
| 20 ~DownloadPrefs(); | 20 ~DownloadPrefs(); |
| 21 | 21 |
| 22 static void RegisterUserPrefs(PrefService* prefs); | 22 static void RegisterUserPrefs(PrefService* prefs); |
| 23 | 23 |
| 24 // Return the next download id and increment the counter. Must be called on |
| 25 // the UI thread. |
| 26 int GetNextId(); |
| 27 |
| 24 FilePath download_path() const { return *download_path_; } | 28 FilePath download_path() const { return *download_path_; } |
| 25 int save_file_type() const { return *save_file_type_; } | 29 int save_file_type() const { return *save_file_type_; } |
| 26 | 30 |
| 27 // Returns true if the prompt_for_download preference has been set and the | 31 // Returns true if the prompt_for_download preference has been set and the |
| 28 // download location is not managed (which means the user shouldn't be able | 32 // download location is not managed (which means the user shouldn't be able |
| 29 // to choose another download location). | 33 // to choose another download location). |
| 30 bool PromptForDownload() const; | 34 bool PromptForDownload() const; |
| 31 | 35 |
| 32 // Returns true if the download path preference is managed. | 36 // Returns true if the download path preference is managed. |
| 33 bool IsDownloadPathManaged() const; | 37 bool IsDownloadPathManaged() const; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 |
| 51 private: | 55 private: |
| 52 void SaveAutoOpenState(); | 56 void SaveAutoOpenState(); |
| 53 | 57 |
| 54 PrefService* prefs_; | 58 PrefService* prefs_; |
| 55 | 59 |
| 60 IntegerPrefMember next_download_id_; |
| 56 BooleanPrefMember prompt_for_download_; | 61 BooleanPrefMember prompt_for_download_; |
| 57 FilePathPrefMember download_path_; | 62 FilePathPrefMember download_path_; |
| 58 IntegerPrefMember save_file_type_; | 63 IntegerPrefMember save_file_type_; |
| 59 | 64 |
| 60 // Set of file extensions to open at download completion. | 65 // Set of file extensions to open at download completion. |
| 61 struct AutoOpenCompareFunctor { | 66 struct AutoOpenCompareFunctor { |
| 62 bool operator()(const FilePath::StringType& a, | 67 bool operator()(const FilePath::StringType& a, |
| 63 const FilePath::StringType& b) const; | 68 const FilePath::StringType& b) const; |
| 64 }; | 69 }; |
| 65 typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; | 70 typedef std::set<FilePath::StringType, AutoOpenCompareFunctor> AutoOpenSet; |
| 66 AutoOpenSet auto_open_; | 71 AutoOpenSet auto_open_; |
| 67 | 72 |
| 68 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); | 73 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); |
| 69 }; | 74 }; |
| 70 | 75 |
| 71 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ | 76 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ |
| OLD | NEW |