| 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 <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 bool callback_called() { return callback_called_; } | 134 bool callback_called() { return callback_called_; } |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 static std::string GetV4HashResponse( | 137 static std::string GetV4HashResponse( |
| 138 std::vector<ResponseInfo> response_infos) { | 138 std::vector<ResponseInfo> response_infos) { |
| 139 FindFullHashesResponse res; | 139 FindFullHashesResponse res; |
| 140 res.mutable_negative_cache_duration()->set_seconds(600); | 140 res.mutable_negative_cache_duration()->set_seconds(600); |
| 141 for (const ResponseInfo& info : response_infos) { | 141 for (const ResponseInfo& info : response_infos) { |
| 142 ThreatMatch* m = res.add_matches(); | 142 ThreatMatch* m = res.add_matches(); |
| 143 m->set_platform_type(info.list_id.platform_type); | 143 m->set_platform_type(info.list_id.platform_type()); |
| 144 m->set_threat_entry_type(info.list_id.threat_entry_type); | 144 m->set_threat_entry_type(info.list_id.threat_entry_type()); |
| 145 m->set_threat_type(info.list_id.threat_type); | 145 m->set_threat_type(info.list_id.threat_type()); |
| 146 m->mutable_cache_duration()->set_seconds(300); | 146 m->mutable_cache_duration()->set_seconds(300); |
| 147 m->mutable_threat()->set_hash(info.full_hash); | 147 m->mutable_threat()->set_hash(info.full_hash); |
| 148 | 148 |
| 149 for (const KeyValue& key_value : info.key_values) { | 149 for (const KeyValue& key_value : info.key_values) { |
| 150 ThreatEntryMetadata::MetadataEntry* e = | 150 ThreatEntryMetadata::MetadataEntry* e = |
| 151 m->mutable_threat_entry_metadata()->add_entries(); | 151 m->mutable_threat_entry_metadata()->add_entries(); |
| 152 e->set_key(key_value.key); | 152 e->set_key(key_value.key); |
| 153 e->set_value(key_value.value); | 153 e->set_value(key_value.value); |
| 154 } | 154 } |
| 155 } | 155 } |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 full_hash = FullHash("Everything's shiny, Cap'n."); | 727 full_hash = FullHash("Everything's shiny, Cap'n."); |
| 728 info = ResponseInfo(full_hash, GetChromeUrlApiId()); | 728 info = ResponseInfo(full_hash, GetChromeUrlApiId()); |
| 729 info.key_values.emplace_back("permission", "GEOLOCATION"); | 729 info.key_values.emplace_back("permission", "GEOLOCATION"); |
| 730 infos.push_back(info); | 730 infos.push_back(info); |
| 731 SetupFetcherToReturnOKResponse(factory, infos); | 731 SetupFetcherToReturnOKResponse(factory, infos); |
| 732 | 732 |
| 733 EXPECT_TRUE(callback_called()); | 733 EXPECT_TRUE(callback_called()); |
| 734 } | 734 } |
| 735 | 735 |
| 736 } // namespace safe_browsing | 736 } // namespace safe_browsing |
| OLD | NEW |