| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/safe_browsing/safe_browsing_util.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Listnames that browser can process. | 157 // Listnames that browser can process. |
| 158 const char kMalwareList[] = "goog-malware-shavar"; | 158 const char kMalwareList[] = "goog-malware-shavar"; |
| 159 const char kPhishingList[] = "goog-phish-shavar"; | 159 const char kPhishingList[] = "goog-phish-shavar"; |
| 160 const char kBinUrlList[] = "goog-badbinurl-shavar"; | 160 const char kBinUrlList[] = "goog-badbinurl-shavar"; |
| 161 // We don't use the bad binary digest list anymore. Use a fake listname to be | 161 // We don't use the bad binary digest list anymore. Use a fake listname to be |
| 162 // sure we don't request it accidentally. | 162 // sure we don't request it accidentally. |
| 163 const char kBinHashList[] = "goog-badbin-digestvar-disabled"; | 163 const char kBinHashList[] = "goog-badbin-digestvar-disabled"; |
| 164 const char kCsdWhiteList[] = "goog-csdwhite-sha256"; | 164 const char kCsdWhiteList[] = "goog-csdwhite-sha256"; |
| 165 const char kDownloadWhiteList[] = "goog-downloadwhite-digest256"; | 165 const char kDownloadWhiteList[] = "goog-downloadwhite-digest256"; |
| 166 | 166 |
| 167 int GetListId(const std::string& name) { | 167 ListType GetListId(const std::string& name) { |
| 168 int id; | 168 ListType id; |
| 169 if (name == safe_browsing_util::kMalwareList) { | 169 if (name == safe_browsing_util::kMalwareList) { |
| 170 id = MALWARE; | 170 id = MALWARE; |
| 171 } else if (name == safe_browsing_util::kPhishingList) { | 171 } else if (name == safe_browsing_util::kPhishingList) { |
| 172 id = PHISH; | 172 id = PHISH; |
| 173 } else if (name == safe_browsing_util::kBinUrlList) { | 173 } else if (name == safe_browsing_util::kBinUrlList) { |
| 174 id = BINURL; | 174 id = BINURL; |
| 175 } else if (name == safe_browsing_util::kBinHashList) { | 175 } else if (name == safe_browsing_util::kBinHashList) { |
| 176 id = BINHASH; | 176 id = BINHASH; |
| 177 } else if (name == safe_browsing_util::kCsdWhiteList) { | 177 } else if (name == safe_browsing_util::kCsdWhiteList) { |
| 178 id = CSDWHITELIST; | 178 id = CSDWHITELIST; |
| 179 } else if (name == safe_browsing_util::kDownloadWhiteList) { | 179 } else if (name == safe_browsing_util::kDownloadWhiteList) { |
| 180 id = DOWNLOADWHITELIST; | 180 id = DOWNLOADWHITELIST; |
| 181 } else { | 181 } else { |
| 182 id = INVALID; | 182 id = INVALID; |
| 183 } | 183 } |
| 184 return id; | 184 return id; |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool GetListName(int list_id, std::string* list) { | 187 bool GetListName(ListType list_id, std::string* list) { |
| 188 switch (list_id) { | 188 switch (list_id) { |
| 189 case MALWARE: | 189 case MALWARE: |
| 190 *list = safe_browsing_util::kMalwareList; | 190 *list = safe_browsing_util::kMalwareList; |
| 191 break; | 191 break; |
| 192 case PHISH: | 192 case PHISH: |
| 193 *list = safe_browsing_util::kPhishingList; | 193 *list = safe_browsing_util::kPhishingList; |
| 194 break; | 194 break; |
| 195 case BINURL: | 195 case BINURL: |
| 196 *list = safe_browsing_util::kBinUrlList; | 196 *list = safe_browsing_util::kBinUrlList; |
| 197 break; | 197 break; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 #endif | 483 #endif |
| 484 if (is_client_side_detection) | 484 if (is_client_side_detection) |
| 485 client_name.append("_csd"); | 485 client_name.append("_csd"); |
| 486 | 486 |
| 487 GURL report_url(report_page + base::StringPrintf(kReportParams, | 487 GURL report_url(report_page + base::StringPrintf(kReportParams, |
| 488 client_name.c_str(), | 488 client_name.c_str(), |
| 489 current_esc.c_str())); | 489 current_esc.c_str())); |
| 490 return google_util::AppendGoogleLocaleParam(report_url); | 490 return google_util::AppendGoogleLocaleParam(report_url); |
| 491 } | 491 } |
| 492 | 492 |
| 493 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) { | 493 SBFullHash StringToSBFullHash(const std::string& hash_in) { |
| 494 DCHECK_EQ(crypto::kSHA256Length, hash_in.size()); | 494 DCHECK_EQ(crypto::kSHA256Length, hash_in.size()); |
| 495 memcpy(hash_out->full_hash, hash_in.data(), crypto::kSHA256Length); | 495 SBFullHash hash_out; |
| 496 memcpy(hash_out.full_hash, hash_in.data(), crypto::kSHA256Length); |
| 497 return hash_out; |
| 496 } | 498 } |
| 497 | 499 |
| 498 std::string SBFullHashToString(const SBFullHash& hash) { | 500 std::string SBFullHashToString(const SBFullHash& hash) { |
| 499 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); | 501 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); |
| 500 return std::string(hash.full_hash, sizeof(hash.full_hash)); | 502 return std::string(hash.full_hash, sizeof(hash.full_hash)); |
| 501 } | 503 } |
| 504 |
| 502 } // namespace safe_browsing_util | 505 } // namespace safe_browsing_util |
| OLD | NEW |