blob: 91c1a3c1751dee3444edd0efaa11294aa6c0d73d [file] [log] [blame]
[email protected]b544c1ae2013-07-24 18:34:131// Copyright 2013 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_PREFS_PREF_METRICS_SERVICE_H_
6#define CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
7
Keishi Hattori0e45c022021-11-27 09:25:528#include "base/memory/raw_ptr.h"
[email protected]b544c1ae2013-07-24 18:34:139#include "base/memory/singleton.h"
[email protected]8456bec2013-09-09 04:06:2310#include "base/memory/weak_ptr.h"
[email protected]540380fc2014-03-14 10:10:3411#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
12#include "components/keyed_service/core/keyed_service.h"
Mark Pearsonefb5f4f2018-08-15 19:55:4013#include "url/gurl.h"
14
Sylvain Defresnecd9430a2019-02-18 14:06:5515class PrefService;
Mark Pearsonefb5f4f2018-08-15 19:55:4016class Profile;
[email protected]b544c1ae2013-07-24 18:34:1317
[email protected]b544c1ae2013-07-24 18:34:1318// PrefMetricsService is responsible for recording prefs-related UMA stats.
[email protected]540380fc2014-03-14 10:10:3419class PrefMetricsService : public KeyedService {
[email protected]b544c1ae2013-07-24 18:34:1320 public:
21 explicit PrefMetricsService(Profile* profile);
Peter Boström53c6c5952021-09-17 09:41:2622
23 PrefMetricsService(const PrefMetricsService&) = delete;
24 PrefMetricsService& operator=(const PrefMetricsService&) = delete;
25
dcheng8f4b8622014-10-23 16:37:4826 ~PrefMetricsService() override;
[email protected]b544c1ae2013-07-24 18:34:1327
tedchoc42da7e242016-06-01 03:56:4928 // Records metrics about the state of the homepage on launch.
29 static void RecordHomePageLaunchMetrics(bool show_home_button,
30 bool homepage_is_ntp,
31 const GURL& homepage_url);
32
[email protected]b544c1ae2013-07-24 18:34:1333 class Factory : public BrowserContextKeyedServiceFactory {
34 public:
35 static Factory* GetInstance();
36 static PrefMetricsService* GetForProfile(Profile* profile);
37 private:
olli.raula36aa8be2015-09-10 11:14:2238 friend struct base::DefaultSingletonTraits<Factory>;
[email protected]b544c1ae2013-07-24 18:34:1339
40 Factory();
dcheng8f4b8622014-10-23 16:37:4841 ~Factory() override;
[email protected]b544c1ae2013-07-24 18:34:1342
43 // BrowserContextKeyedServiceFactory implementation
dcheng8f4b8622014-10-23 16:37:4844 KeyedService* BuildServiceInstanceFor(
mostynb2b52d1db2014-10-07 02:47:1745 content::BrowserContext* profile) const override;
dcheng8f4b8622014-10-23 16:37:4846 bool ServiceIsCreatedWithBrowserContext() const override;
dcheng8f4b8622014-10-23 16:37:4847 content::BrowserContext* GetBrowserContextToUse(
mostynb2b52d1db2014-10-07 02:47:1748 content::BrowserContext* context) const override;
[email protected]b544c1ae2013-07-24 18:34:1349 };
[email protected]0ebc4032013-08-10 07:07:1150
[email protected]b544c1ae2013-07-24 18:34:1351 private:
[email protected]b544c1ae2013-07-24 18:34:1352 // Record prefs state on browser context creation.
53 void RecordLaunchPrefs();
54
Keishi Hattori0e45c022021-11-27 09:25:5255 raw_ptr<Profile> profile_;
56 raw_ptr<PrefService> prefs_;
[email protected]8456bec2013-09-09 04:06:2357
Jeremy Roman495db682019-07-12 16:03:2458 base::WeakPtrFactory<PrefMetricsService> weak_factory_{this};
[email protected]b544c1ae2013-07-24 18:34:1359};
60
61#endif // CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_