| 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/safe_browsing/client_side_detection_host.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 class MockSafeBrowsingUIManager : public SafeBrowsingUIManager { | 137 class MockSafeBrowsingUIManager : public SafeBrowsingUIManager { |
| 138 public: | 138 public: |
| 139 explicit MockSafeBrowsingUIManager(SafeBrowsingService* service) | 139 explicit MockSafeBrowsingUIManager(SafeBrowsingService* service) |
| 140 : SafeBrowsingUIManager(service) { } | 140 : SafeBrowsingUIManager(service) { } |
| 141 | 141 |
| 142 MOCK_METHOD1(DisplayBlockingPage, void(const UnsafeResource& resource)); | 142 MOCK_METHOD1(DisplayBlockingPage, void(const UnsafeResource& resource)); |
| 143 | 143 |
| 144 // Helper function which calls OnBlockingPageComplete for this client | 144 // Helper function which calls OnBlockingPageComplete for this client |
| 145 // object. | 145 // object. |
| 146 void InvokeOnBlockingPageComplete(const UrlCheckCallback& callback) { | 146 void InvokeOnBlockingPageComplete( |
| 147 const security_interstitials::UnsafeResource::UrlCheckCallback& callback) { |
| 147 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 148 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 148 // Note: this will delete the client object in the case of the CsdClient | 149 // Note: this will delete the client object in the case of the CsdClient |
| 149 // implementation. | 150 // implementation. |
| 150 if (!callback.is_null()) | 151 if (!callback.is_null()) |
| 151 callback.Run(false); | 152 callback.Run(false); |
| 152 } | 153 } |
| 153 | 154 |
| 154 protected: | 155 protected: |
| 155 virtual ~MockSafeBrowsingUIManager() { } | 156 virtual ~MockSafeBrowsingUIManager() { } |
| 156 | 157 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 MOCK_METHOD3(ExtractMalwareFeatures, | 198 MOCK_METHOD3(ExtractMalwareFeatures, |
| 198 void(BrowseInfo*, | 199 void(BrowseInfo*, |
| 199 ClientMalwareRequest*, | 200 ClientMalwareRequest*, |
| 200 const BrowserFeatureExtractor::MalwareDoneCallback&)); | 201 const BrowserFeatureExtractor::MalwareDoneCallback&)); |
| 201 }; | 202 }; |
| 202 | 203 |
| 203 } // namespace | 204 } // namespace |
| 204 | 205 |
| 205 class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness { | 206 class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness { |
| 206 public: | 207 public: |
| 207 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; | 208 typedef security_interstitials::UnsafeResource UnsafeResource; |
| 208 | 209 |
| 209 void SetUp() override { | 210 void SetUp() override { |
| 210 ChromeRenderViewHostTestHarness::SetUp(); | 211 ChromeRenderViewHostTestHarness::SetUp(); |
| 211 | 212 |
| 212 // Inject service classes. | 213 // Inject service classes. |
| 213 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); | 214 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); |
| 214 database_manager_ = new StrictMock<MockSafeBrowsingDatabaseManager>(); | 215 database_manager_ = new StrictMock<MockSafeBrowsingDatabaseManager>(); |
| 215 ui_manager_ = new StrictMock<MockSafeBrowsingUIManager>( | 216 ui_manager_ = new StrictMock<MockSafeBrowsingUIManager>( |
| 216 SafeBrowsingService::CreateSafeBrowsingService()); | 217 SafeBrowsingService::CreateSafeBrowsingService()); |
| 217 csd_host_.reset(ClientSideDetectionHost::Create(web_contents())); | 218 csd_host_.reset(ClientSideDetectionHost::Create(web_contents())); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 EXPECT_EQ(url, resource.url); | 1191 EXPECT_EQ(url, resource.url); |
| 1191 EXPECT_EQ(url, resource.original_url); | 1192 EXPECT_EQ(url, resource.original_url); |
| 1192 | 1193 |
| 1193 ExpectStartPhishingDetection(NULL); | 1194 ExpectStartPhishingDetection(NULL); |
| 1194 | 1195 |
| 1195 // Showing a phishing warning will invalidate all the weak pointers which | 1196 // Showing a phishing warning will invalidate all the weak pointers which |
| 1196 // means we will not extract malware features. | 1197 // means we will not extract malware features. |
| 1197 ExpectShouldClassifyForMalwareResult(false); | 1198 ExpectShouldClassifyForMalwareResult(false); |
| 1198 } | 1199 } |
| 1199 } // namespace safe_browsing | 1200 } // namespace safe_browsing |
| OLD | NEW |