Home | History | Annotate | Download | only in metrics
      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 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_
      6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_
      7 
      8 #include "base/gtest_prod_util.h"
      9 #include "base/macros.h"
     10 #include "chrome/browser/metrics/metrics_service_accessor.h"
     11 
     12 class ChromeBrowserMetricsServiceObserver;
     13 class Profile;
     14 
     15 namespace {
     16 class CrashesDOMHandler;
     17 class FlashDOMHandler;
     18 }
     19 
     20 namespace extensions {
     21 class ExtensionDownloader;
     22 class ManifestFetchData;
     23 class MetricsPrivateGetIsCrashReportingEnabledFunction;
     24 }
     25 
     26 namespace prerender {
     27 bool IsOmniboxEnabled(Profile* profile);
     28 }
     29 
     30 namespace system_logs {
     31 class ChromeInternalLogSource;
     32 }
     33 
     34 // This class limits and documents access to metrics service helper methods.
     35 // Since these methods are private, each user has to be explicitly declared
     36 // as a 'friend' below.
     37 class ChromeMetricsServiceAccessor : public MetricsServiceAccessor {
     38  private:
     39   friend bool prerender::IsOmniboxEnabled(Profile* profile);
     40   friend class ::ChromeBrowserMetricsServiceObserver;
     41   friend class ChromeRenderMessageFilter;
     42   friend class ::CrashesDOMHandler;
     43   friend class extensions::ExtensionDownloader;
     44   friend class extensions::ManifestFetchData;
     45   friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction;
     46   friend class ::FlashDOMHandler;
     47   friend class system_logs::ChromeInternalLogSource;
     48 
     49   FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest,
     50                            MetricsReportingEnabled);
     51   FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest,
     52                            CrashReportingEnabled);
     53 
     54   // Returns true if prefs::kMetricsReportingEnabled is set.
     55   // TODO(asvitkine): Consolidate the method in MetricsStateManager.
     56   // TODO(asvitkine): This function does not report the correct value on
     57   // Android and ChromeOS, see http://crbug.com/362192.
     58   static bool IsMetricsReportingEnabled();
     59 
     60   // Returns true if crash reporting is enabled.  This is set at the platform
     61   // level for Android and ChromeOS, and otherwise is the same as
     62   // IsMetricsReportingEnabled for desktop Chrome.
     63   static bool IsCrashReportingEnabled();
     64 
     65   DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeMetricsServiceAccessor);
     66 };
     67 
     68 #endif  // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_
     69