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_service.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 new ModelLoader(update_renderers, request_context_getter, false)); | 101 new ModelLoader(update_renderers, request_context_getter, false)); |
102 model_loader_extended_.reset( | 102 model_loader_extended_.reset( |
103 new ModelLoader(update_renderers, request_context_getter, true)); | 103 new ModelLoader(update_renderers, request_context_getter, true)); |
104 | 104 |
105 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 105 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
106 content::NotificationService::AllBrowserContextsAndSources()); | 106 content::NotificationService::AllBrowserContextsAndSources()); |
107 } | 107 } |
108 | 108 |
109 ClientSideDetectionService::~ClientSideDetectionService() { | 109 ClientSideDetectionService::~ClientSideDetectionService() { |
110 weak_factory_.InvalidateWeakPtrs(); | 110 weak_factory_.InvalidateWeakPtrs(); |
111 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), | 111 base::STLDeleteContainerPairPointers(client_phishing_reports_.begin(), |
112 client_phishing_reports_.end()); | 112 client_phishing_reports_.end()); |
113 client_phishing_reports_.clear(); | 113 client_phishing_reports_.clear(); |
114 STLDeleteContainerPairPointers(client_malware_reports_.begin(), | 114 base::STLDeleteContainerPairPointers(client_malware_reports_.begin(), |
115 client_malware_reports_.end()); | 115 client_malware_reports_.end()); |
116 client_malware_reports_.clear(); | 116 client_malware_reports_.clear(); |
117 } | 117 } |
118 | 118 |
119 // static | 119 // static |
120 ClientSideDetectionService* ClientSideDetectionService::Create( | 120 ClientSideDetectionService* ClientSideDetectionService::Create( |
121 net::URLRequestContextGetter* request_context_getter) { | 121 net::URLRequestContextGetter* request_context_getter) { |
122 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 122 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
123 return new ClientSideDetectionService(request_context_getter); | 123 return new ClientSideDetectionService(request_context_getter); |
124 } | 124 } |
125 | 125 |
(...skipping 16 matching lines...) Expand all Loading... |
142 model_loader_standard_->CancelFetcher(); | 142 model_loader_standard_->CancelFetcher(); |
143 model_loader_extended_->CancelFetcher(); | 143 model_loader_extended_->CancelFetcher(); |
144 // Invoke pending callbacks with a false verdict. | 144 // Invoke pending callbacks with a false verdict. |
145 for (std::map<const net::URLFetcher*, ClientReportInfo*>::iterator it = | 145 for (std::map<const net::URLFetcher*, ClientReportInfo*>::iterator it = |
146 client_phishing_reports_.begin(); | 146 client_phishing_reports_.begin(); |
147 it != client_phishing_reports_.end(); ++it) { | 147 it != client_phishing_reports_.end(); ++it) { |
148 ClientReportInfo* info = it->second; | 148 ClientReportInfo* info = it->second; |
149 if (!info->callback.is_null()) | 149 if (!info->callback.is_null()) |
150 info->callback.Run(info->phishing_url, false); | 150 info->callback.Run(info->phishing_url, false); |
151 } | 151 } |
152 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), | 152 base::STLDeleteContainerPairPointers(client_phishing_reports_.begin(), |
153 client_phishing_reports_.end()); | 153 client_phishing_reports_.end()); |
154 client_phishing_reports_.clear(); | 154 client_phishing_reports_.clear(); |
155 for (std::map<const net::URLFetcher*, ClientMalwareReportInfo*>::iterator it | 155 for (std::map<const net::URLFetcher*, ClientMalwareReportInfo*>::iterator it |
156 = client_malware_reports_.begin(); | 156 = client_malware_reports_.begin(); |
157 it != client_malware_reports_.end(); ++it) { | 157 it != client_malware_reports_.end(); ++it) { |
158 ClientMalwareReportInfo* info = it->second; | 158 ClientMalwareReportInfo* info = it->second; |
159 if (!info->callback.is_null()) | 159 if (!info->callback.is_null()) |
160 info->callback.Run(info->original_url, info->original_url, false); | 160 info->callback.Run(info->original_url, info->original_url, false); |
161 } | 161 } |
162 STLDeleteContainerPairPointers(client_malware_reports_.begin(), | 162 base::STLDeleteContainerPairPointers(client_malware_reports_.begin(), |
163 client_malware_reports_.end()); | 163 client_malware_reports_.end()); |
164 client_malware_reports_.clear(); | 164 client_malware_reports_.clear(); |
165 cache_.clear(); | 165 cache_.clear(); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 void ClientSideDetectionService::SendClientReportPhishingRequest( | 169 void ClientSideDetectionService::SendClientReportPhishingRequest( |
170 ClientPhishingRequest* verdict, | 170 ClientPhishingRequest* verdict, |
171 bool is_extended_reporting, | 171 bool is_extended_reporting, |
172 const ClientReportPhishingRequestCallback& callback) { | 172 const ClientReportPhishingRequestCallback& callback) { |
173 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 173 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 const std::string& report_url) { | 517 const std::string& report_url) { |
518 GURL url(report_url); | 518 GURL url(report_url); |
519 std::string api_key = google_apis::GetAPIKey(); | 519 std::string api_key = google_apis::GetAPIKey(); |
520 if (!api_key.empty()) | 520 if (!api_key.empty()) |
521 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 521 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
522 | 522 |
523 return url; | 523 return url; |
524 } | 524 } |
525 | 525 |
526 } // namespace safe_browsing | 526 } // namespace safe_browsing |
OLD | NEW |