| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 params, | 402 params, |
| 403 base::Bind(&ClientSideDetectionHost::OnPhishingPreClassificationDone, | 403 base::Bind(&ClientSideDetectionHost::OnPhishingPreClassificationDone, |
| 404 weak_factory_.GetWeakPtr()), | 404 weak_factory_.GetWeakPtr()), |
| 405 base::Bind(&ClientSideDetectionHost::OnMalwarePreClassificationDone, | 405 base::Bind(&ClientSideDetectionHost::OnMalwarePreClassificationDone, |
| 406 weak_factory_.GetWeakPtr()), | 406 weak_factory_.GetWeakPtr()), |
| 407 web_contents(), csd_service_, database_manager_.get(), this); | 407 web_contents(), csd_service_, database_manager_.get(), this); |
| 408 classification_request_->Start(); | 408 classification_request_->Start(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 void ClientSideDetectionHost::OnSafeBrowsingHit( | 411 void ClientSideDetectionHost::OnSafeBrowsingHit( |
| 412 const SafeBrowsingUIManager::UnsafeResource& resource) { | 412 const security_interstitials::UnsafeResource& resource) { |
| 413 if (!web_contents()) | 413 if (!web_contents()) |
| 414 return; | 414 return; |
| 415 | 415 |
| 416 // Check that the hit is either malware or phishing. | 416 // Check that the hit is either malware or phishing. |
| 417 if (resource.threat_type != SB_THREAT_TYPE_URL_PHISHING && | 417 if (resource.threat_type != SB_THREAT_TYPE_URL_PHISHING && |
| 418 resource.threat_type != SB_THREAT_TYPE_URL_MALWARE) | 418 resource.threat_type != SB_THREAT_TYPE_URL_MALWARE) |
| 419 return; | 419 return; |
| 420 | 420 |
| 421 // Check that this notification is really for us. | 421 // Check that this notification is really for us. |
| 422 if (web_contents() != resource.web_contents_getter.Run()) | 422 if (web_contents() != resource.web_contents_getter.Run()) |
| 423 return; | 423 return; |
| 424 | 424 |
| 425 NavigationEntry* entry = resource.GetNavigationEntryForResource(); | 425 NavigationEntry* entry = resource.GetNavigationEntryForResource(); |
| 426 if (!entry) | 426 if (!entry) |
| 427 return; | 427 return; |
| 428 | 428 |
| 429 // Store the unique page ID for later. | 429 // Store the unique page ID for later. |
| 430 unsafe_unique_page_id_ = entry->GetUniqueID(); | 430 unsafe_unique_page_id_ = entry->GetUniqueID(); |
| 431 | 431 |
| 432 // We also keep the resource around in order to be able to send the | 432 // We also keep the resource around in order to be able to send the |
| 433 // malicious URL to the server. | 433 // malicious URL to the server. |
| 434 unsafe_resource_.reset(new SafeBrowsingUIManager::UnsafeResource(resource)); | 434 unsafe_resource_.reset(new security_interstitials::UnsafeResource(resource)); |
| 435 unsafe_resource_->callback.Reset(); // Don't do anything stupid. | 435 unsafe_resource_->callback.Reset(); // Don't do anything stupid. |
| 436 } | 436 } |
| 437 | 437 |
| 438 scoped_refptr<SafeBrowsingDatabaseManager> | 438 scoped_refptr<SafeBrowsingDatabaseManager> |
| 439 ClientSideDetectionHost::database_manager() { | 439 ClientSideDetectionHost::database_manager() { |
| 440 return database_manager_; | 440 return database_manager_; |
| 441 } | 441 } |
| 442 | 442 |
| 443 void ClientSideDetectionHost::WebContentsDestroyed() { | 443 void ClientSideDetectionHost::WebContentsDestroyed() { |
| 444 // Tell any pending classification request that it is being canceled. | 444 // Tell any pending classification request that it is being canceled. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 bool is_phishing) { | 548 bool is_phishing) { |
| 549 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 549 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 550 DVLOG(2) << "Received server phishing verdict for URL:" << phishing_url | 550 DVLOG(2) << "Received server phishing verdict for URL:" << phishing_url |
| 551 << " is_phishing:" << is_phishing; | 551 << " is_phishing:" << is_phishing; |
| 552 UMA_HISTOGRAM_BOOLEAN( | 552 UMA_HISTOGRAM_BOOLEAN( |
| 553 "SBClientPhishing.ServerDeterminesPhishing", | 553 "SBClientPhishing.ServerDeterminesPhishing", |
| 554 is_phishing); | 554 is_phishing); |
| 555 if (is_phishing) { | 555 if (is_phishing) { |
| 556 DCHECK(web_contents()); | 556 DCHECK(web_contents()); |
| 557 if (ui_manager_.get()) { | 557 if (ui_manager_.get()) { |
| 558 SafeBrowsingUIManager::UnsafeResource resource; | 558 security_interstitials::UnsafeResource resource; |
| 559 resource.url = phishing_url; | 559 resource.url = phishing_url; |
| 560 resource.original_url = phishing_url; | 560 resource.original_url = phishing_url; |
| 561 resource.is_subresource = false; | 561 resource.is_subresource = false; |
| 562 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; | 562 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; |
| 563 resource.threat_source = | 563 resource.threat_source = |
| 564 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION; | 564 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION; |
| 565 resource.web_contents_getter = safe_browsing::SafeBrowsingUIManager:: | 565 resource.web_contents_getter = safe_browsing::SafeBrowsingUIManager:: |
| 566 UnsafeResource::GetWebContentsGetter( | 566 UnsafeResource::GetWebContentsGetter( |
| 567 web_contents()->GetRenderProcessHost()->GetID(), | 567 web_contents()->GetRenderProcessHost()->GetID(), |
| 568 web_contents()->GetMainFrame()->GetRoutingID()); | 568 web_contents()->GetMainFrame()->GetRoutingID()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 584 bool is_malware) { | 584 bool is_malware) { |
| 585 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 585 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 586 DVLOG(2) << "Received server malawre IP verdict for URL:" << malware_url | 586 DVLOG(2) << "Received server malawre IP verdict for URL:" << malware_url |
| 587 << " is_malware:" << is_malware; | 587 << " is_malware:" << is_malware; |
| 588 UMA_HISTOGRAM_BOOLEAN( | 588 UMA_HISTOGRAM_BOOLEAN( |
| 589 "SBClientMalware.ServerDeterminesMalware", | 589 "SBClientMalware.ServerDeterminesMalware", |
| 590 is_malware); | 590 is_malware); |
| 591 if (is_malware && malware_url.is_valid() && original_url.is_valid()) { | 591 if (is_malware && malware_url.is_valid() && original_url.is_valid()) { |
| 592 DCHECK(web_contents()); | 592 DCHECK(web_contents()); |
| 593 if (ui_manager_.get()) { | 593 if (ui_manager_.get()) { |
| 594 SafeBrowsingUIManager::UnsafeResource resource; | 594 security_interstitials::UnsafeResource resource; |
| 595 resource.url = malware_url; | 595 resource.url = malware_url; |
| 596 resource.original_url = original_url; | 596 resource.original_url = original_url; |
| 597 resource.is_subresource = (malware_url.host() != original_url.host()); | 597 resource.is_subresource = (malware_url.host() != original_url.host()); |
| 598 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; | 598 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; |
| 599 resource.threat_source = | 599 resource.threat_source = |
| 600 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION; | 600 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION; |
| 601 resource.web_contents_getter = safe_browsing::SafeBrowsingUIManager:: | 601 resource.web_contents_getter = safe_browsing::SafeBrowsingUIManager:: |
| 602 UnsafeResource::GetWebContentsGetter( | 602 UnsafeResource::GetWebContentsGetter( |
| 603 web_contents()->GetRenderProcessHost()->GetID(), | 603 web_contents()->GetRenderProcessHost()->GetID(), |
| 604 web_contents()->GetMainFrame()->GetRoutingID()); | 604 web_contents()->GetMainFrame()->GetRoutingID()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 ui_manager_->RemoveObserver(this); | 715 ui_manager_->RemoveObserver(this); |
| 716 | 716 |
| 717 ui_manager_ = ui_manager; | 717 ui_manager_ = ui_manager; |
| 718 if (ui_manager) | 718 if (ui_manager) |
| 719 ui_manager_->AddObserver(this); | 719 ui_manager_->AddObserver(this); |
| 720 | 720 |
| 721 database_manager_ = database_manager; | 721 database_manager_ = database_manager; |
| 722 } | 722 } |
| 723 | 723 |
| 724 } // namespace safe_browsing | 724 } // namespace safe_browsing |
| OLD | NEW |