| 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 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/location.h" | 11 #include "base/location.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.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 "components/variations/service/variations_service.h" | 17 #include "components/variations/service/variations_service.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 | 19 |
| 19 namespace safe_browsing { | 20 namespace safe_browsing { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 void VerifyVariationsSeedSignatureOnUIThread( | 24 void VerifyVariationsSeedSignatureOnUIThread( |
| 24 scoped_ptr<IncidentReceiver> incident_receiver) { | 25 scoped_ptr<IncidentReceiver> incident_receiver) { |
| 25 variations::VariationsService* variations_service = | 26 variations::VariationsService* variations_service = |
| 26 g_browser_process->variations_service(); | 27 g_browser_process->variations_service(); |
| 27 if (!variations_service) | 28 if (!variations_service) |
| 28 return; | 29 return; |
| 29 std::string invalid_signature = | 30 std::string invalid_signature = |
| 30 variations_service->GetInvalidVariationsSeedSignature(); | 31 variations_service->GetInvalidVariationsSeedSignature(); |
| 31 if (!invalid_signature.empty()) { | 32 if (!invalid_signature.empty()) { |
| 32 scoped_ptr< | 33 scoped_ptr< |
| 33 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident> | 34 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident> |
| 34 variations_seed_signature( | 35 variations_seed_signature( |
| 35 new ClientIncidentReport_IncidentData_VariationsSeedSignatureInciden
t()); | 36 new ClientIncidentReport_IncidentData_VariationsSeedSignatureInciden
t()); |
| 36 variations_seed_signature->set_variations_seed_signature(invalid_signature); | 37 variations_seed_signature->set_variations_seed_signature(invalid_signature); |
| 37 incident_receiver->AddIncidentForProcess(make_scoped_ptr( | 38 incident_receiver->AddIncidentForProcess( |
| 38 new VariationsSeedSignatureIncident(variations_seed_signature.Pass()))); | 39 make_scoped_ptr(new VariationsSeedSignatureIncident( |
| 40 std::move(variations_seed_signature)))); |
| 39 } | 41 } |
| 40 } | 42 } |
| 41 | 43 |
| 42 } // namespace | 44 } // namespace |
| 43 | 45 |
| 44 void RegisterVariationsSeedSignatureAnalysis() { | 46 void RegisterVariationsSeedSignatureAnalysis() { |
| 45 scoped_refptr<SafeBrowsingService> safe_browsing_service( | 47 scoped_refptr<SafeBrowsingService> safe_browsing_service( |
| 46 g_browser_process->safe_browsing_service()); | 48 g_browser_process->safe_browsing_service()); |
| 47 | 49 |
| 48 safe_browsing_service->RegisterDelayedAnalysisCallback( | 50 safe_browsing_service->RegisterDelayedAnalysisCallback( |
| 49 base::Bind(&VerifyVariationsSeedSignature)); | 51 base::Bind(&VerifyVariationsSeedSignature)); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void VerifyVariationsSeedSignature( | 54 void VerifyVariationsSeedSignature( |
| 53 scoped_ptr<IncidentReceiver> incident_receiver) { | 55 scoped_ptr<IncidentReceiver> incident_receiver) { |
| 54 content::BrowserThread::PostTask( | 56 content::BrowserThread::PostTask( |
| 55 content::BrowserThread::UI, | 57 content::BrowserThread::UI, |
| 56 FROM_HERE, | 58 FROM_HERE, |
| 57 base::Bind(&VerifyVariationsSeedSignatureOnUIThread, | 59 base::Bind(&VerifyVariationsSeedSignatureOnUIThread, |
| 58 base::Passed(&incident_receiver))); | 60 base::Passed(&incident_receiver))); |
| 59 } | 61 } |
| 60 | 62 |
| 61 } // namespace safe_browsing | 63 } // namespace safe_browsing |
| OLD | NEW |