OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class DownloadPrefs { | 26 class DownloadPrefs { |
27 public: | 27 public: |
28 explicit DownloadPrefs(Profile* profile); | 28 explicit DownloadPrefs(Profile* profile); |
29 ~DownloadPrefs(); | 29 ~DownloadPrefs(); |
30 | 30 |
31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
32 | 32 |
33 // Returns the default download directory. | 33 // Returns the default download directory. |
34 static const base::FilePath& GetDefaultDownloadDirectory(); | 34 static const base::FilePath& GetDefaultDownloadDirectory(); |
35 | 35 |
| 36 #if defined(OS_WIN) |
| 37 // Returns true if it is known that Adobe Reader is up to date as of the |
| 38 // time of the most recent DownloadPrefs creation. |
| 39 static bool IsAdobeReaderUpToDate(); |
| 40 #endif |
| 41 |
36 // Returns the default download directory for the current profile. | 42 // Returns the default download directory for the current profile. |
37 base::FilePath GetDefaultDownloadDirectoryForProfile() const; | 43 base::FilePath GetDefaultDownloadDirectoryForProfile() const; |
38 | 44 |
39 // Returns the DownloadPrefs corresponding to the given DownloadManager | 45 // Returns the DownloadPrefs corresponding to the given DownloadManager |
40 // or BrowserContext. | 46 // or BrowserContext. |
41 static DownloadPrefs* FromDownloadManager( | 47 static DownloadPrefs* FromDownloadManager( |
42 content::DownloadManager* download_manager); | 48 content::DownloadManager* download_manager); |
43 static DownloadPrefs* FromBrowserContext( | 49 static DownloadPrefs* FromBrowserContext( |
44 content::BrowserContext* browser_context); | 50 content::BrowserContext* browser_context); |
45 | 51 |
(...skipping 20 matching lines...) Expand all Loading... |
66 // |path.Extension()|. | 72 // |path.Extension()|. |
67 bool IsAutoOpenEnabledBasedOnExtension(const base::FilePath& path) const; | 73 bool IsAutoOpenEnabledBasedOnExtension(const base::FilePath& path) const; |
68 | 74 |
69 // Enables auto-open based on file extension. Returns true on success. | 75 // Enables auto-open based on file extension. Returns true on success. |
70 // TODO(phajdan.jr): Add WARN_UNUSED_RESULT here. | 76 // TODO(phajdan.jr): Add WARN_UNUSED_RESULT here. |
71 bool EnableAutoOpenBasedOnExtension(const base::FilePath& file_name); | 77 bool EnableAutoOpenBasedOnExtension(const base::FilePath& file_name); |
72 | 78 |
73 // Disables auto-open based on file extension. | 79 // Disables auto-open based on file extension. |
74 void DisableAutoOpenBasedOnExtension(const base::FilePath& file_name); | 80 void DisableAutoOpenBasedOnExtension(const base::FilePath& file_name); |
75 | 81 |
| 82 #if defined(OS_WIN) |
| 83 // Store the user preference to disk. If |should_open| is true, also disable |
| 84 // the built-in PDF plugin. If |should_open| is false, enable the PDF plugin. |
| 85 void SetShouldOpenPdfInAdobeReader(bool should_open); |
| 86 |
| 87 // Return whether the user prefers to open PDF downloads in Adobe Reader. |
| 88 bool ShouldOpenPdfInAdobeReader() const; |
| 89 #endif |
| 90 |
76 void ResetAutoOpen(); | 91 void ResetAutoOpen(); |
77 | 92 |
78 private: | 93 private: |
79 void SaveAutoOpenState(); | 94 void SaveAutoOpenState(); |
80 | 95 |
81 Profile* profile_; | 96 Profile* profile_; |
82 | 97 |
83 BooleanPrefMember prompt_for_download_; | 98 BooleanPrefMember prompt_for_download_; |
84 FilePathPrefMember download_path_; | 99 FilePathPrefMember download_path_; |
85 FilePathPrefMember save_file_path_; | 100 FilePathPrefMember save_file_path_; |
86 IntegerPrefMember save_file_type_; | 101 IntegerPrefMember save_file_type_; |
87 | 102 |
88 // Set of file extensions to open at download completion. | 103 // Set of file extensions to open at download completion. |
89 struct AutoOpenCompareFunctor { | 104 struct AutoOpenCompareFunctor { |
90 bool operator()(const base::FilePath::StringType& a, | 105 bool operator()(const base::FilePath::StringType& a, |
91 const base::FilePath::StringType& b) const; | 106 const base::FilePath::StringType& b) const; |
92 }; | 107 }; |
93 typedef std::set<base::FilePath::StringType, | 108 typedef std::set<base::FilePath::StringType, |
94 AutoOpenCompareFunctor> AutoOpenSet; | 109 AutoOpenCompareFunctor> AutoOpenSet; |
95 AutoOpenSet auto_open_; | 110 AutoOpenSet auto_open_; |
96 | 111 |
| 112 #if defined(OS_WIN) |
| 113 bool should_open_pdf_in_adobe_reader_; |
| 114 #endif |
| 115 |
97 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); | 116 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); |
98 }; | 117 }; |
99 | 118 |
100 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ | 119 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ |
OLD | NEW |