| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 10 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 10 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 resource.threat_type = SafeBrowsingService::URL_MALWARE; | 258 resource.threat_type = SafeBrowsingService::URL_MALWARE; |
| 259 // Bogus client class. We just need this class to check that the client | 259 // Bogus client class. We just need this class to check that the client |
| 260 // field of the UnsafeResource gets cleared before we stored it in the | 260 // field of the UnsafeResource gets cleared before we stored it in the |
| 261 // host object. | 261 // host object. |
| 262 class BogusClient : public SafeBrowsingService::Client { | 262 class BogusClient : public SafeBrowsingService::Client { |
| 263 public: | 263 public: |
| 264 BogusClient() {} | 264 BogusClient() {} |
| 265 virtual ~BogusClient() {} | 265 virtual ~BogusClient() {} |
| 266 }; | 266 }; |
| 267 resource.client = new BogusClient(); | 267 resource.client = new BogusClient(); |
| 268 resource.render_process_host_id = contents()->GetRenderProcessHost()->id(); | 268 resource.render_process_host_id = contents()->GetRenderProcessHost()-> |
| 269 GetID(); |
| 269 resource.render_view_id = contents()->render_view_host()->routing_id(); | 270 resource.render_view_id = contents()->render_view_host()->routing_id(); |
| 270 csd_host_->OnSafeBrowsingHit(resource); | 271 csd_host_->OnSafeBrowsingHit(resource); |
| 271 delete resource.client; | 272 delete resource.client; |
| 272 ASSERT_TRUE(csd_host_->DidShowSBInterstitial()); | 273 ASSERT_TRUE(csd_host_->DidShowSBInterstitial()); |
| 273 ASSERT_TRUE(csd_host_->unsafe_resource_.get()); | 274 ASSERT_TRUE(csd_host_->unsafe_resource_.get()); |
| 274 // Test that the resource above was copied. | 275 // Test that the resource above was copied. |
| 275 EXPECT_EQ(resource.url, csd_host_->unsafe_resource_->url); | 276 EXPECT_EQ(resource.url, csd_host_->unsafe_resource_->url); |
| 276 EXPECT_EQ(resource.original_url, csd_host_->unsafe_resource_->original_url); | 277 EXPECT_EQ(resource.original_url, csd_host_->unsafe_resource_->original_url); |
| 277 EXPECT_EQ(resource.is_subresource, | 278 EXPECT_EQ(resource.is_subresource, |
| 278 csd_host_->unsafe_resource_->is_subresource); | 279 csd_host_->unsafe_resource_->is_subresource); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 cb->Run(phishing_url, true); | 406 cb->Run(phishing_url, true); |
| 406 delete cb; | 407 delete cb; |
| 407 | 408 |
| 408 MessageLoop::current()->RunAllPending(); | 409 MessageLoop::current()->RunAllPending(); |
| 409 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 410 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 410 EXPECT_EQ(phishing_url, resource.url); | 411 EXPECT_EQ(phishing_url, resource.url); |
| 411 EXPECT_EQ(phishing_url, resource.original_url); | 412 EXPECT_EQ(phishing_url, resource.original_url); |
| 412 EXPECT_FALSE(resource.is_subresource); | 413 EXPECT_FALSE(resource.is_subresource); |
| 413 EXPECT_EQ(SafeBrowsingService::CLIENT_SIDE_PHISHING_URL, | 414 EXPECT_EQ(SafeBrowsingService::CLIENT_SIDE_PHISHING_URL, |
| 414 resource.threat_type); | 415 resource.threat_type); |
| 415 EXPECT_EQ(contents()->GetRenderProcessHost()->id(), | 416 EXPECT_EQ(contents()->GetRenderProcessHost()->GetID(), |
| 416 resource.render_process_host_id); | 417 resource.render_process_host_id); |
| 417 EXPECT_EQ(contents()->render_view_host()->routing_id(), | 418 EXPECT_EQ(contents()->render_view_host()->routing_id(), |
| 418 resource.render_view_id); | 419 resource.render_view_id); |
| 419 | 420 |
| 420 // Make sure the client object will be deleted. | 421 // Make sure the client object will be deleted. |
| 421 BrowserThread::PostTask( | 422 BrowserThread::PostTask( |
| 422 BrowserThread::IO, | 423 BrowserThread::IO, |
| 423 FROM_HERE, | 424 FROM_HERE, |
| 424 NewRunnableMethod( | 425 NewRunnableMethod( |
| 425 sb_service_.get(), | 426 sb_service_.get(), |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 cb_other->Run(other_phishing_url, true); // Should show interstitial. | 502 cb_other->Run(other_phishing_url, true); // Should show interstitial. |
| 502 delete cb_other; | 503 delete cb_other; |
| 503 | 504 |
| 504 MessageLoop::current()->RunAllPending(); | 505 MessageLoop::current()->RunAllPending(); |
| 505 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 506 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 506 EXPECT_EQ(other_phishing_url, resource.url); | 507 EXPECT_EQ(other_phishing_url, resource.url); |
| 507 EXPECT_EQ(other_phishing_url, resource.original_url); | 508 EXPECT_EQ(other_phishing_url, resource.original_url); |
| 508 EXPECT_FALSE(resource.is_subresource); | 509 EXPECT_FALSE(resource.is_subresource); |
| 509 EXPECT_EQ(SafeBrowsingService::CLIENT_SIDE_PHISHING_URL, | 510 EXPECT_EQ(SafeBrowsingService::CLIENT_SIDE_PHISHING_URL, |
| 510 resource.threat_type); | 511 resource.threat_type); |
| 511 EXPECT_EQ(contents()->GetRenderProcessHost()->id(), | 512 EXPECT_EQ(contents()->GetRenderProcessHost()->GetID(), |
| 512 resource.render_process_host_id); | 513 resource.render_process_host_id); |
| 513 EXPECT_EQ(contents()->render_view_host()->routing_id(), | 514 EXPECT_EQ(contents()->render_view_host()->routing_id(), |
| 514 resource.render_view_id); | 515 resource.render_view_id); |
| 515 | 516 |
| 516 // Make sure the client object will be deleted. | 517 // Make sure the client object will be deleted. |
| 517 BrowserThread::PostTask( | 518 BrowserThread::PostTask( |
| 518 BrowserThread::IO, | 519 BrowserThread::IO, |
| 519 FROM_HERE, | 520 FROM_HERE, |
| 520 NewRunnableMethod( | 521 NewRunnableMethod( |
| 521 sb_service_.get(), | 522 sb_service_.get(), |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 742 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 742 EXPECT_EQ(url, resource.url); | 743 EXPECT_EQ(url, resource.url); |
| 743 EXPECT_EQ(url, resource.original_url); | 744 EXPECT_EQ(url, resource.original_url); |
| 744 delete resource.client; | 745 delete resource.client; |
| 745 msg = process()->sink().GetFirstMessageMatching( | 746 msg = process()->sink().GetFirstMessageMatching( |
| 746 SafeBrowsingMsg_StartPhishingDetection::ID); | 747 SafeBrowsingMsg_StartPhishingDetection::ID); |
| 747 ASSERT_FALSE(msg); | 748 ASSERT_FALSE(msg); |
| 748 } | 749 } |
| 749 | 750 |
| 750 } // namespace safe_browsing | 751 } // namespace safe_browsing |
| OLD | NEW |