| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/incident_reporting/variations_seed_signat
ure_analyzer.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_analyzer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/metrics/variations/variations_service.h" | 12 #include "chrome/browser/metrics/variations/variations_service.h" |
| 13 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" |
| 13 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_incident.h" | 14 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_incident.h" |
| 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 15 #include "chrome/common/safe_browsing/csd.pb.h" | 16 #include "chrome/common/safe_browsing/csd.pb.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 | 18 |
| 18 namespace safe_browsing { | 19 namespace safe_browsing { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 void VerifyVariationsSeedSignatureOnUIThread( | 23 void VerifyVariationsSeedSignatureOnUIThread( |
| 23 const AddIncidentCallback& callback) { | 24 scoped_ptr<IncidentReceiver> incident_receiver) { |
| 24 chrome_variations::VariationsService* variations_service = | 25 chrome_variations::VariationsService* variations_service = |
| 25 g_browser_process->variations_service(); | 26 g_browser_process->variations_service(); |
| 26 if (!variations_service) | 27 if (!variations_service) |
| 27 return; | 28 return; |
| 28 std::string invalid_signature = | 29 std::string invalid_signature = |
| 29 variations_service->GetInvalidVariationsSeedSignature(); | 30 variations_service->GetInvalidVariationsSeedSignature(); |
| 30 if (!invalid_signature.empty()) { | 31 if (!invalid_signature.empty()) { |
| 31 scoped_ptr< | 32 scoped_ptr< |
| 32 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident> | 33 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident> |
| 33 variations_seed_signature( | 34 variations_seed_signature( |
| 34 new ClientIncidentReport_IncidentData_VariationsSeedSignatureInciden
t()); | 35 new ClientIncidentReport_IncidentData_VariationsSeedSignatureInciden
t()); |
| 35 variations_seed_signature->set_variations_seed_signature(invalid_signature); | 36 variations_seed_signature->set_variations_seed_signature(invalid_signature); |
| 36 callback.Run(make_scoped_ptr( | 37 incident_receiver->AddIncidentForProcess(make_scoped_ptr( |
| 37 new VariationsSeedSignatureIncident(variations_seed_signature.Pass()))); | 38 new VariationsSeedSignatureIncident(variations_seed_signature.Pass()))); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 void RegisterVariationsSeedSignatureAnalysis() { | 44 void RegisterVariationsSeedSignatureAnalysis() { |
| 44 scoped_refptr<SafeBrowsingService> safe_browsing_service( | 45 scoped_refptr<SafeBrowsingService> safe_browsing_service( |
| 45 g_browser_process->safe_browsing_service()); | 46 g_browser_process->safe_browsing_service()); |
| 46 | 47 |
| 47 safe_browsing_service->RegisterDelayedAnalysisCallback( | 48 safe_browsing_service->RegisterDelayedAnalysisCallback( |
| 48 base::Bind(&VerifyVariationsSeedSignature)); | 49 base::Bind(&VerifyVariationsSeedSignature)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void VerifyVariationsSeedSignature(const AddIncidentCallback& callback) { | 52 void VerifyVariationsSeedSignature( |
| 53 scoped_ptr<IncidentReceiver> incident_receiver) { |
| 52 content::BrowserThread::PostTask( | 54 content::BrowserThread::PostTask( |
| 53 content::BrowserThread::UI, | 55 content::BrowserThread::UI, |
| 54 FROM_HERE, | 56 FROM_HERE, |
| 55 base::Bind(&VerifyVariationsSeedSignatureOnUIThread, callback)); | 57 base::Bind(&VerifyVariationsSeedSignatureOnUIThread, |
| 58 base::Passed(&incident_receiver))); |
| 56 } | 59 } |
| 57 | 60 |
| 58 } // namespace safe_browsing | 61 } // namespace safe_browsing |
| OLD | NEW |