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/base64url.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
15 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
16 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
18 | 18 |
19 using base::Time; | 19 using base::Time; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 info->add_platform_types(p); | 147 info->add_platform_types(p); |
148 } | 148 } |
149 for (const SBPrefix& prefix : prefixes) { | 149 for (const SBPrefix& prefix : prefixes) { |
150 std::string hash(reinterpret_cast<const char*>(&prefix), sizeof(SBPrefix)); | 150 std::string hash(reinterpret_cast<const char*>(&prefix), sizeof(SBPrefix)); |
151 info->add_threat_entries()->set_hash(hash); | 151 info->add_threat_entries()->set_hash(hash); |
152 } | 152 } |
153 | 153 |
154 // Serialize and Base64 encode. | 154 // Serialize and Base64 encode. |
155 std::string req_data, req_base64; | 155 std::string req_data, req_base64; |
156 req.SerializeToString(&req_data); | 156 req.SerializeToString(&req_data); |
157 base::Base64Encode(req_data, &req_base64); | 157 base::Base64UrlEncode(req_data, base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
158 | 158 &req_base64); |
159 return req_base64; | 159 return req_base64; |
160 } | 160 } |
161 | 161 |
162 bool V4GetHashProtocolManager::ParseHashResponse( | 162 bool V4GetHashProtocolManager::ParseHashResponse( |
163 const std::string& data, | 163 const std::string& data, |
164 std::vector<SBFullHashResult>* full_hashes, | 164 std::vector<SBFullHashResult>* full_hashes, |
165 base::Time* negative_cache_expire) { | 165 base::Time* negative_cache_expire) { |
166 FindFullHashesResponse response; | 166 FindFullHashesResponse response; |
167 | 167 |
168 if (!response.ParseFromString(data)) { | 168 if (!response.ParseFromString(data)) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 409 |
410 void V4GetHashProtocolManager::GetHashUrlAndHeaders( | 410 void V4GetHashProtocolManager::GetHashUrlAndHeaders( |
411 const std::string& req_base64, | 411 const std::string& req_base64, |
412 GURL* gurl, | 412 GURL* gurl, |
413 net::HttpRequestHeaders* headers) const { | 413 net::HttpRequestHeaders* headers) const { |
414 V4ProtocolManagerUtil::GetRequestUrlAndHeaders(req_base64, "fullHashes:find", | 414 V4ProtocolManagerUtil::GetRequestUrlAndHeaders(req_base64, "fullHashes:find", |
415 config_, gurl, headers); | 415 config_, gurl, headers); |
416 } | 416 } |
417 | 417 |
418 } // namespace safe_browsing | 418 } // namespace safe_browsing |
OLD | NEW |