Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / safe_browsing / incident_reporting / variations_seed_signature_analyzer.cc
blob4b53accbe17b2eb4b481f3d3b041bd396595604a
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.
5 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signature_analyzer.h"
7 #include <string>
9 #include "base/bind.h"
10 #include "base/location.h"
11 #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/variations_seed_signature_incident.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/common/safe_browsing/csd.pb.h"
16 #include "components/variations/service/variations_service.h"
17 #include "content/public/browser/browser_thread.h"
19 namespace safe_browsing {
21 namespace {
23 void VerifyVariationsSeedSignatureOnUIThread(
24 scoped_ptr<IncidentReceiver> incident_receiver) {
25 variations::VariationsService* variations_service =
26 g_browser_process->variations_service();
27 if (!variations_service)
28 return;
29 std::string invalid_signature =
30 variations_service->GetInvalidVariationsSeedSignature();
31 if (!invalid_signature.empty()) {
32 scoped_ptr<
33 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident>
34 variations_seed_signature(
35 new ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident());
36 variations_seed_signature->set_variations_seed_signature(invalid_signature);
37 incident_receiver->AddIncidentForProcess(make_scoped_ptr(
38 new VariationsSeedSignatureIncident(variations_seed_signature.Pass())));
42 } // namespace
44 void RegisterVariationsSeedSignatureAnalysis() {
45 scoped_refptr<SafeBrowsingService> safe_browsing_service(
46 g_browser_process->safe_browsing_service());
48 safe_browsing_service->RegisterDelayedAnalysisCallback(
49 base::Bind(&VerifyVariationsSeedSignature));
52 void VerifyVariationsSeedSignature(
53 scoped_ptr<IncidentReceiver> incident_receiver) {
54 content::BrowserThread::PostTask(
55 content::BrowserThread::UI,
56 FROM_HERE,
57 base::Bind(&VerifyVariationsSeedSignatureOnUIThread,
58 base::Passed(&incident_receiver)));
61 } // namespace safe_browsing