Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_util.cc

Issue 7863006: Add a whitelist for the new binary download protection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Matt's comment. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // Utility functions ----------------------------------------------------------- 163 // Utility functions -----------------------------------------------------------
164 164
165 namespace safe_browsing_util { 165 namespace safe_browsing_util {
166 166
167 // Listnames that browser can process. 167 // Listnames that browser can process.
168 const char kMalwareList[] = "goog-malware-shavar"; 168 const char kMalwareList[] = "goog-malware-shavar";
169 const char kPhishingList[] = "goog-phish-shavar"; 169 const char kPhishingList[] = "goog-phish-shavar";
170 const char kBinUrlList[] = "goog-badbinurl-shavar"; 170 const char kBinUrlList[] = "goog-badbinurl-shavar";
171 const char kBinHashList[] = "goog-badbin-digestvar"; 171 const char kBinHashList[] = "goog-badbin-digestvar";
172 const char kCsdWhiteList[] = "goog-csdwhite-sha256"; 172 const char kCsdWhiteList[] = "goog-csdwhite-sha256";
173 const char kDownloadWhiteList[] = "goog-downloadwhite-digest256";
173 174
174 int GetListId(const std::string& name) { 175 int GetListId(const std::string& name) {
175 int id; 176 int id;
176 if (name == safe_browsing_util::kMalwareList) { 177 if (name == safe_browsing_util::kMalwareList) {
177 id = MALWARE; 178 id = MALWARE;
178 } else if (name == safe_browsing_util::kPhishingList) { 179 } else if (name == safe_browsing_util::kPhishingList) {
179 id = PHISH; 180 id = PHISH;
180 } else if (name == safe_browsing_util::kBinUrlList) { 181 } else if (name == safe_browsing_util::kBinUrlList) {
181 id = BINURL; 182 id = BINURL;
182 } else if (name == safe_browsing_util::kBinHashList) { 183 } else if (name == safe_browsing_util::kBinHashList) {
183 id = BINHASH; 184 id = BINHASH;
184 } else if (name == safe_browsing_util::kCsdWhiteList) { 185 } else if (name == safe_browsing_util::kCsdWhiteList) {
185 id = CSDWHITELIST; 186 id = CSDWHITELIST;
187 } else if (name == safe_browsing_util::kDownloadWhiteList) {
188 id = DOWNLOADWHITELIST;
186 } else { 189 } else {
187 id = INVALID; 190 id = INVALID;
188 } 191 }
189 return id; 192 return id;
190 } 193 }
191 194
192 bool GetListName(int list_id, std::string* list) { 195 bool GetListName(int list_id, std::string* list) {
193 switch (list_id) { 196 switch (list_id) {
194 case MALWARE: 197 case MALWARE:
195 *list = safe_browsing_util::kMalwareList; 198 *list = safe_browsing_util::kMalwareList;
196 break; 199 break;
197 case PHISH: 200 case PHISH:
198 *list = safe_browsing_util::kPhishingList; 201 *list = safe_browsing_util::kPhishingList;
199 break; 202 break;
200 case BINURL: 203 case BINURL:
201 *list = safe_browsing_util::kBinUrlList; 204 *list = safe_browsing_util::kBinUrlList;
202 break; 205 break;
203 case BINHASH: 206 case BINHASH:
204 *list = safe_browsing_util::kBinHashList; 207 *list = safe_browsing_util::kBinHashList;
205 break; 208 break;
206 case CSDWHITELIST: 209 case CSDWHITELIST:
207 *list = safe_browsing_util::kCsdWhiteList; 210 *list = safe_browsing_util::kCsdWhiteList;
208 break; 211 break;
212 case DOWNLOADWHITELIST:
213 *list = safe_browsing_util::kDownloadWhiteList;
214 break;
209 default: 215 default:
210 return false; 216 return false;
211 } 217 }
212 return true; 218 return true;
213 } 219 }
214 220
215 std::string Unescape(const std::string& url) { 221 std::string Unescape(const std::string& url) {
216 std::string unescaped_str(url); 222 std::string unescaped_str(url);
217 std::string old_unescaped_str; 223 std::string old_unescaped_str;
218 const int kMaxLoopIterations = 1024; 224 const int kMaxLoopIterations = 1024;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) { 540 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) {
535 DCHECK_EQ(static_cast<size_t>(crypto::SHA256_LENGTH), hash_in.size()); 541 DCHECK_EQ(static_cast<size_t>(crypto::SHA256_LENGTH), hash_in.size());
536 memcpy(hash_out->full_hash, hash_in.data(), crypto::SHA256_LENGTH); 542 memcpy(hash_out->full_hash, hash_in.data(), crypto::SHA256_LENGTH);
537 } 543 }
538 544
539 std::string SBFullHashToString(const SBFullHash& hash) { 545 std::string SBFullHashToString(const SBFullHash& hash) {
540 DCHECK_EQ(static_cast<size_t>(crypto::SHA256_LENGTH), sizeof(hash.full_hash)); 546 DCHECK_EQ(static_cast<size_t>(crypto::SHA256_LENGTH), sizeof(hash.full_hash));
541 return std::string(hash.full_hash, sizeof(hash.full_hash)); 547 return std::string(hash.full_hash, sizeof(hash.full_hash));
542 } 548 }
543 } // namespace safe_browsing_util 549 } // namespace safe_browsing_util
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698