OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_analyzer.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/location.h" |
| 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/metrics/variations/variations_service.h" |
| 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 14 #include "chrome/common/safe_browsing/csd.pb.h" |
| 15 #include "content/public/browser/browser_thread.h" |
| 16 |
| 17 namespace safe_browsing { |
| 18 |
| 19 namespace { |
| 20 |
| 21 void VerifyVariationsSeedSignatureOnUIThread( |
| 22 const AddIncidentCallback& callback) { |
| 23 chrome_variations::VariationsService* variations_service = |
| 24 g_browser_process->variations_service(); |
| 25 if (!variations_service) |
| 26 return; |
| 27 std::string invalid_signature = |
| 28 variations_service->GetInvalidVariationsSeedSignature(); |
| 29 if (!invalid_signature.empty()) { |
| 30 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( |
| 31 new ClientIncidentReport_IncidentData()); |
| 32 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident* |
| 33 variations_seed_signature = |
| 34 incident_data->mutable_variations_seed_signature(); |
| 35 variations_seed_signature->set_variations_seed_signature(invalid_signature); |
| 36 callback.Run(incident_data.Pass()); |
| 37 } |
| 38 } |
| 39 |
| 40 } // namespace |
| 41 |
| 42 void RegisterVariationsSeedSignatureAnalysis() { |
| 43 scoped_refptr<SafeBrowsingService> safe_browsing_service( |
| 44 g_browser_process->safe_browsing_service()); |
| 45 |
| 46 safe_browsing_service->RegisterDelayedAnalysisCallback( |
| 47 base::Bind(&VerifyVariationsSeedSignature)); |
| 48 } |
| 49 |
| 50 void VerifyVariationsSeedSignature(const AddIncidentCallback& callback) { |
| 51 content::BrowserThread::PostTask( |
| 52 content::BrowserThread::UI, |
| 53 FROM_HERE, |
| 54 base::Bind(&VerifyVariationsSeedSignatureOnUIThread, callback)); |
| 55 } |
| 56 |
| 57 } // namespace safe_browsing |
OLD | NEW |