Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/download/download_prefs.h

Issue 2943763002: Add a new group policy to disable safe browsing for files downloaded from trusted sources. (Closed)
Patch Set: Fix an XML goof Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
8 #include <set> 9 #include <set>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "components/prefs/pref_member.h" 14 #include "components/prefs/pref_member.h"
14 15
15 class Profile; 16 class Profile;
17 class TrustedSourcesManager;
16 18
17 namespace content { 19 namespace content {
18 class BrowserContext; 20 class BrowserContext;
21 class DownloadItem;
19 class DownloadManager; 22 class DownloadManager;
20 } 23 }
21 24
22 namespace user_prefs { 25 namespace user_prefs {
23 class PrefRegistrySyncable; 26 class PrefRegistrySyncable;
24 } 27 }
25 28
26 // Stores all download-related preferences. 29 // Stores all download-related preferences.
27 class DownloadPrefs { 30 class DownloadPrefs {
28 public: 31 public:
(...skipping 14 matching lines...) Expand all
43 // Returns the default download directory for the current profile. 46 // Returns the default download directory for the current profile.
44 base::FilePath GetDefaultDownloadDirectoryForProfile() const; 47 base::FilePath GetDefaultDownloadDirectoryForProfile() const;
45 48
46 // Returns the DownloadPrefs corresponding to the given DownloadManager 49 // Returns the DownloadPrefs corresponding to the given DownloadManager
47 // or BrowserContext. 50 // or BrowserContext.
48 static DownloadPrefs* FromDownloadManager( 51 static DownloadPrefs* FromDownloadManager(
49 content::DownloadManager* download_manager); 52 content::DownloadManager* download_manager);
50 static DownloadPrefs* FromBrowserContext( 53 static DownloadPrefs* FromBrowserContext(
51 content::BrowserContext* browser_context); 54 content::BrowserContext* browser_context);
52 55
56 // Identify whether the downloaded item was downloaded from a trusted source.
57 bool IsFromTrustedSource(const content::DownloadItem& item);
58
53 base::FilePath DownloadPath() const; 59 base::FilePath DownloadPath() const;
54 void SetDownloadPath(const base::FilePath& path); 60 void SetDownloadPath(const base::FilePath& path);
55 base::FilePath SaveFilePath() const; 61 base::FilePath SaveFilePath() const;
56 void SetSaveFilePath(const base::FilePath& path); 62 void SetSaveFilePath(const base::FilePath& path);
57 int save_file_type() const { return *save_file_type_; } 63 int save_file_type() const { return *save_file_type_; }
58 void SetSaveFileType(int type); 64 void SetSaveFileType(int type);
59 DownloadRestriction download_restriction() const { 65 DownloadRestriction download_restriction() const {
60 return static_cast<DownloadRestriction>(*download_restriction_); 66 return static_cast<DownloadRestriction>(*download_restriction_);
61 } 67 }
68 bool safebrowsing_for_trusted_sources_enabled() const {
69 return *safebrowsing_for_trusted_sources_enabled_;
70 }
62 71
63 // Returns true if the prompt_for_download preference has been set and the 72 // Returns true if the prompt_for_download preference has been set and the
64 // download location is not managed (which means the user shouldn't be able 73 // download location is not managed (which means the user shouldn't be able
65 // to choose another download location). 74 // to choose another download location).
66 bool PromptForDownload() const; 75 bool PromptForDownload() const;
67 76
68 // Returns true if the download path preference is managed. 77 // Returns true if the download path preference is managed.
69 bool IsDownloadPathManaged() const; 78 bool IsDownloadPathManaged() const;
70 79
71 // Returns true if there is at least one file extension registered 80 // Returns true if there is at least one file extension registered
(...skipping 30 matching lines...) Expand all
102 private: 111 private:
103 void SaveAutoOpenState(); 112 void SaveAutoOpenState();
104 113
105 Profile* profile_; 114 Profile* profile_;
106 115
107 BooleanPrefMember prompt_for_download_; 116 BooleanPrefMember prompt_for_download_;
108 FilePathPrefMember download_path_; 117 FilePathPrefMember download_path_;
109 FilePathPrefMember save_file_path_; 118 FilePathPrefMember save_file_path_;
110 IntegerPrefMember save_file_type_; 119 IntegerPrefMember save_file_type_;
111 IntegerPrefMember download_restriction_; 120 IntegerPrefMember download_restriction_;
121 BooleanPrefMember safebrowsing_for_trusted_sources_enabled_;
122
123 // To identify if a download URL is from a trusted source.
124 std::unique_ptr<TrustedSourcesManager> trusted_sources_manager_;
112 125
113 // Set of file extensions to open at download completion. 126 // Set of file extensions to open at download completion.
114 struct AutoOpenCompareFunctor { 127 struct AutoOpenCompareFunctor {
115 bool operator()(const base::FilePath::StringType& a, 128 bool operator()(const base::FilePath::StringType& a,
116 const base::FilePath::StringType& b) const; 129 const base::FilePath::StringType& b) const;
117 }; 130 };
118 typedef std::set<base::FilePath::StringType, 131 typedef std::set<base::FilePath::StringType,
119 AutoOpenCompareFunctor> AutoOpenSet; 132 AutoOpenCompareFunctor> AutoOpenSet;
120 AutoOpenSet auto_open_; 133 AutoOpenSet auto_open_;
121 134
122 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) 135 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
123 bool should_open_pdf_in_system_reader_; 136 bool should_open_pdf_in_system_reader_;
124 #endif 137 #endif
125 138
126 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs); 139 DISALLOW_COPY_AND_ASSIGN(DownloadPrefs);
127 }; 140 };
128 141
129 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_ 142 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate_unittest.cc ('k') | chrome/browser/download/download_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698