| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 void SetUnsafeSubResourceForCurrent(bool expect_unsafe_resource) { | 359 void SetUnsafeSubResourceForCurrent(bool expect_unsafe_resource) { |
| 360 UnsafeResource resource; | 360 UnsafeResource resource; |
| 361 resource.url = GURL("http://www.malware.com/"); | 361 resource.url = GURL("http://www.malware.com/"); |
| 362 resource.original_url = web_contents()->GetURL(); | 362 resource.original_url = web_contents()->GetURL(); |
| 363 resource.is_subresource = true; | 363 resource.is_subresource = true; |
| 364 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE; | 364 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE; |
| 365 resource.callback = base::Bind(&EmptyUrlCheckCallback); | 365 resource.callback = base::Bind(&EmptyUrlCheckCallback); |
| 366 resource.callback_thread = | 366 resource.callback_thread = |
| 367 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 367 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 368 resource.render_process_host_id = web_contents()->GetRenderProcessHost()-> | 368 resource.render_process_host_id = web_contents()->GetRenderProcessHost()-> |
| 369 GetID(); | 369 GetID(); |
| 370 resource.render_frame_id = web_contents()->GetMainFrame()->GetRoutingID(); | 370 resource.render_frame_id = web_contents()->GetMainFrame()->GetRoutingID(); |
| 371 csd_host_->OnSafeBrowsingHit(resource); | 371 csd_host_->OnSafeBrowsingHit(resource); |
| 372 resource.callback.Reset(); | 372 resource.callback.Reset(); |
| 373 ASSERT_EQ(expect_unsafe_resource, csd_host_->DidShowSBInterstitial()); | 373 ASSERT_EQ(expect_unsafe_resource, csd_host_->DidShowSBInterstitial()); |
| 374 if (expect_unsafe_resource) | 374 if (expect_unsafe_resource) |
| 375 TestUnsafeResourceCopied(resource); | 375 TestUnsafeResourceCopied(resource); |
| 376 } | 376 } |
| 377 | 377 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 388 } | 388 } |
| 389 | 389 |
| 390 // Simulate a safebrowsing hit before navigation completes. | 390 // Simulate a safebrowsing hit before navigation completes. |
| 391 UnsafeResource resource; | 391 UnsafeResource resource; |
| 392 resource.url = url; | 392 resource.url = url; |
| 393 resource.original_url = url; | 393 resource.original_url = url; |
| 394 resource.is_subresource = false; | 394 resource.is_subresource = false; |
| 395 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE; | 395 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE; |
| 396 resource.callback = base::Bind(&EmptyUrlCheckCallback); | 396 resource.callback = base::Bind(&EmptyUrlCheckCallback); |
| 397 resource.callback_thread = | 397 resource.callback_thread = |
| 398 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 398 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 399 resource.render_process_host_id = pending_rvh()->GetProcess()->GetID(); | 399 resource.render_process_host_id = pending_rvh()->GetProcess()->GetID(); |
| 400 resource.render_frame_id = pending_main_rfh()->GetRoutingID(); | 400 resource.render_frame_id = pending_main_rfh()->GetRoutingID(); |
| 401 csd_host_->OnSafeBrowsingHit(resource); | 401 csd_host_->OnSafeBrowsingHit(resource); |
| 402 resource.callback.Reset(); | 402 resource.callback.Reset(); |
| 403 | 403 |
| 404 // LoadURL created a navigation entry, now simulate the RenderView sending | 404 // LoadURL created a navigation entry, now simulate the RenderView sending |
| 405 // a notification that it actually navigated. | 405 // a notification that it actually navigated. |
| 406 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 406 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| 407 | 407 |
| 408 ASSERT_TRUE(csd_host_->DidShowSBInterstitial()); | 408 ASSERT_TRUE(csd_host_->DidShowSBInterstitial()); |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 EXPECT_EQ(url, resource.url); | 1199 EXPECT_EQ(url, resource.url); |
| 1200 EXPECT_EQ(url, resource.original_url); | 1200 EXPECT_EQ(url, resource.original_url); |
| 1201 | 1201 |
| 1202 ExpectStartPhishingDetection(NULL); | 1202 ExpectStartPhishingDetection(NULL); |
| 1203 | 1203 |
| 1204 // Showing a phishing warning will invalidate all the weak pointers which | 1204 // Showing a phishing warning will invalidate all the weak pointers which |
| 1205 // means we will not extract malware features. | 1205 // means we will not extract malware features. |
| 1206 ExpectShouldClassifyForMalwareResult(false); | 1206 ExpectShouldClassifyForMalwareResult(false); |
| 1207 } | 1207 } |
| 1208 } // namespace safe_browsing | 1208 } // namespace safe_browsing |
| OLD | NEW |