[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / metrics / metrics_service_accessor.cc
1 // Copyright 2014 The Chromium Authors
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 "components/metrics/metrics_service_accessor.h"
6
7 #include "base/base_switches.h"
8 #include "build/branding_buildflags.h"
9 #include "components/metrics/metrics_pref_names.h"
10 #include "components/metrics/metrics_service.h"
11 #include "components/metrics/metrics_switches.h"
12 #include "components/prefs/pref_service.h"
13 #include "components/variations/hashing.h"
14 #include "components/variations/synthetic_trial_registry.h"
15
16 namespace metrics {
17 namespace {
18
19 bool g_force_official_enabled_test = false;
20
21 bool IsMetricsReportingEnabledForOfficialBuild(PrefService* pref_service) {
22   return pref_service->GetBoolean(prefs::kMetricsReportingEnabled);
23 }
24
25 }  // namespace
26
27 // static
28 bool MetricsServiceAccessor::IsMetricsReportingEnabled(
29     PrefService* pref_service) {
30   if (IsMetricsReportingForceEnabled()) {
31     LOG(WARNING) << "Metrics Reporting is force enabled, data will be sent to "
32                     "servers. Should not be used for tests.";
33     return true;
34   }
35 #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
36   return IsMetricsReportingEnabledForOfficialBuild(pref_service);
37 #else
38   // In non-official builds, disable metrics reporting completely.
39   return g_force_official_enabled_test
40              ? IsMetricsReportingEnabledForOfficialBuild(pref_service)
41              : false;
42 #endif  // BUILDFLAG(GOOGLE_CHROME_BRANDING)
43 }
44
45 // static
46 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial(
47     MetricsService* metrics_service,
48     base::StringPiece trial_name,
49     base::StringPiece group_name,
50     variations::SyntheticTrialAnnotationMode annotation_mode) {
51   if (!metrics_service)
52     return false;
53
54   variations::SyntheticTrialGroup trial_group(trial_name, group_name,
55                                               annotation_mode);
56   metrics_service->GetSyntheticTrialRegistry()->RegisterSyntheticFieldTrial(
57       trial_group);
58   return true;
59 }
60
61 // static
62 void MetricsServiceAccessor::SetForceIsMetricsReportingEnabledPrefLookup(
63     bool value) {
64   g_force_official_enabled_test = value;
65 }
66
67 // static
68 bool MetricsServiceAccessor::IsForceMetricsReportingEnabledPrefLookup() {
69   return g_force_official_enabled_test;
70 }
71
72 }  // namespace metrics