| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 void ClientSideDetectionService::SendModelToRenderers() { | 253 void ClientSideDetectionService::SendModelToRenderers() { |
| 254 for (content::RenderProcessHost::iterator i( | 254 for (content::RenderProcessHost::iterator i( |
| 255 content::RenderProcessHost::AllHostsIterator()); | 255 content::RenderProcessHost::AllHostsIterator()); |
| 256 !i.IsAtEnd(); i.Advance()) { | 256 !i.IsAtEnd(); i.Advance()) { |
| 257 SendModelToProcess(i.GetCurrentValue()); | 257 SendModelToProcess(i.GetCurrentValue()); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { | 261 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { |
| 262 if (CommandLine::ForCurrentProcess()->HasSwitch( | 262 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 263 switches::kSbDisableAutoUpdate)) | 263 switches::kSbDisableAutoUpdate)) |
| 264 return; | 264 return; |
| 265 base::MessageLoop::current()->PostDelayedTask( | 265 base::MessageLoop::current()->PostDelayedTask( |
| 266 FROM_HERE, | 266 FROM_HERE, |
| 267 base::Bind(&ClientSideDetectionService::StartFetchModel, | 267 base::Bind(&ClientSideDetectionService::StartFetchModel, |
| 268 weak_factory_.GetWeakPtr()), | 268 weak_factory_.GetWeakPtr()), |
| 269 base::TimeDelta::FromMilliseconds(delay_ms)); | 269 base::TimeDelta::FromMilliseconds(delay_ms)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ClientSideDetectionService::StartFetchModel() { | 272 void ClientSideDetectionService::StartFetchModel() { |
| 273 if (enabled_) { | 273 if (enabled_) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 GURL ClientSideDetectionService::GetClientReportUrl( | 635 GURL ClientSideDetectionService::GetClientReportUrl( |
| 636 const std::string& report_url) { | 636 const std::string& report_url) { |
| 637 GURL url(report_url); | 637 GURL url(report_url); |
| 638 std::string api_key = google_apis::GetAPIKey(); | 638 std::string api_key = google_apis::GetAPIKey(); |
| 639 if (!api_key.empty()) | 639 if (!api_key.empty()) |
| 640 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 640 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 641 | 641 |
| 642 return url; | 642 return url; |
| 643 } | 643 } |
| 644 } // namespace safe_browsing | 644 } // namespace safe_browsing |
| OLD | NEW |