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 // 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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "base/test/thread_test_helper.h" | 14 #include "base/test/thread_test_helper.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/prerender/prerender_manager.h" | 17 #include "chrome/browser/prerender/prerender_manager.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 19 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
20 #include "chrome/browser/safe_browsing/protocol_manager.h" | 20 #include "chrome/browser/safe_browsing/protocol_manager.h" |
21 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
23 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 23 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
27 #include "chrome/test/base/in_process_browser_test.h" | 28 #include "chrome/test/base/in_process_browser_test.h" |
28 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 #include "content/public/browser/web_contents_view.h" | 31 #include "content/public/browser/web_contents_view.h" |
31 #include "content/public/test/test_browser_thread.h" | 32 #include "content/public/test/test_browser_thread.h" |
32 #include "crypto/sha2.h" | 33 #include "crypto/sha2.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
34 | 35 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 TestSafeBrowsingDatabase* db = db_factory_.GetDb(); | 355 TestSafeBrowsingDatabase* db = db_factory_.GetDb(); |
355 SBFullHash full_hash; | 356 SBFullHash full_hash; |
356 safe_browsing_util::StringToSBFullHash(digest, &full_hash); | 357 safe_browsing_util::StringToSBFullHash(digest, &full_hash); |
357 db->AddDownloadPrefix(full_hash.prefix); | 358 db->AddDownloadPrefix(full_hash.prefix); |
358 | 359 |
359 TestProtocolManager* pm = pm_factory_.GetProtocolManager(); | 360 TestProtocolManager* pm = pm_factory_.GetProtocolManager(); |
360 pm->SetGetFullHashResponse(hash_result); | 361 pm->SetGetFullHashResponse(hash_result); |
361 } | 362 } |
362 | 363 |
363 bool ShowingInterstitialPage() { | 364 bool ShowingInterstitialPage() { |
364 WebContents* contents = browser()->GetActiveWebContents(); | 365 WebContents* contents = chrome::GetActiveWebContents(browser()); |
365 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); | 366 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); |
366 return interstitial_page != NULL; | 367 return interstitial_page != NULL; |
367 } | 368 } |
368 | 369 |
369 void IntroduceGetHashDelay(int64 ms) { | 370 void IntroduceGetHashDelay(int64 ms) { |
370 pm_factory_.GetProtocolManager()->IntroduceDelay(ms); | 371 pm_factory_.GetProtocolManager()->IntroduceDelay(ms); |
371 } | 372 } |
372 | 373 |
373 int64 DownloadUrlCheckTimeout(SafeBrowsingService* sb_service) { | 374 int64 DownloadUrlCheckTimeout(SafeBrowsingService* sb_service) { |
374 return sb_service->download_urlcheck_timeout_ms_; | 375 return sb_service->download_urlcheck_timeout_ms_; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 748 |
748 // Delete the Profile. SBS stops again. | 749 // Delete the Profile. SBS stops again. |
749 pref_service2 = NULL; | 750 pref_service2 = NULL; |
750 profile2.reset(); | 751 profile2.reset(); |
751 WaitForIOThread(); | 752 WaitForIOThread(); |
752 EXPECT_FALSE(sb_service->enabled()); | 753 EXPECT_FALSE(sb_service->enabled()); |
753 EXPECT_FALSE(csd_service->enabled()); | 754 EXPECT_FALSE(csd_service->enabled()); |
754 } | 755 } |
755 | 756 |
756 } // namespace | 757 } // namespace |
OLD | NEW |