| 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/safe_browsing/malware_details.h" | 10 #include "chrome/browser/safe_browsing/malware_details.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 class TestSafeBrowsingUIManager: public SafeBrowsingUIManager { | 48 class TestSafeBrowsingUIManager: public SafeBrowsingUIManager { |
| 49 public: | 49 public: |
| 50 explicit TestSafeBrowsingUIManager(SafeBrowsingService* service) | 50 explicit TestSafeBrowsingUIManager(SafeBrowsingService* service) |
| 51 : SafeBrowsingUIManager(service) { | 51 : SafeBrowsingUIManager(service) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void SendSerializedMalwareDetails( | 54 virtual void SendSerializedMalwareDetails( |
| 55 const std::string& serialized) OVERRIDE { | 55 const std::string& serialized) override { |
| 56 details_.push_back(serialized); | 56 details_.push_back(serialized); |
| 57 } | 57 } |
| 58 | 58 |
| 59 std::list<std::string>* GetDetails() { | 59 std::list<std::string>* GetDetails() { |
| 60 return &details_; | 60 return &details_; |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 virtual ~TestSafeBrowsingUIManager() {} | 64 virtual ~TestSafeBrowsingUIManager() {} |
| 65 | 65 |
| 66 std::list<std::string> details_; | 66 std::list<std::string> details_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class TestSafeBrowsingBlockingPageFactory | 69 class TestSafeBrowsingBlockingPageFactory |
| 70 : public SafeBrowsingBlockingPageFactory { | 70 : public SafeBrowsingBlockingPageFactory { |
| 71 public: | 71 public: |
| 72 TestSafeBrowsingBlockingPageFactory() { } | 72 TestSafeBrowsingBlockingPageFactory() { } |
| 73 virtual ~TestSafeBrowsingBlockingPageFactory() { } | 73 virtual ~TestSafeBrowsingBlockingPageFactory() { } |
| 74 | 74 |
| 75 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 75 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 76 SafeBrowsingUIManager* manager, | 76 SafeBrowsingUIManager* manager, |
| 77 WebContents* web_contents, | 77 WebContents* web_contents, |
| 78 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 78 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 79 OVERRIDE { | 79 override { |
| 80 return new TestSafeBrowsingBlockingPage(manager, web_contents, | 80 return new TestSafeBrowsingBlockingPage(manager, web_contents, |
| 81 unsafe_resources); | 81 unsafe_resources); |
| 82 } | 82 } |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 class SafeBrowsingBlockingPageTest : public ChromeRenderViewHostTestHarness { | 87 class SafeBrowsingBlockingPageTest : public ChromeRenderViewHostTestHarness { |
| 88 public: | 88 public: |
| 89 // The decision the user made. | 89 // The decision the user made. |
| 90 enum UserResponse { | 90 enum UserResponse { |
| 91 PENDING, | 91 PENDING, |
| 92 OK, | 92 OK, |
| 93 CANCEL | 93 CANCEL |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 SafeBrowsingBlockingPageTest() { | 96 SafeBrowsingBlockingPageTest() { |
| 97 ResetUserResponse(); | 97 ResetUserResponse(); |
| 98 // The safe browsing UI manager does not need a service for this test. | 98 // The safe browsing UI manager does not need a service for this test. |
| 99 ui_manager_ = new TestSafeBrowsingUIManager(NULL); | 99 ui_manager_ = new TestSafeBrowsingUIManager(NULL); |
| 100 } | 100 } |
| 101 | 101 |
| 102 virtual void SetUp() OVERRIDE { | 102 virtual void SetUp() override { |
| 103 ChromeRenderViewHostTestHarness::SetUp(); | 103 ChromeRenderViewHostTestHarness::SetUp(); |
| 104 SafeBrowsingBlockingPage::RegisterFactory(&factory_); | 104 SafeBrowsingBlockingPage::RegisterFactory(&factory_); |
| 105 ResetUserResponse(); | 105 ResetUserResponse(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual void TearDown() OVERRIDE { | 108 virtual void TearDown() override { |
| 109 // Release the UI manager before the BrowserThreads are destroyed. | 109 // Release the UI manager before the BrowserThreads are destroyed. |
| 110 ui_manager_ = NULL; | 110 ui_manager_ = NULL; |
| 111 SafeBrowsingBlockingPage::RegisterFactory(NULL); | 111 SafeBrowsingBlockingPage::RegisterFactory(NULL); |
| 112 // Clean up singleton reference (crbug.com/110594). | 112 // Clean up singleton reference (crbug.com/110594). |
| 113 MalwareDetails::RegisterFactory(NULL); | 113 MalwareDetails::RegisterFactory(NULL); |
| 114 ChromeRenderViewHostTestHarness::TearDown(); | 114 ChromeRenderViewHostTestHarness::TearDown(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void OnBlockingPageComplete(bool proceed) { | 117 void OnBlockingPageComplete(bool proceed) { |
| 118 if (proceed) | 118 if (proceed) |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 657 |
| 658 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( | 658 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( |
| 659 prefs::kSafeBrowsingExtendedReportingEnabled)); | 659 prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 660 | 660 |
| 661 // Simulate the user uncheck the report agreement checkbox. | 661 // Simulate the user uncheck the report agreement checkbox. |
| 662 sb_interstitial->SetReportingPreference(false); | 662 sb_interstitial->SetReportingPreference(false); |
| 663 | 663 |
| 664 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( | 664 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( |
| 665 prefs::kSafeBrowsingExtendedReportingEnabled)); | 665 prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 666 } | 666 } |
| OLD | NEW |