| OLD | NEW |
| 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 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
| 6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
| 7 // service. | 7 // service. |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/sha2.h" | 12 #include "crypto/sha2.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 14 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
| 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 17 #include "chrome/browser/safe_browsing/protocol_manager.h" | 17 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/test/in_process_browser_test.h" | 20 #include "chrome/test/in_process_browser_test.h" |
| 21 #include "chrome/test/ui_test_utils.h" | 21 #include "chrome/test/ui_test_utils.h" |
| 22 #include "content/browser/browser_thread.h" | 22 #include "content/browser/browser_thread.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 SafeBrowsingServiceTest() { | 249 SafeBrowsingServiceTest() { |
| 250 } | 250 } |
| 251 | 251 |
| 252 static void GenUrlFullhashResult(const GURL& url, | 252 static void GenUrlFullhashResult(const GURL& url, |
| 253 const std::string& list_name, | 253 const std::string& list_name, |
| 254 int add_chunk_id, | 254 int add_chunk_id, |
| 255 SBFullHashResult* full_hash) { | 255 SBFullHashResult* full_hash) { |
| 256 std::string host; | 256 std::string host; |
| 257 std::string path; | 257 std::string path; |
| 258 safe_browsing_util::CanonicalizeUrl(url, &host, &path, NULL); | 258 safe_browsing_util::CanonicalizeUrl(url, &host, &path, NULL); |
| 259 base::SHA256HashString(host + path, &full_hash->hash, | 259 crypto::SHA256HashString(host + path, &full_hash->hash, |
| 260 sizeof(SBFullHash)); | 260 sizeof(SBFullHash)); |
| 261 full_hash->list_name = list_name; | 261 full_hash->list_name = list_name; |
| 262 full_hash->add_chunk_id = add_chunk_id; | 262 full_hash->add_chunk_id = add_chunk_id; |
| 263 } | 263 } |
| 264 | 264 |
| 265 static void GenDigestFullhashResult(const std::string& full_digest, | 265 static void GenDigestFullhashResult(const std::string& full_digest, |
| 266 const std::string& list_name, | 266 const std::string& list_name, |
| 267 int add_chunk_id, | 267 int add_chunk_id, |
| 268 SBFullHashResult* full_hash) { | 268 SBFullHashResult* full_hash) { |
| 269 safe_browsing_util::StringToSBFullHash(full_digest, &full_hash->hash); | 269 safe_browsing_util::StringToSBFullHash(full_digest, &full_hash->hash); |
| 270 full_hash->list_name = list_name; | 270 full_hash->list_name = list_name; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 client->CheckDownloadHash(full_hash); | 597 client->CheckDownloadHash(full_hash); |
| 598 | 598 |
| 599 // There should be a timeout and the hash would be considered as safe. | 599 // There should be a timeout and the hash would be considered as safe. |
| 600 EXPECT_EQ(SafeBrowsingService::SAFE, client->GetResult()); | 600 EXPECT_EQ(SafeBrowsingService::SAFE, client->GetResult()); |
| 601 | 601 |
| 602 // Need to set the timeout back to the default value. | 602 // Need to set the timeout back to the default value. |
| 603 SetDownloadHashCheckTimeout(sb_service, default_hashcheck_timeout); | 603 SetDownloadHashCheckTimeout(sb_service, default_hashcheck_timeout); |
| 604 } | 604 } |
| 605 | 605 |
| 606 } // namespace | 606 } // namespace |
| OLD | NEW |