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 <deque> | 5 #include <deque> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "chrome/browser/prerender/prerender_field_trial.h" | 37 #include "chrome/browser/prerender/prerender_field_trial.h" |
38 #include "chrome/browser/prerender/prerender_handle.h" | 38 #include "chrome/browser/prerender/prerender_handle.h" |
39 #include "chrome/browser/prerender/prerender_link_manager.h" | 39 #include "chrome/browser/prerender/prerender_link_manager.h" |
40 #include "chrome/browser/prerender/prerender_link_manager_factory.h" | 40 #include "chrome/browser/prerender/prerender_link_manager_factory.h" |
41 #include "chrome/browser/prerender/prerender_manager.h" | 41 #include "chrome/browser/prerender/prerender_manager.h" |
42 #include "chrome/browser/prerender/prerender_manager_factory.h" | 42 #include "chrome/browser/prerender/prerender_manager_factory.h" |
43 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
44 #include "chrome/browser/profiles/profile_io_data.h" | 44 #include "chrome/browser/profiles/profile_io_data.h" |
45 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 45 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
46 #include "chrome/browser/safe_browsing/database_manager.h" | 46 #include "chrome/browser/safe_browsing/database_manager.h" |
| 47 #include "chrome/browser/safe_browsing/local_database_manager.h" |
47 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 48 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
48 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 49 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 50 #include "chrome/browser/safe_browsing/test_database_manager.h" |
49 #include "chrome/browser/task_manager/task_manager.h" | 51 #include "chrome/browser/task_manager/task_manager.h" |
50 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 52 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
51 #include "chrome/browser/ui/browser.h" | 53 #include "chrome/browser/ui/browser.h" |
52 #include "chrome/browser/ui/browser_commands.h" | 54 #include "chrome/browser/ui/browser_commands.h" |
53 #include "chrome/browser/ui/browser_finder.h" | 55 #include "chrome/browser/ui/browser_finder.h" |
54 #include "chrome/browser/ui/browser_navigator.h" | 56 #include "chrome/browser/ui/browser_navigator.h" |
55 #include "chrome/browser/ui/browser_window.h" | 57 #include "chrome/browser/ui/browser_window.h" |
56 #include "chrome/browser/ui/location_bar/location_bar.h" | 58 #include "chrome/browser/ui/location_bar/location_bar.h" |
57 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 59 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
58 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 60 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 handle(handle) { | 695 handle(handle) { |
694 } | 696 } |
695 | 697 |
696 FinalStatus final_status; | 698 FinalStatus final_status; |
697 base::WeakPtr<TestPrerender> handle; | 699 base::WeakPtr<TestPrerender> handle; |
698 }; | 700 }; |
699 | 701 |
700 std::deque<ExpectedContents> expected_contents_queue_; | 702 std::deque<ExpectedContents> expected_contents_queue_; |
701 }; | 703 }; |
702 | 704 |
| 705 // TODO(nparker): Switch this to use TestSafeBrowsingDatabaseManager and run |
| 706 // with SAFE_BROWSING_DB_LOCAL || SAFE_BROWSING_DB_REMOTE. |
703 #if defined(FULL_SAFE_BROWSING) | 707 #if defined(FULL_SAFE_BROWSING) |
704 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for | 708 // A SafeBrowsingDatabaseManager implementation that returns a fixed result for |
705 // a given URL. | 709 // a given URL. |
706 class FakeSafeBrowsingDatabaseManager : public SafeBrowsingDatabaseManager { | 710 class FakeSafeBrowsingDatabaseManager |
| 711 : public LocalSafeBrowsingDatabaseManager { |
707 public: | 712 public: |
708 explicit FakeSafeBrowsingDatabaseManager(SafeBrowsingService* service) | 713 explicit FakeSafeBrowsingDatabaseManager(SafeBrowsingService* service) |
709 : SafeBrowsingDatabaseManager(service), | 714 : LocalSafeBrowsingDatabaseManager(service), |
710 threat_type_(SB_THREAT_TYPE_SAFE) { } | 715 threat_type_(SB_THREAT_TYPE_SAFE) {} |
711 | 716 |
712 // Called on the IO thread to check if the given url is safe or not. If we | 717 // Called on the IO thread to check if the given url is safe or not. If we |
713 // can synchronously determine that the url is safe, CheckUrl returns true. | 718 // can synchronously determine that the url is safe, CheckUrl returns true. |
714 // Otherwise it returns false, and "client" is called asynchronously with the | 719 // Otherwise it returns false, and "client" is called asynchronously with the |
715 // result when it is ready. | 720 // result when it is ready. |
716 // Returns true, indicating a SAFE result, unless the URL is the fixed URL | 721 // Returns true, indicating a SAFE result, unless the URL is the fixed URL |
717 // specified by the user, and the user-specified result is not SAFE | 722 // specified by the user, and the user-specified result is not SAFE |
718 // (in which that result will be communicated back via a call into the | 723 // (in which that result will be communicated back via a call into the |
719 // client, and false will be returned). | 724 // client, and false will be returned). |
720 // Overrides SafeBrowsingService::CheckBrowseUrl. | 725 // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl. |
721 bool CheckBrowseUrl(const GURL& gurl, Client* client) override { | 726 bool CheckBrowseUrl(const GURL& gurl, Client* client) override { |
722 if (gurl != url_ || threat_type_ == SB_THREAT_TYPE_SAFE) | 727 if (gurl != url_ || threat_type_ == SB_THREAT_TYPE_SAFE) |
723 return true; | 728 return true; |
724 | 729 |
725 BrowserThread::PostTask( | 730 BrowserThread::PostTask( |
726 BrowserThread::IO, FROM_HERE, | 731 BrowserThread::IO, FROM_HERE, |
727 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, | 732 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, |
728 this, gurl, client)); | 733 this, gurl, client)); |
729 return false; | 734 return false; |
730 } | 735 } |
731 | 736 |
732 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) { | 737 void SetThreatTypeForUrl(const GURL& url, SBThreatType threat_type) { |
733 url_ = url; | 738 url_ = url; |
734 threat_type_ = threat_type; | 739 threat_type_ = threat_type; |
735 } | 740 } |
736 | 741 |
737 private: | 742 private: |
738 ~FakeSafeBrowsingDatabaseManager() override {} | 743 ~FakeSafeBrowsingDatabaseManager() override {} |
739 | 744 |
740 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { | 745 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { |
741 std::vector<SBThreatType> expected_threats; | 746 std::vector<SBThreatType> expected_threats; |
742 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); | 747 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); |
743 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); | 748 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); |
744 SafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check( | 749 // TODO(nparker): Replace SafeBrowsingCheck w/ a call to |
| 750 // client->OnCheckBrowseUrlResult() |
| 751 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check( |
745 std::vector<GURL>(1, gurl), | 752 std::vector<GURL>(1, gurl), |
746 std::vector<SBFullHash>(), | 753 std::vector<SBFullHash>(), |
747 client, | 754 client, |
748 safe_browsing_util::MALWARE, | 755 safe_browsing_util::MALWARE, |
749 expected_threats); | 756 expected_threats); |
750 sb_check.url_results[0] = threat_type_; | 757 sb_check.url_results[0] = threat_type_; |
751 client->OnSafeBrowsingResult(sb_check); | 758 sb_check.OnSafeBrowsingResult(); |
752 } | 759 } |
753 | 760 |
754 GURL url_; | 761 GURL url_; |
755 SBThreatType threat_type_; | 762 SBThreatType threat_type_; |
756 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); | 763 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); |
757 }; | 764 }; |
758 | 765 |
759 class FakeSafeBrowsingService : public SafeBrowsingService { | 766 class FakeSafeBrowsingService : public SafeBrowsingService { |
760 public: | 767 public: |
761 FakeSafeBrowsingService() { } | 768 FakeSafeBrowsingService() { } |
(...skipping 3303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4065 browser()->tab_strip_model()->GetActiveWebContents(); | 4072 browser()->tab_strip_model()->GetActiveWebContents(); |
4066 bool display_test_result = false; | 4073 bool display_test_result = false; |
4067 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, | 4074 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, |
4068 "DidDisplayReallyPass()", | 4075 "DidDisplayReallyPass()", |
4069 &display_test_result)); | 4076 &display_test_result)); |
4070 ASSERT_TRUE(display_test_result); | 4077 ASSERT_TRUE(display_test_result); |
4071 } | 4078 } |
4072 #endif // !defined(DISABLE_NACL) | 4079 #endif // !defined(DISABLE_NACL) |
4073 | 4080 |
4074 } // namespace prerender | 4081 } // namespace prerender |
OLD | NEW |