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 // Helper class which handles communication with the SafeBrowsing backends for | 5 // Helper class which handles communication with the SafeBrowsing backends for |
6 // client-side phishing detection. This class is used to fetch the client-side | 6 // client-side phishing detection. This class is used to fetch the client-side |
7 // model and send it to all renderers. This class is also used to send a ping | 7 // model and send it to all renderers. This class is also used to send a ping |
8 // back to Google to verify if a particular site is really phishing or not. | 8 // back to Google to verify if a particular site is really phishing or not. |
9 // | 9 // |
10 // This class is not thread-safe and expects all calls to be made on the UI | 10 // This class is not thread-safe and expects all calls to be made on the UI |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // Get the number of malware reports that we have sent over kReportsInterval. | 252 // Get the number of malware reports that we have sent over kReportsInterval. |
253 int GetMalwareNumReports(); | 253 int GetMalwareNumReports(); |
254 | 254 |
255 // Get the number of phishing reports that we have sent over kReportsInterval. | 255 // Get the number of phishing reports that we have sent over kReportsInterval. |
256 int GetPhishingNumReports(); | 256 int GetPhishingNumReports(); |
257 | 257 |
258 // Get the number of reports that we have sent over kReportsInterval, and | 258 // Get the number of reports that we have sent over kReportsInterval, and |
259 // trims off the old elements. | 259 // trims off the old elements. |
260 int GetNumReports(std::queue<base::Time>* report_times); | 260 int GetNumReports(std::queue<base::Time>* report_times); |
261 | 261 |
262 // Initializes the |private_networks_| vector with the network blocks | |
263 // that we consider non-public IP addresses. Returns true on success. | |
264 bool InitializePrivateNetworks(); | |
265 | |
266 // Send the model to the given renderer. | 262 // Send the model to the given renderer. |
267 void SendModelToProcess(content::RenderProcessHost* process); | 263 void SendModelToProcess(content::RenderProcessHost* process); |
268 | 264 |
269 // Same as above but sends the model to all rendereres. | 265 // Same as above but sends the model to all rendereres. |
270 void SendModelToRenderers(); | 266 void SendModelToRenderers(); |
271 | 267 |
272 // Reads the bad subnets from the client model and inserts them into | 268 // Reads the bad subnets from the client model and inserts them into |
273 // |bad_subnets| for faster lookups. This method is static to simplify | 269 // |bad_subnets| for faster lookups. This method is static to simplify |
274 // testing. | 270 // testing. |
275 static void SetBadSubnets(const ClientSideModel& model, | 271 static void SetBadSubnets(const ClientSideModel& model, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // of malware requests that we send in a day. | 316 // of malware requests that we send in a day. |
321 std::queue<base::Time> malware_report_times_; | 317 std::queue<base::Time> malware_report_times_; |
322 | 318 |
323 // Used to asynchronously call the callbacks for | 319 // Used to asynchronously call the callbacks for |
324 // SendClientReportPhishingRequest. | 320 // SendClientReportPhishingRequest. |
325 base::WeakPtrFactory<ClientSideDetectionService> weak_factory_; | 321 base::WeakPtrFactory<ClientSideDetectionService> weak_factory_; |
326 | 322 |
327 // The context we use to issue network requests. | 323 // The context we use to issue network requests. |
328 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 324 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
329 | 325 |
330 // The network blocks that we consider private IP address ranges. | |
331 std::vector<AddressRange> private_networks_; | |
332 | |
333 // Map of bad subnets which are copied from the client model and put into | 326 // Map of bad subnets which are copied from the client model and put into |
334 // this map to speed up lookups. | 327 // this map to speed up lookups. |
335 BadSubnetMap bad_subnets_; | 328 BadSubnetMap bad_subnets_; |
336 | 329 |
337 content::NotificationRegistrar registrar_; | 330 content::NotificationRegistrar registrar_; |
338 | 331 |
339 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); | 332 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); |
340 }; | 333 }; |
341 } // namespace safe_browsing | 334 } // namespace safe_browsing |
342 | 335 |
343 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ | 336 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ |
OLD | NEW |