| 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 "chrome/browser/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
| 6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/safe_browsing/malware_details.h" | 7 #include "chrome/browser/safe_browsing/malware_details.h" |
| 8 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 8 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 10 #include "chrome/browser/safe_browsing/ui_manager.h" | 10 #include "chrome/browser/safe_browsing/ui_manager.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 interstitial_page()->DontCreateViewForTesting(); | 62 interstitial_page()->DontCreateViewForTesting(); |
| 63 } | 63 } |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 class TestSafeBrowsingUIManager: public SafeBrowsingUIManager { | 66 class TestSafeBrowsingUIManager: public SafeBrowsingUIManager { |
| 67 public: | 67 public: |
| 68 explicit TestSafeBrowsingUIManager(SafeBrowsingService* service) | 68 explicit TestSafeBrowsingUIManager(SafeBrowsingService* service) |
| 69 : SafeBrowsingUIManager(service) { | 69 : SafeBrowsingUIManager(service) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual void SendSerializedMalwareDetails(const std::string& serialized) { | 72 virtual void SendSerializedMalwareDetails( |
| 73 const std::string& serialized) OVERRIDE { |
| 73 details_.push_back(serialized); | 74 details_.push_back(serialized); |
| 74 } | 75 } |
| 75 | 76 |
| 76 std::list<std::string>* GetDetails() { | 77 std::list<std::string>* GetDetails() { |
| 77 return &details_; | 78 return &details_; |
| 78 } | 79 } |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 virtual ~TestSafeBrowsingUIManager() {} | 82 virtual ~TestSafeBrowsingUIManager() {} |
| 82 | 83 |
| 83 std::list<std::string> details_; | 84 std::list<std::string> details_; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 class TestSafeBrowsingBlockingPageFactory | 87 class TestSafeBrowsingBlockingPageFactory |
| 87 : public SafeBrowsingBlockingPageFactory { | 88 : public SafeBrowsingBlockingPageFactory { |
| 88 public: | 89 public: |
| 89 TestSafeBrowsingBlockingPageFactory() { } | 90 TestSafeBrowsingBlockingPageFactory() { } |
| 90 ~TestSafeBrowsingBlockingPageFactory() { } | 91 virtual ~TestSafeBrowsingBlockingPageFactory() { } |
| 91 | 92 |
| 92 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 93 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 93 SafeBrowsingUIManager* manager, | 94 SafeBrowsingUIManager* manager, |
| 94 WebContents* web_contents, | 95 WebContents* web_contents, |
| 95 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { | 96 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 97 OVERRIDE { |
| 96 // TODO(mattm): remove this when SafeBrowsingBlockingPageV2 supports | 98 // TODO(mattm): remove this when SafeBrowsingBlockingPageV2 supports |
| 97 // multi-threat warnings. | 99 // multi-threat warnings. |
| 98 if (unsafe_resources.size() == 1 && | 100 if (unsafe_resources.size() == 1 && |
| 99 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || | 101 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || |
| 100 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { | 102 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { |
| 101 return new TestSafeBrowsingBlockingPageV2(manager, web_contents, | 103 return new TestSafeBrowsingBlockingPageV2(manager, web_contents, |
| 102 unsafe_resources); | 104 unsafe_resources); |
| 103 } | 105 } |
| 104 return new TestSafeBrowsingBlockingPageV1(manager, web_contents, | 106 return new TestSafeBrowsingBlockingPageV1(manager, web_contents, |
| 105 unsafe_resources); | 107 unsafe_resources); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 | 664 |
| 663 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( | 665 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( |
| 664 prefs::kSafeBrowsingReportingEnabled)); | 666 prefs::kSafeBrowsingReportingEnabled)); |
| 665 | 667 |
| 666 // Simulate the user uncheck the report agreement checkbox. | 668 // Simulate the user uncheck the report agreement checkbox. |
| 667 sb_interstitial->SetReportingPreference(false); | 669 sb_interstitial->SetReportingPreference(false); |
| 668 | 670 |
| 669 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( | 671 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( |
| 670 prefs::kSafeBrowsingReportingEnabled)); | 672 prefs::kSafeBrowsingReportingEnabled)); |
| 671 } | 673 } |
| OLD | NEW |