| 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_update_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_update_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/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "components/safe_browsing_db/safebrowsing.pb.h" | 14 #include "components/safe_browsing_db/safebrowsing.pb.h" |
| 15 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
| 17 #include "net/http/http_status_code.h" | 17 #include "net/http/http_status_code.h" |
| 18 #include "net/url_request/url_fetcher.h" | 18 #include "net/url_request/url_fetcher.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 list_update_request->set_threat_type(list_to_update.threat_type); | 208 list_update_request->set_threat_type(list_to_update.threat_type); |
| 209 | 209 |
| 210 if (!state.empty()) { | 210 if (!state.empty()) { |
| 211 list_update_request->set_state(state); | 211 list_update_request->set_state(state); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Serialize and Base64 encode. | 215 // Serialize and Base64 encode. |
| 216 std::string req_data, req_base64; | 216 std::string req_data, req_base64; |
| 217 request.SerializeToString(&req_data); | 217 request.SerializeToString(&req_data); |
| 218 base::Base64Encode(req_data, &req_base64); | 218 base::Base64UrlEncode(req_data, base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
| 219 | 219 &req_base64); |
| 220 return req_base64; | 220 return req_base64; |
| 221 } | 221 } |
| 222 | 222 |
| 223 bool V4UpdateProtocolManager::ParseUpdateResponse( | 223 bool V4UpdateProtocolManager::ParseUpdateResponse( |
| 224 const std::string& data, | 224 const std::string& data, |
| 225 std::vector<ListUpdateResponse>* list_update_responses) { | 225 std::vector<ListUpdateResponse>* list_update_responses) { |
| 226 FetchThreatListUpdatesResponse response; | 226 FetchThreatListUpdatesResponse response; |
| 227 | 227 |
| 228 if (!response.ParseFromString(data)) { | 228 if (!response.ParseFromString(data)) { |
| 229 RecordParseUpdateResult(PARSE_FROM_STRING_ERROR); | 229 RecordParseUpdateResult(PARSE_FROM_STRING_ERROR); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 void V4UpdateProtocolManager::GetUpdateUrlAndHeaders( | 343 void V4UpdateProtocolManager::GetUpdateUrlAndHeaders( |
| 344 const std::string& req_base64, | 344 const std::string& req_base64, |
| 345 GURL* gurl, | 345 GURL* gurl, |
| 346 net::HttpRequestHeaders* headers) const { | 346 net::HttpRequestHeaders* headers) const { |
| 347 V4ProtocolManagerUtil::GetRequestUrlAndHeaders( | 347 V4ProtocolManagerUtil::GetRequestUrlAndHeaders( |
| 348 req_base64, "threatListUpdates:fetch", config_, gurl, headers); | 348 req_base64, "threatListUpdates:fetch", config_, gurl, headers); |
| 349 } | 349 } |
| 350 | 350 |
| 351 } // namespace safe_browsing | 351 } // namespace safe_browsing |
| OLD | NEW |