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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_switches.h" | |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/safe_browsing/client_model.pb.h" | 21 #include "chrome/common/safe_browsing/client_model.pb.h" |
21 #include "chrome/common/safe_browsing/csd.pb.h" | 22 #include "chrome/common/safe_browsing/csd.pb.h" |
22 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 23 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
26 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
27 #include "crypto/sha2.h" | 28 #include "crypto/sha2.h" |
28 #include "google_apis/google_api_keys.h" | 29 #include "google_apis/google_api_keys.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 | 264 |
264 void ClientSideDetectionService::SendModelToRenderers() { | 265 void ClientSideDetectionService::SendModelToRenderers() { |
265 for (content::RenderProcessHost::iterator i( | 266 for (content::RenderProcessHost::iterator i( |
266 content::RenderProcessHost::AllHostsIterator()); | 267 content::RenderProcessHost::AllHostsIterator()); |
267 !i.IsAtEnd(); i.Advance()) { | 268 !i.IsAtEnd(); i.Advance()) { |
268 SendModelToProcess(i.GetCurrentValue()); | 269 SendModelToProcess(i.GetCurrentValue()); |
269 } | 270 } |
270 } | 271 } |
271 | 272 |
272 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { | 273 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { |
274 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
275 switches::kSbDisableAutoUpdate)) | |
276 return; | |
noelutz
2013/04/17 22:36:45
There are two other places in this file where we i
mattm
2013/04/17 23:12:17
I think you're thinking of the MalwareDetails clas
noelutz
2013/04/17 23:36:48
You're absolutely right. Thanks for refreshing my
| |
273 MessageLoop::current()->PostDelayedTask( | 277 MessageLoop::current()->PostDelayedTask( |
274 FROM_HERE, | 278 FROM_HERE, |
275 base::Bind(&ClientSideDetectionService::StartFetchModel, | 279 base::Bind(&ClientSideDetectionService::StartFetchModel, |
276 weak_factory_.GetWeakPtr()), | 280 weak_factory_.GetWeakPtr()), |
277 base::TimeDelta::FromMilliseconds(delay_ms)); | 281 base::TimeDelta::FromMilliseconds(delay_ms)); |
278 } | 282 } |
279 | 283 |
280 void ClientSideDetectionService::StartFetchModel() { | 284 void ClientSideDetectionService::StartFetchModel() { |
281 if (enabled_) { | 285 if (enabled_) { |
282 // Start fetching the model either from the cache or possibly from the | 286 // Start fetching the model either from the cache or possibly from the |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 const std::string& report_url) { | 638 const std::string& report_url) { |
635 std::string url = report_url; | 639 std::string url = report_url; |
636 std::string api_key = google_apis::GetAPIKey(); | 640 std::string api_key = google_apis::GetAPIKey(); |
637 if (!api_key.empty()) { | 641 if (!api_key.empty()) { |
638 base::StringAppendF(&url, "?key=%s", | 642 base::StringAppendF(&url, "?key=%s", |
639 net::EscapeQueryParamValue(api_key, true).c_str()); | 643 net::EscapeQueryParamValue(api_key, true).c_str()); |
640 } | 644 } |
641 return url; | 645 return url; |
642 } | 646 } |
643 } // namespace safe_browsing | 647 } // namespace safe_browsing |
OLD | NEW |