blob: 59612c9faa9330cfdb9b327addcf821a62b89aa8 [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
5#ifndef CHROME_BROWSER_GLOBAL_DESKTOP_FEATURES_H_
6#define CHROME_BROWSER_GLOBAL_DESKTOP_FEATURES_H_
7
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.
20class GlobalDesktopFeatures {
21 public:
22 static std::unique_ptr<GlobalDesktopFeatures> CreateGlobalDesktopFeatures();
23 virtual ~GlobalDesktopFeatures();
24
25 GlobalDesktopFeatures(const GlobalDesktopFeatures&) = delete;
26 GlobalDesktopFeatures& operator=(const GlobalDesktopFeatures&) = delete;
27
28 // Call this method to stub out GlobalDesktopFeatures for tests.
29 using GlobalDesktopFeaturesFactory =
30 base::RepeatingCallback<std::unique_ptr<GlobalDesktopFeatures>()>;
31 static void ReplaceGlobalDesktopFeaturesForTesting(
32 GlobalDesktopFeaturesFactory factory);
33
34 // Called exactly once to initialize features.
35 void Init();
36
37 // Public accessors for features, e.g.
38 // FooFeature* foo_feature() { return foo_feature_.get(); }
39
Mickey Burks4d1287c12024-07-22 22:38:2040#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2041 whats_new::WhatsNewRegistry* whats_new_registry() {
42 return whats_new_registry_.get();
43 }
Mickey Burks4d1287c12024-07-22 22:38:2044#endif
Erik Chen46088762024-07-15 20:58:2045
46 protected:
47 GlobalDesktopFeatures();
48
49 // Override these methods to stub out individual feature controllers for
50 // testing. e.g.
51 // virtual std::unique_ptr<FooFeature> CreateFooFeature();
52
Mickey Burks4d1287c12024-07-22 22:38:2053#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2054 virtual std::unique_ptr<whats_new::WhatsNewRegistry> CreateWhatsNewRegistry();
Mickey Burks4d1287c12024-07-22 22:38:2055#endif
Erik Chen46088762024-07-15 20:58:2056
57 private:
58 // Features will each have a controller. e.g.
59 // std::unique_ptr<FooFeature> foo_feature_;
60
Mickey Burks4d1287c12024-07-22 22:38:2061#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
Erik Chen46088762024-07-15 20:58:2062 std::unique_ptr<whats_new::WhatsNewRegistry> whats_new_registry_;
Mickey Burks4d1287c12024-07-22 22:38:2063#endif
Erik Chen46088762024-07-15 20:58:2064};
65
66#endif // CHROME_BROWSER_GLOBAL_DESKTOP_FEATURES_H_