Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 3028040: Report malware redirectors as well. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 5
6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 6 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 this, &SafeBrowsingService::OnBlockingPageDone, resources, false)); 743 this, &SafeBrowsingService::OnBlockingPageDone, resources, false));
744 return; 744 return;
745 } 745 }
746 746
747 // Report the malware sub-resource to the SafeBrowsing servers if we have a 747 // Report the malware sub-resource to the SafeBrowsing servers if we have a
748 // malware sub-resource on a safe page and only if the user has opted in to 748 // malware sub-resource on a safe page and only if the user has opted in to
749 // reporting statistics. 749 // reporting statistics.
750 const MetricsService* metrics = g_browser_process->metrics_service(); 750 const MetricsService* metrics = g_browser_process->metrics_service();
751 DCHECK(metrics); 751 DCHECK(metrics);
752 if (metrics && metrics->reporting_active() && 752 if (metrics && metrics->reporting_active() &&
753 resource.resource_type != ResourceType::MAIN_FRAME &&
754 resource.threat_type == SafeBrowsingService::URL_MALWARE) { 753 resource.threat_type == SafeBrowsingService::URL_MALWARE) {
755 GURL page_url = wc->GetURL(); 754 GURL page_url = wc->GetURL();
756 GURL referrer_url; 755 GURL referrer_url;
757 NavigationEntry* entry = wc->controller().GetActiveEntry(); 756 NavigationEntry* entry = wc->controller().GetActiveEntry();
758 if (entry) 757 if (entry)
759 referrer_url = entry->referrer(); 758 referrer_url = entry->referrer();
760 ChromeThread::PostTask( 759
761 ChromeThread::IO, FROM_HERE, 760 if (resource.url != page_url || !referrer_url.is_empty()) {
762 NewRunnableMethod(this, 761 bool is_subresource = resource.resource_type != ResourceType::MAIN_FRAME;
763 &SafeBrowsingService::ReportMalware, 762 ChromeThread::PostTask(
764 resource.url, 763 ChromeThread::IO, FROM_HERE,
765 page_url, 764 NewRunnableMethod(this,
766 referrer_url)); 765 &SafeBrowsingService::ReportMalware,
766 resource.url,
767 page_url,
768 referrer_url,
769 is_subresource));
770 }
767 } 771 }
768 772
769 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource); 773 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
770 } 774 }
771 775
772 void SafeBrowsingService::ReportMalware(const GURL& malware_url, 776 void SafeBrowsingService::ReportMalware(const GURL& malware_url,
773 const GURL& page_url, 777 const GURL& page_url,
774 const GURL& referrer_url) { 778 const GURL& referrer_url,
779 bool is_subresource) {
775 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 780 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
776 781
777 if (!enabled_) 782 if (!enabled_)
778 return; 783 return;
779 784
780 if (DatabaseAvailable()) { 785 if (DatabaseAvailable()) {
781 // Check if 'page_url' is already blacklisted (exists in our cache). Only 786 // Check if 'page_url' is already blacklisted (exists in our cache). Only
782 // report if it's not there. 787 // report if it's not there. This can happen if the user has ignored
788 // the warning for page_url and is now hitting a warning for a resource.
783 std::string list; 789 std::string list;
784 std::vector<SBPrefix> prefix_hits; 790 std::vector<SBPrefix> prefix_hits;
785 std::vector<SBFullHashResult> full_hits; 791 std::vector<SBFullHashResult> full_hits;
786 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits, 792 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits,
787 protocol_manager_->last_update()); 793 protocol_manager_->last_update());
788 if (!full_hits.empty()) 794 if (!full_hits.empty())
789 return; 795 return;
790 } 796 }
791 797
792 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url); 798 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url,
799 is_subresource);
793 } 800 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698