Revert "Rename GlobalFeatures to GlobalDesktopFeatures."
This reverts commit 4608876e6a9685e6b2b4693e66db48fc897d17f8.
Integrated relevant changes to global_desktop_features.* from
4d1287c14d5da1ef18ff695910c1aa537262780b that caused a merge conflict.
Bug: b/331784136
Change-Id: Ic06f03b132ce3df47a8100b3035b9aaa6bc71ae2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5734053
Auto-Submit: Jan Láník <[email protected]>
Reviewed-by: Erik Chen <[email protected]>
Commit-Queue: Erik Chen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1332029}
diff --git a/chrome/browser/global_features.h b/chrome/browser/global_features.h
new file mode 100644
index 0000000..d91ece6
--- /dev/null
+++ b/chrome/browser/global_features.h
@@ -0,0 +1,65 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GLOBAL_FEATURES_H_
+#define CHROME_BROWSER_GLOBAL_FEATURES_H_
+
+#include "base/functional/callback.h"
+#include "build/build_config.h"
+
+namespace whats_new {
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
+class WhatsNewRegistry;
+#endif
+} // namespace whats_new
+
+// This class owns the core controllers for features that are globally
+// scoped on desktop. It can be subclassed by tests to perform
+// dependency injection.
+class GlobalFeatures {
+ public:
+ static std::unique_ptr<GlobalFeatures> CreateGlobalFeatures();
+ virtual ~GlobalFeatures();
+
+ GlobalFeatures(const GlobalFeatures&) = delete;
+ GlobalFeatures& operator=(const GlobalFeatures&) = delete;
+
+ // Call this method to stub out GlobalFeatures for tests.
+ using GlobalFeaturesFactory =
+ base::RepeatingCallback<std::unique_ptr<GlobalFeatures>()>;
+ static void ReplaceGlobalFeaturesForTesting(GlobalFeaturesFactory factory);
+
+ // Called exactly once to initialize features.
+ void Init();
+
+ // Public accessors for features, e.g.
+ // FooFeature* foo_feature() { return foo_feature_.get(); }
+
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
+ whats_new::WhatsNewRegistry* whats_new_registry() {
+ return whats_new_registry_.get();
+ }
+#endif
+
+ protected:
+ GlobalFeatures();
+
+ // Override these methods to stub out individual feature controllers for
+ // testing. e.g.
+ // virtual std::unique_ptr<FooFeature> CreateFooFeature();
+
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
+ virtual std::unique_ptr<whats_new::WhatsNewRegistry> CreateWhatsNewRegistry();
+#endif
+
+ private:
+ // Features will each have a controller. e.g.
+ // std::unique_ptr<FooFeature> foo_feature_;
+
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
+ std::unique_ptr<whats_new::WhatsNewRegistry> whats_new_registry_;
+#endif
+};
+
+#endif // CHROME_BROWSER_GLOBAL_FEATURES_H_