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 "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Seconds resolution is good enough so we ignore the nanos field. | 204 // Seconds resolution is good enough so we ignore the nanos field. |
205 result.cache_duration = | 205 result.cache_duration = |
206 base::TimeDelta::FromSeconds(match.cache_duration().seconds()); | 206 base::TimeDelta::FromSeconds(match.cache_duration().seconds()); |
207 } | 207 } |
208 | 208 |
209 // Different threat types will handle the metadata differently. | 209 // Different threat types will handle the metadata differently. |
210 if (match.threat_type() == API_ABUSE) { | 210 if (match.threat_type() == API_ABUSE) { |
211 if (match.has_platform_type() && | 211 if (match.has_platform_type() && |
212 match.platform_type() == CHROME_PLATFORM) { | 212 match.platform_type() == CHROME_PLATFORM) { |
213 if (match.has_threat_entry_metadata()) { | 213 if (match.has_threat_entry_metadata()) { |
214 // For API Abuse, store a csv of the returned permissions. | 214 // For API Abuse, store a list of the returned permissions. |
215 for (const ThreatEntryMetadata::MetadataEntry& m : | 215 for (const ThreatEntryMetadata::MetadataEntry& m : |
216 match.threat_entry_metadata().entries()) { | 216 match.threat_entry_metadata().entries()) { |
217 if (m.key() == "permission") { | 217 if (m.key() == "permission") { |
218 result.metadata += m.value() + ","; | 218 result.metadata.api_permissions.push_back(m.value()); |
219 } | 219 } |
220 } | 220 } |
221 } else { | 221 } else { |
222 RecordParseGetHashResult(NO_METADATA_ERROR); | 222 RecordParseGetHashResult(NO_METADATA_ERROR); |
223 return false; | 223 return false; |
224 } | 224 } |
225 } else { | 225 } else { |
226 RecordParseGetHashResult(UNEXPECTED_PLATFORM_TYPE_ERROR); | 226 RecordParseGetHashResult(UNEXPECTED_PLATFORM_TYPE_ERROR); |
227 return false; | 227 return false; |
228 } | 228 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 next_gethash_time_ = now + next; | 338 next_gethash_time_ = now + next; |
339 } | 339 } |
340 | 340 |
341 GURL V4GetHashProtocolManager::GetHashUrl(const std::string& req_base64) const { | 341 GURL V4GetHashProtocolManager::GetHashUrl(const std::string& req_base64) const { |
342 return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedFullHashes", | 342 return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedFullHashes", |
343 config_); | 343 config_); |
344 } | 344 } |
345 | 345 |
346 | 346 |
347 } // namespace safe_browsing | 347 } // namespace safe_browsing |
OLD | NEW |