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 "chrome/browser/safe_browsing/client_side_detection_service.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util_proxy.h" | 8 #include "base/file_util_proxy.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 }; | 59 }; |
60 | 60 |
61 ClientSideDetectionService::CacheState::CacheState(bool phish, base::Time time) | 61 ClientSideDetectionService::CacheState::CacheState(bool phish, base::Time time) |
62 : is_phishing(phish), | 62 : is_phishing(phish), |
63 timestamp(time) {} | 63 timestamp(time) {} |
64 | 64 |
65 ClientSideDetectionService::ClientSideDetectionService( | 65 ClientSideDetectionService::ClientSideDetectionService( |
66 net::URLRequestContextGetter* request_context_getter) | 66 net::URLRequestContextGetter* request_context_getter) |
67 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 67 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
68 request_context_getter_(request_context_getter) { | 68 request_context_getter_(request_context_getter) { |
69 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CREATED, | 69 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
70 NotificationService::AllSources()); | 70 NotificationService::AllSources()); |
71 } | 71 } |
72 | 72 |
73 ClientSideDetectionService::~ClientSideDetectionService() { | 73 ClientSideDetectionService::~ClientSideDetectionService() { |
74 method_factory_.RevokeAll(); | 74 method_factory_.RevokeAll(); |
75 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), | 75 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), |
76 client_phishing_reports_.end()); | 76 client_phishing_reports_.end()); |
77 client_phishing_reports_.clear(); | 77 client_phishing_reports_.clear(); |
78 } | 78 } |
79 | 79 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (source == model_fetcher_.get()) { | 182 if (source == model_fetcher_.get()) { |
183 HandleModelResponse(source, url, status, response_code, cookies, data); | 183 HandleModelResponse(source, url, status, response_code, cookies, data); |
184 } else if (client_phishing_reports_.find(source) != | 184 } else if (client_phishing_reports_.find(source) != |
185 client_phishing_reports_.end()) { | 185 client_phishing_reports_.end()) { |
186 HandlePhishingVerdict(source, url, status, response_code, cookies, data); | 186 HandlePhishingVerdict(source, url, status, response_code, cookies, data); |
187 } else { | 187 } else { |
188 NOTREACHED(); | 188 NOTREACHED(); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 void ClientSideDetectionService::Observe(NotificationType type, | 192 void ClientSideDetectionService::Observe(int type, |
193 const NotificationSource& source, | 193 const NotificationSource& source, |
194 const NotificationDetails& details) { | 194 const NotificationDetails& details) { |
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
196 DCHECK(type == NotificationType::RENDERER_PROCESS_CREATED); | 196 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CREATED); |
197 if (!model_.get()) { | 197 if (!model_.get()) { |
198 // Model might not be ready or maybe there was an error. | 198 // Model might not be ready or maybe there was an error. |
199 return; | 199 return; |
200 } | 200 } |
201 SendModelToProcess(Source<RenderProcessHost>(source).ptr()); | 201 SendModelToProcess(Source<RenderProcessHost>(source).ptr()); |
202 } | 202 } |
203 | 203 |
204 void ClientSideDetectionService::SendModelToProcess( | 204 void ClientSideDetectionService::SendModelToProcess( |
205 RenderProcessHost* process) { | 205 RenderProcessHost* process) { |
206 VLOG(2) << "Sending phishing model to renderer"; | 206 VLOG(2) << "Sending phishing model to renderer"; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // |size| bits sets to one. | 464 // |size| bits sets to one. |
465 std::string mask(net::kIPv6AddressSize, '\x00'); | 465 std::string mask(net::kIPv6AddressSize, '\x00'); |
466 mask.replace(0, size / 8, size / 8, '\xFF'); | 466 mask.replace(0, size / 8, size / 8, '\xFF'); |
467 if (size % 8) { | 467 if (size % 8) { |
468 mask[size / 8] = 0xFF << (8 - (size % 8)); | 468 mask[size / 8] = 0xFF << (8 - (size % 8)); |
469 } | 469 } |
470 (*bad_subnets)[mask].insert(model.bad_subnet(i).prefix()); | 470 (*bad_subnets)[mask].insert(model.bad_subnet(i).prefix()); |
471 } | 471 } |
472 } | 472 } |
473 } // namespace safe_browsing | 473 } // namespace safe_browsing |
OLD | NEW |