OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Every file type should have exactly one setting, pre-filtered for this | 106 // Every file type should have exactly one setting, pre-filtered for this |
107 // platform. | 107 // platform. |
108 for (const auto& file_type : new_config->file_types()) { | 108 for (const auto& file_type : new_config->file_types()) { |
109 if (file_type.platform_settings().size() != 1) | 109 if (file_type.platform_settings().size() != 1) |
110 return UpdateResult::FAILED_WRONG_SETTINGS_COUNT; | 110 return UpdateResult::FAILED_WRONG_SETTINGS_COUNT; |
111 } | 111 } |
112 | 112 |
113 // Compare against existing config, if we have one. | 113 // Compare against existing config, if we have one. |
114 if (config_) { | 114 if (config_) { |
| 115 // If versions are equal, we skip the update but it's not really |
| 116 // a failure. |
| 117 if (new_config->version_id() == config_->version_id()) |
| 118 return UpdateResult::SKIPPED_VERSION_CHECK_EQUAL; |
| 119 |
115 // Check that version number increases | 120 // Check that version number increases |
116 if (new_config->version_id() <= config_->version_id()) | 121 if (new_config->version_id() <= config_->version_id()) |
117 return UpdateResult::FAILED_VERSION_CHECK; | 122 return UpdateResult::FAILED_VERSION_CHECK; |
118 | 123 |
119 // Check that we haven't dropped more than 1/2 the list. | 124 // Check that we haven't dropped more than 1/2 the list. |
120 if (new_config->file_types().size() * 2 < config_->file_types().size()) | 125 if (new_config->file_types().size() * 2 < config_->file_types().size()) |
121 return UpdateResult::FAILED_DELTA_CHECK; | 126 return UpdateResult::FAILED_DELTA_CHECK; |
122 } | 127 } |
123 | 128 |
124 // Looks good. Update our internal list. | 129 // Looks good. Update our internal list. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 225 } |
221 | 226 |
222 DownloadFileType::DangerLevel FileTypePolicies::GetFileDangerLevel( | 227 DownloadFileType::DangerLevel FileTypePolicies::GetFileDangerLevel( |
223 const base::FilePath& file) const { | 228 const base::FilePath& file) const { |
224 const std::string ext = CanonicalizedExtension(file); | 229 const std::string ext = CanonicalizedExtension(file); |
225 AutoLock lock(lock_); | 230 AutoLock lock(lock_); |
226 return PolicyForExtension(ext).platform_settings(0).danger_level(); | 231 return PolicyForExtension(ext).platform_settings(0).danger_level(); |
227 } | 232 } |
228 | 233 |
229 } // namespace safe_browsing | 234 } // namespace safe_browsing |
OLD | NEW |