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

Side by Side Diff: chrome/common/safe_browsing/file_type_policies.cc

Issue 1982723002: Use FileTypePolicies for download danger classifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_policies
Patch Set: Fix bad rebase Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/common/safe_browsing/file_type_policies.h" 5 #include "chrome/common/safe_browsing/file_type_policies.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 AutoLock lock(lock_); 202 AutoLock lock(lock_);
203 return PolicyForExtension(ext).is_archive(); 203 return PolicyForExtension(ext).is_archive();
204 } 204 }
205 205
206 bool FileTypePolicies::IsCheckedBinaryFile(const base::FilePath& file) const { 206 bool FileTypePolicies::IsCheckedBinaryFile(const base::FilePath& file) const {
207 const std::string ext = CanonicalizedExtension(file); 207 const std::string ext = CanonicalizedExtension(file);
208 AutoLock lock(lock_); 208 AutoLock lock(lock_);
209 return PolicyForExtension(ext).ping_setting() == DownloadFileType::FULL_PING; 209 return PolicyForExtension(ext).ping_setting() == DownloadFileType::FULL_PING;
210 } 210 }
211 211
212 bool FileTypePolicies::IsAllowedToOpenAutomatically(
213 const base::FilePath& file) const {
214 const std::string ext = CanonicalizedExtension(file);
215 if (ext.empty())
216 return false;
217 AutoLock lock(lock_);
218 return PolicyForExtension(ext).platform_settings(0).auto_open_hint() ==
219 DownloadFileType::ALLOW_AUTO_OPEN;
220 }
221
222 DownloadFileType::DangerLevel FileTypePolicies::GetFileDangerLevel(
223 const base::FilePath& file) const {
224 const std::string ext = CanonicalizedExtension(file);
225 AutoLock lock(lock_);
226 return PolicyForExtension(ext).platform_settings(0).danger_level();
227 }
228
212 } // namespace safe_browsing 229 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/common/safe_browsing/file_type_policies.h ('k') | content/browser/download/download_stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698