| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 28 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 29 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/tab_contents/tab_contents.h" |
| 30 #include "content/browser/tab_contents/tab_contents_view.h" | 30 #include "content/browser/tab_contents/tab_contents_view.h" |
| 31 #include "content/test/test_browser_thread.h" | 31 #include "content/test/test_browser_thread.h" |
| 32 #include "crypto/sha2.h" | 32 #include "crypto/sha2.h" |
| 33 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
| 34 | 34 |
| 35 using base::Histogram; | 35 using base::Histogram; |
| 36 using base::StatisticsRecorder; | 36 using base::StatisticsRecorder; |
| 37 using content::BrowserThread; | 37 using content::BrowserThread; |
| 38 | 38 using content::WebContents; |
| 39 using ::testing::_; | 39 using ::testing::_; |
| 40 using ::testing::Mock; | 40 using ::testing::Mock; |
| 41 using ::testing::StrictMock; | 41 using ::testing::StrictMock; |
| 42 | 42 |
| 43 // A SafeBrowingDatabase class that allows us to inject the malicious URLs. | 43 // A SafeBrowingDatabase class that allows us to inject the malicious URLs. |
| 44 class TestSafeBrowsingDatabase : public SafeBrowsingDatabase { | 44 class TestSafeBrowsingDatabase : public SafeBrowsingDatabase { |
| 45 public: | 45 public: |
| 46 TestSafeBrowsingDatabase() {} | 46 TestSafeBrowsingDatabase() {} |
| 47 | 47 |
| 48 virtual ~TestSafeBrowsingDatabase() {} | 48 virtual ~TestSafeBrowsingDatabase() {} |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 TestSafeBrowsingDatabase* db = db_factory_.GetDb(); | 374 TestSafeBrowsingDatabase* db = db_factory_.GetDb(); |
| 375 SBFullHash full_hash; | 375 SBFullHash full_hash; |
| 376 safe_browsing_util::StringToSBFullHash(digest, &full_hash); | 376 safe_browsing_util::StringToSBFullHash(digest, &full_hash); |
| 377 db->AddDownloadPrefix(full_hash.prefix); | 377 db->AddDownloadPrefix(full_hash.prefix); |
| 378 | 378 |
| 379 TestProtocolManager* pm = pm_factory_.GetProtocolManager(); | 379 TestProtocolManager* pm = pm_factory_.GetProtocolManager(); |
| 380 pm->SetGetFullHashResponse(hash_result); | 380 pm->SetGetFullHashResponse(hash_result); |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool ShowingInterstitialPage() { | 383 bool ShowingInterstitialPage() { |
| 384 TabContents* contents = browser()->GetSelectedTabContents(); | 384 WebContents* contents = browser()->GetSelectedWebContents(); |
| 385 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); | 385 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); |
| 386 return interstitial_page != NULL; | 386 return interstitial_page != NULL; |
| 387 } | 387 } |
| 388 | 388 |
| 389 void IntroduceGetHashDelay(int64 ms) { | 389 void IntroduceGetHashDelay(int64 ms) { |
| 390 pm_factory_.GetProtocolManager()->IntroduceDelay(ms); | 390 pm_factory_.GetProtocolManager()->IntroduceDelay(ms); |
| 391 } | 391 } |
| 392 | 392 |
| 393 int64 DownloadUrlCheckTimeout(SafeBrowsingService* sb_service) { | 393 int64 DownloadUrlCheckTimeout(SafeBrowsingService* sb_service) { |
| 394 return sb_service->download_urlcheck_timeout_ms_; | 394 return sb_service->download_urlcheck_timeout_ms_; |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 763 |
| 764 // Delete the Profile. SBS stops again. | 764 // Delete the Profile. SBS stops again. |
| 765 pref_service2 = NULL; | 765 pref_service2 = NULL; |
| 766 profile2.reset(); | 766 profile2.reset(); |
| 767 WaitForIOThread(); | 767 WaitForIOThread(); |
| 768 EXPECT_FALSE(sb_service->enabled()); | 768 EXPECT_FALSE(sb_service->enabled()); |
| 769 EXPECT_FALSE(csd_service->enabled()); | 769 EXPECT_FALSE(csd_service->enabled()); |
| 770 } | 770 } |
| 771 | 771 |
| 772 } // namespace | 772 } // namespace |
| OLD | NEW |