blob: d91ece69a439cb98fc3caccc1fb80feffd9cf972 [file] [log] [blame]
Erik Chen46088762024-07-15 20:58:201// Copyright 2024 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
Jan Lanik826be882024-07-23 23:52:375#ifndef CHROME_BROWSER_GLOBAL_FEATURES_H_
6#define CHROME_BROWSER_GLOBAL_FEATURES_H_
Erik Chen46088762024-07-15 20:58:207
8#include "base/functional/callback.h"
9#include "build/build_config.h"
10
11namespace whats_new {
Mickey Burks4d1287c12024-07-22 22:38:2012#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2013class WhatsNewRegistry;
Mickey Burks4d1287c12024-07-22 22:38:2014#endif
Erik Chen46088762024-07-15 20:58:2015} // namespace whats_new
16
17// This class owns the core controllers for features that are globally
18// scoped on desktop. It can be subclassed by tests to perform
19// dependency injection.
Jan Lanik826be882024-07-23 23:52:3720class GlobalFeatures {
Erik Chen46088762024-07-15 20:58:2021 public:
Jan Lanik826be882024-07-23 23:52:3722 static std::unique_ptr<GlobalFeatures> CreateGlobalFeatures();
23 virtual ~GlobalFeatures();
Erik Chen46088762024-07-15 20:58:2024
Jan Lanik826be882024-07-23 23:52:3725 GlobalFeatures(const GlobalFeatures&) = delete;
26 GlobalFeatures& operator=(const GlobalFeatures&) = delete;
Erik Chen46088762024-07-15 20:58:2027
Jan Lanik826be882024-07-23 23:52:3728 // Call this method to stub out GlobalFeatures for tests.
29 using GlobalFeaturesFactory =
30 base::RepeatingCallback<std::unique_ptr<GlobalFeatures>()>;
31 static void ReplaceGlobalFeaturesForTesting(GlobalFeaturesFactory factory);
Erik Chen46088762024-07-15 20:58:2032
33 // Called exactly once to initialize features.
34 void Init();
35
36 // Public accessors for features, e.g.
37 // FooFeature* foo_feature() { return foo_feature_.get(); }
38
Mickey Burks4d1287c12024-07-22 22:38:2039#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2040 whats_new::WhatsNewRegistry* whats_new_registry() {
41 return whats_new_registry_.get();
42 }
Mickey Burks4d1287c12024-07-22 22:38:2043#endif
Erik Chen46088762024-07-15 20:58:2044
45 protected:
Jan Lanik826be882024-07-23 23:52:3746 GlobalFeatures();
Erik Chen46088762024-07-15 20:58:2047
48 // Override these methods to stub out individual feature controllers for
49 // testing. e.g.
50 // virtual std::unique_ptr<FooFeature> CreateFooFeature();
51
Mickey Burks4d1287c12024-07-22 22:38:2052#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2053 virtual std::unique_ptr<whats_new::WhatsNewRegistry> CreateWhatsNewRegistry();
Mickey Burks4d1287c12024-07-22 22:38:2054#endif
Erik Chen46088762024-07-15 20:58:2055
56 private:
57 // Features will each have a controller. e.g.
58 // std::unique_ptr<FooFeature> foo_feature_;
59
Mickey Burks4d1287c12024-07-22 22:38:2060#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2061 std::unique_ptr<whats_new::WhatsNewRegistry> whats_new_registry_;
Mickey Burks4d1287c12024-07-22 22:38:2062#endif
Erik Chen46088762024-07-15 20:58:2063};
64
Jan Lanik826be882024-07-23 23:52:3765#endif // CHROME_BROWSER_GLOBAL_FEATURES_H_