From: uazo Date: Sat, 18 Nov 2023 09:41:28 +0000 Subject: Add cromite flags support Add SET_CROMITE_FEATURE_ENABLED*, SET_CROMITE_FEATURE_DISABLED* and CROMITE_FEATURE macros, logic has been adapted from that found in brave. Allows flags to be defined in separate files. Activates a new cromite tab in chrome://flags with only the flags added and changed. In android added chrome://flags/cromite in the setting ui. Need: bromite-build-utils.patch License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html --- base/BUILD.gn | 5 +- base/android/feature_map.cc | 5 + .../src/org/chromium/base/FeatureMap.java | 5 + .../base/ImmutableFlagWithDefault.java | 25 +++ .../base/cached_flags/ValuesReturned.java | 2 +- base/feature.h | 93 +++++++++- base/feature_list.cc | 76 ++++++++ base/feature_list.h | 5 + build/android/gyp/java_cpp_features.py | 15 ++ chrome/android/java/res/values/values.xml | 3 + .../java/res/xml/privacy_preferences.xml | 4 + .../homepage/settings/HomepageSettings.java | 2 +- .../privacy/settings/PrivacySettings.java | 2 +- .../settings/FragmentDependencyProvider.java | 10 +- .../browser/settings/SettingsActivity.java | 41 ++++- .../tracing/settings/DeveloperSettings.java | 5 +- chrome/browser/about_flags.cc | 11 ++ chrome/browser/browser_features.cc | 1 + chrome/browser/browser_features.h | 1 + chrome/browser/flags/BUILD.gn | 13 ++ .../flags/android/chrome_feature_list.cc | 1 + .../flags/android/chrome_feature_list.h | 1 + .../browser/flags/ChromeFeatureList.java | 13 +- .../flags/cromite/include_all_directory.java | 1 + .../java_template/CromiteCachedFlag.java.tmpl | 47 +++++ .../settings/ChromeBaseSettingsFragment.java | 50 +++++ .../strings/android_chrome_strings.grd | 1 + .../Add-cromite-flags-support.grdp | 9 + .../placeholder.txt | 1 + chrome/browser/ui/ui_features.cc | 1 + chrome/browser/unexpire_flags.cc | 15 +- chrome/common/chrome_features.cc | 1 + .../browser_ui/accessibility/android/BUILD.gn | 1 + .../res/xml/accessibility_preferences.xml | 3 +- .../accessibility/AccessibilitySettings.java | 6 +- .../android/java/res/values/attrs.xml | 4 + .../settings/ChromeSwitchPreference.java | 19 ++ .../components/cached_flags/CachedFlag.java | 8 +- components/components_strings.grd | 1 + .../content_settings/core/common/features.cc | 1 + .../placeholder.txt | 1 + .../core/offline_page_feature.cc | 1 + .../offline_pages/core/offline_page_feature.h | 1 + .../browser/features/password_features.cc | 1 + components/permissions/features.cc | 1 + ...nthetic_trials_active_group_id_provider.cc | 4 +- ...ynthetic_trials_active_group_id_provider.h | 4 +- components/webui/flags/flags_state.cc | 59 ++++++ components/webui/flags/resources/app.css | 32 ++++ components/webui/flags/resources/app.html.ts | 28 +++ components/webui/flags/resources/app.ts | 24 +++ .../webui/flags/resources/experiment.css | 9 +- .../webui/flags/resources/experiment.html.ts | 7 +- .../webui/flags/resources/experiment.ts | 12 +- .../flags/resources/flags_browser_proxy.ts | 5 + .../webui/version/version_handler_helper.cc | 4 +- content/common/features.cc | 1 + content/public/common/content_features.cc | 1 + content/public/common/content_features.h | 1 + cromite_flags/BUILD.gn | 174 ++++++++++++++++++ .../browser/about_flags_cc/placeholder.txt | 1 + .../browser_features_cc/placeholder.txt | 1 + .../browser_features_h/placeholder.txt | 1 + .../chrome_feature_list_cc/placeholder.txt | 1 + .../chrome_feature_list_h/placeholder.txt | 1 + .../browser/ui/ui_features_cc/placeholder.txt | 1 + .../common/chrome_features_cc/placeholder.txt | 1 + .../common/chrome_features_h/placeholder.txt | 1 + .../core/common/features_cc/placeholder.txt | 1 + .../offline_page_feature_cc/placeholder.txt | 1 + .../offline_page_feature_h/placeholder.txt | 1 + .../password_features_cc/placeholder.txt | 1 + .../permissions/features_cc/placeholder.txt | 1 + .../common/features_cc/placeholder.txt | 1 + .../content_features_cc/placeholder.txt | 1 + .../common/content_features_h/placeholder.txt | 1 + .../base/media_switches_cc/placeholder.txt | 1 + .../base/media_switches_h/placeholder.txt | 1 + .../net/base/features_cc/placeholder.txt | 1 + .../net/base/features_h/placeholder.txt | 1 + .../public/cpp/features_cc/placeholder.txt | 1 + .../public/cpp/features_h/placeholder.txt | 1 + .../blink/common/features_cc/placeholder.txt | 1 + .../blink/common/features_h/placeholder.txt | 1 + .../ui/base/features_cc/placeholder.txt | 1 + .../ui/base/features_h/placeholder.txt | 1 + media/base/media_switches.cc | 2 +- media/base/media_switches.h | 2 +- net/base/features.cc | 1 + net/base/features.h | 1 + services/network/public/cpp/features.cc | 1 + services/network/public/cpp/features.h | 1 + third_party/blink/common/features.cc | 1 + third_party/blink/public/common/features.h | 1 + ui/base/ui_base_features.cc | 1 + ui/base/ui_base_features.h | 1 + 96 files changed, 885 insertions(+), 31 deletions(-) create mode 100644 base/android/java/src/org/chromium/base/ImmutableFlagWithDefault.java create mode 100644 chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/include_all_directory.java create mode 100644 chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/java_template/CromiteCachedFlag.java.tmpl create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-cromite-flags-support.grdp create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/placeholder.txt create mode 100644 components/cromite_components_strings_grd/placeholder.txt create mode 100755 cromite_flags/BUILD.gn create mode 100755 cromite_flags/chrome/browser/about_flags_cc/placeholder.txt create mode 100755 cromite_flags/chrome/browser/browser_features_cc/placeholder.txt create mode 100755 cromite_flags/chrome/browser/browser_features_h/placeholder.txt create mode 100755 cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/placeholder.txt create mode 100755 cromite_flags/chrome/browser/flags/android/chrome_feature_list_h/placeholder.txt create mode 100755 cromite_flags/chrome/browser/ui/ui_features_cc/placeholder.txt create mode 100755 cromite_flags/chrome/common/chrome_features_cc/placeholder.txt create mode 100755 cromite_flags/chrome/common/chrome_features_h/placeholder.txt create mode 100755 cromite_flags/components/content_settings/core/common/features_cc/placeholder.txt create mode 100755 cromite_flags/components/offline_pages/core/offline_page_feature_cc/placeholder.txt create mode 100755 cromite_flags/components/offline_pages/core/offline_page_feature_h/placeholder.txt create mode 100755 cromite_flags/components/password_manager/core/browser/features/password_features_cc/placeholder.txt create mode 100755 cromite_flags/components/permissions/features_cc/placeholder.txt create mode 100755 cromite_flags/content/common/features_cc/placeholder.txt create mode 100755 cromite_flags/content/public/common/content_features_cc/placeholder.txt create mode 100755 cromite_flags/content/public/common/content_features_h/placeholder.txt create mode 100755 cromite_flags/media/base/media_switches_cc/placeholder.txt create mode 100755 cromite_flags/media/base/media_switches_h/placeholder.txt create mode 100755 cromite_flags/net/base/features_cc/placeholder.txt create mode 100755 cromite_flags/net/base/features_h/placeholder.txt create mode 100755 cromite_flags/services/network/public/cpp/features_cc/placeholder.txt create mode 100755 cromite_flags/services/network/public/cpp/features_h/placeholder.txt create mode 100755 cromite_flags/third_party/blink/common/features_cc/placeholder.txt create mode 100755 cromite_flags/third_party/blink/common/features_h/placeholder.txt create mode 100755 cromite_flags/ui/base/features_cc/placeholder.txt create mode 100755 cromite_flags/ui/base/features_h/placeholder.txt diff --git a/base/BUILD.gn b/base/BUILD.gn --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -189,6 +189,8 @@ generate_allowlist_from_histograms_file("memory_dump_provider_name_variants") { # This does not include test code (test support and anything in the test # directory) which should use source_set as is recommended for GN targets). component("base") { + deps = [ "//cromite_flags", ] + sources = [ "allocator/allocator_check.cc", "allocator/allocator_check.h", @@ -1073,7 +1075,7 @@ component("base") { "//build/config/compiler:wglobal_constructors", ] - deps = [ + deps += [ ":check_version_internal", ":simdutf_shim", "//base/allocator:buildflags", @@ -5056,6 +5058,7 @@ if (is_android) { "android/java/src/org/chromium/base/Flag.java", "android/java/src/org/chromium/base/MutableBooleanParamWithSafeDefault.java", "android/java/src/org/chromium/base/MutableFlagWithSafeDefault.java", + "android/java/src/org/chromium/base/ImmutableFlagWithDefault.java", "android/java/src/org/chromium/base/MutableIntParamWithSafeDefault.java", "android/java/src/org/chromium/base/MutableParamWithSafeDefault.java", ] diff --git a/base/android/feature_map.cc b/base/android/feature_map.cc --- a/base/android/feature_map.cc +++ b/base/android/feature_map.cc @@ -46,6 +46,11 @@ const Feature* FeatureMap::FindFeatureExposedToJava( static bool JNI_FeatureMap_IsEnabled(int64_t jfeature_map, const std::string& feature_name) { + if (base::FeatureList::IsCromiteFlag(feature_name)) { + const base::Feature* cromite_feature = + base::FeatureList::GetCromiteFlag(feature_name); + return base::FeatureList::IsEnabled(*cromite_feature); + } FeatureMap* feature_map = reinterpret_cast(jfeature_map); const base::Feature* feature = feature_map->FindFeatureExposedToJava(feature_name); diff --git a/base/android/java/src/org/chromium/base/FeatureMap.java b/base/android/java/src/org/chromium/base/FeatureMap.java --- a/base/android/java/src/org/chromium/base/FeatureMap.java +++ b/base/android/java/src/org/chromium/base/FeatureMap.java @@ -159,6 +159,11 @@ public abstract class FeatureMap { return new MutableFlagWithSafeDefault(this, featureName, defaultValue); } + public ImmutableFlagWithDefault immutableFlagWithDefault( + String featureName, boolean defaultValue) { + return new ImmutableFlagWithDefault(this, featureName, defaultValue); + } + private void ensureNativeMapInit() { assert FeatureList.isNativeInitialized(); diff --git a/base/android/java/src/org/chromium/base/ImmutableFlagWithDefault.java b/base/android/java/src/org/chromium/base/ImmutableFlagWithDefault.java new file mode 100644 --- /dev/null +++ b/base/android/java/src/org/chromium/base/ImmutableFlagWithDefault.java @@ -0,0 +1,25 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base; + +import org.chromium.build.annotations.NullMarked; +import org.chromium.build.annotations.Nullable; + +@NullMarked +public class ImmutableFlagWithDefault extends MutableFlagWithSafeDefault { + private final boolean mDefaultValue; + private @Nullable Boolean mInMemoryCachedValue; + + public ImmutableFlagWithDefault( + FeatureMap featureMap, String featureName, boolean defaultValue) { + super(featureMap, featureName, defaultValue); + mDefaultValue = defaultValue; + } + + @Override + public boolean isEnabled() { + return mDefaultValue; + } +} diff --git a/base/android/java/src/org/chromium/base/cached_flags/ValuesReturned.java b/base/android/java/src/org/chromium/base/cached_flags/ValuesReturned.java --- a/base/android/java/src/org/chromium/base/cached_flags/ValuesReturned.java +++ b/base/android/java/src/org/chromium/base/cached_flags/ValuesReturned.java @@ -18,7 +18,7 @@ import java.util.function.Supplier; @NullMarked public abstract class ValuesReturned { @GuardedBy("sBoolValues") - private static final Map sBoolValues = new HashMap<>(); + public static final Map sBoolValues = new HashMap<>(); @GuardedBy("sStringValues") private static final Map sStringValues = new HashMap<>(); diff --git a/base/feature.h b/base/feature.h --- a/base/feature.h +++ b/base/feature.h @@ -182,8 +182,10 @@ struct BASE_EXPORT LOGICALLY_CONST Feature { constexpr Feature(const char* name, FeatureState default_state, - internal::FeatureMacroHandshake) - : name(name), default_state(default_state) { + internal::FeatureMacroHandshake, + bool cromite = false, bool is_new_flag = false) + : name(name), default_state(default_state), + is_cromite(cromite), is_new(is_new_flag) { #if BUILDFLAG(ENABLE_BANNED_BASE_FEATURE_PREFIX) if (std::string_view(name).starts_with( BUILDFLAG(BANNED_BASE_FEATURE_PREFIX))) { @@ -210,6 +212,9 @@ struct BASE_EXPORT LOGICALLY_CONST Feature { // command line switch. const FeatureState default_state; + const bool is_cromite = false; + const bool is_new = false; + private: friend class FeatureList; @@ -237,4 +242,88 @@ struct BASE_EXPORT LOGICALLY_CONST Feature { } // namespace base +namespace base { +namespace internal { + +// Perform base::Feature duplicates check and fills overriden states into a +// map that is used at runtime to get an override if available. +class BASE_EXPORT FeatureDefaultStateOverrider { + public: + using FeatureOverrideInfo = + std::pair, FeatureState>; + + FeatureDefaultStateOverrider( + const Feature& feature, FeatureState state); +}; + +} // namespace internal +} // namespace base + +#define CROMITE_FEATURE(feature, name, default_state) \ + constinit const base::Feature feature(name, default_state, base::internal::FeatureMacroHandshake::kSecret, true, true); \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") \ + static const ::base::internal::FeatureDefaultStateOverrider \ + g_feature_default_state_overrider_ ##feature {feature, default_state}; \ + _Pragma("clang diagnostic pop") \ + static_assert(true, "") /* for a semicolon requirement */ + +#define SET_CROMITE_FEATURE_ENABLED(feature) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") \ + static const ::base::internal::FeatureDefaultStateOverrider \ + g_feature_default_state_overrider_ ##feature {feature, base::FEATURE_ENABLED_BY_DEFAULT}; \ + _Pragma("clang diagnostic pop") \ + static_assert(true, "") /* for a semicolon requirement */ + +#define SET_CROMITE_FEATURE_DISABLED(feature) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") \ + static const ::base::internal::FeatureDefaultStateOverrider \ + g_feature_default_state_overrider_ ##feature {feature, base::FEATURE_DISABLED_BY_DEFAULT}; \ + _Pragma("clang diagnostic pop") \ + static_assert(true, "") /* for a semicolon requirement */ + +#define SET_CROMITE_FEATURE_ENABLED_W_NAMESPACE(namespace_value, feature) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") \ + static const ::base::internal::FeatureDefaultStateOverrider \ + g_feature_default_state_overrider_ ##feature {namespace_value::feature, base::FEATURE_ENABLED_BY_DEFAULT}; \ + _Pragma("clang diagnostic pop") \ + static_assert(true, "") /* for a semicolon requirement */ + +#define SET_CROMITE_FEATURE_DISABLED_W_NAMESPACE(namespace_value, feature) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") \ + static const ::base::internal::FeatureDefaultStateOverrider \ + g_feature_default_state_overrider_ ##feature {namespace_value::feature, base::FEATURE_DISABLED_BY_DEFAULT}; \ + _Pragma("clang diagnostic pop") \ + static_assert(true, "") /* for a semicolon requirement */ + +#define BASE_FEATURE_DISABLED_3_ARGS(feature, name, default_state) \ + BASE_FEATURE(feature, name, default_state); \ + static_assert(default_state == base::FEATURE_DISABLED_BY_DEFAULT, "Check default state") + +#define BASE_FEATURE_DISABLED_2_ARGS(name, default_state) \ + BASE_FEATURE(name, default_state); \ + static_assert(default_state == base::FEATURE_DISABLED_BY_DEFAULT, "Check default state") + +#define GET_BASE_FEATURE_DISABLED_MACRO(_1, _2, _3, NAME, ...) NAME +#define BASE_FEATURE_DISABLED(...) \ + GET_BASE_FEATURE_DISABLED_MACRO(__VA_ARGS__, BASE_FEATURE_DISABLED_3_ARGS, \ + BASE_FEATURE_DISABLED_2_ARGS)(__VA_ARGS__) + +#define BASE_FEATURE_ENABLED_3_ARGS(feature, name, default_state) \ + BASE_FEATURE(feature, name, default_state); \ + static_assert(default_state == base::FEATURE_ENABLED_BY_DEFAULT, "Check default state") + +#define BASE_FEATURE_ENABLED_2_ARGS(name, default_state) \ + BASE_FEATURE(name, default_state); \ + static_assert(default_state == base::FEATURE_ENABLED_BY_DEFAULT, "Check default state") + +#define GET_BASE_FEATURE_ENABLED_MACRO(_1, _2, _3, NAME, ...) NAME +#define BASE_FEATURE_ENABLED(...) \ + GET_BASE_FEATURE_ENABLED_MACRO(__VA_ARGS__, BASE_FEATURE_ENABLED_3_ARGS, \ + BASE_FEATURE_ENABLED_2_ARGS)(__VA_ARGS__) + #endif // BASE_FEATURE_H_ diff --git a/base/feature_list.cc b/base/feature_list.cc --- a/base/feature_list.cc +++ b/base/feature_list.cc @@ -41,6 +41,31 @@ namespace base { +namespace internal { + +using DefaultStateOverrides = + flat_map; + +constexpr size_t kDefaultStateOverridesReserve = 64 * 4; + +DefaultStateOverrides& GetListOfNewFeatureState() { + static NoDestructor + startup_default_state_overrides([] { + DefaultStateOverrides v; + v.reserve(kDefaultStateOverridesReserve); + return v; + }()); + return *startup_default_state_overrides; +} + +FeatureDefaultStateOverrider::FeatureDefaultStateOverrider( + const Feature& feature, FeatureState state) { + auto& default_state_overrides = GetListOfNewFeatureState(); + default_state_overrides.insert({&feature, state}); +} + +} // namespace internal + namespace { // Pointer to the FeatureList instance singleton that was set via @@ -533,6 +558,46 @@ bool FeatureList::IsEnabled(const Feature& feature) { return g_feature_list_instance->IsFeatureEnabled(feature); } +// static +bool FeatureList::IsCromiteChanged(const Feature& feature) { + for(auto const& [key, value]: internal::GetListOfNewFeatureState()) { + if (key->name == feature.name) { + return true; + } + } + return false; +} + +// static +const base::Feature* FeatureList::GetCromiteFlag(const std::string& feature_name) { + for(auto const& [key, value]: internal::GetListOfNewFeatureState()) { + if (key->name == feature_name && key->is_cromite) { + return key; + } + } + NOTREACHED(); +} + +// static +bool FeatureList::IsCromiteFlag(const std::string& feature_name) { + for(auto const& [key, value]: internal::GetListOfNewFeatureState()) { + if (key->name == feature_name && key->is_cromite) { + return true; + } + } + return false; +} + +// static +bool FeatureList::GetCromiteChange(const Feature& feature) { + for(auto const& [key, value]: internal::GetListOfNewFeatureState()) { + if (key->name == feature.name) { + return value == base::FEATURE_ENABLED_BY_DEFAULT; + } + } + NOTREACHED(); +} + // static bool FeatureList::IsValidFeatureOrFieldTrialName(std::string_view name) { return IsStringASCII(name) && name.find_first_of(",<*") == std::string::npos; @@ -836,6 +901,17 @@ void FeatureList::RegisterFeatureAccess( void FeatureList::FinalizeInitialization() { DCHECK(!initialized_); + //LOG(INFO) << "---FinalizeInitialization"; + for(auto const& [key, value]: internal::GetListOfNewFeatureState()) { + // LOG(INFO) << "---key " << key->name + // << " " + // << (value == base::FEATURE_ENABLED_BY_DEFAULT ? "1" : "0"); + RegisterOverride(key->name, + value == base::FEATURE_ENABLED_BY_DEFAULT + ? OverrideState::OVERRIDE_ENABLE_FEATURE + : OverrideState::OVERRIDE_DISABLE_FEATURE, + /* field_trial = */ nullptr); + } // Store the field trial list pointer for DCHECKing. field_trial_list_ = FieldTrialList::GetInstance(); initialized_ = true; diff --git a/base/feature_list.h b/base/feature_list.h --- a/base/feature_list.h +++ b/base/feature_list.h @@ -290,6 +290,11 @@ class BASE_EXPORT FeatureList { // instance, which is checked in builds with DCHECKs enabled. static bool IsEnabled(const Feature& feature); + static bool IsCromiteFlag(const std::string& featureName); + static const base::Feature* GetCromiteFlag(const std::string& featureName); + static bool IsCromiteChanged(const Feature& feature); + static bool GetCromiteChange(const Feature& feature); + // Some characters are not allowed to appear in feature names or the // associated field trial names, as they are used as special characters for // command-line serialization. This function checks that the strings are ASCII diff --git a/build/android/gyp/java_cpp_features.py b/build/android/gyp/java_cpp_features.py --- a/build/android/gyp/java_cpp_features.py +++ b/build/android/gyp/java_cpp_features.py @@ -22,6 +22,11 @@ class FeatureParserDelegate(java_cpp_utils.CppConstantParser.Delegate): # ExtractConstantName() -> 'ConstantName' # ExtractValue() -> '"StringNameOfTheFeature"' or '"ConstantName"' _FEATURE_RE = re.compile(r'BASE_FEATURE\(\s*(k\w+),') + _FEATURE_RE1 = re.compile(r'CROMITE_FEATURE\(\s*(k\w+),') + _FEATURE_RE2 = re.compile(r'BASE_FEATURE_DISABLED\(\s*(k\w+),') + _FEATURE_RE3 = re.compile(r'CROMITE_FEATURE_DISABLED\(\s*(k\w+),') + _FEATURE_RE4 = re.compile(r'BASE_FEATURE_ENABLED\(\s*(k\w+),') + _FEATURE_RE5 = re.compile(r'CROMITE_FEATURE_ENABLED\(\s*(k\w+),') _STRING_LITERAL_RE = re.compile(r'"(?:\\"|[^"])*"') _constant_name = None # The name of the current macro. _comma_count = 0 # Number of commas seen in the current macro. @@ -34,6 +39,16 @@ class FeatureParserDelegate(java_cpp_utils.CppConstantParser.Delegate): self._constant_name = None match = self._FEATURE_RE.match(line) + if match is None: + match = self._FEATURE_RE1.match(line) + if match is None: + match = self._FEATURE_RE2.match(line) + if match is None: + match = self._FEATURE_RE3.match(line) + if match is None: + match = self._FEATURE_RE4.match(line) + if match is None: + match = self._FEATURE_RE5.match(line) if match: # The regex ensures that the feature name starts with 'k'. feature_name = match.group(1) diff --git a/chrome/android/java/res/values/values.xml b/chrome/android/java/res/values/values.xml --- a/chrome/android/java/res/values/values.xml +++ b/chrome/android/java/res/values/values.xml @@ -9,6 +9,9 @@ found in the LICENSE file. xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> + Open Cromite flags list + chrome://flags/cromite + diff --git a/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-cromite-flags-support.grdp b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-cromite-flags-support.grdp new file mode 100644 --- /dev/null +++ b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-cromite-flags-support.grdp @@ -0,0 +1,9 @@ + + + + Relaunch + + + Your changes will take effect the next time you relaunch Cromite. + + diff --git a/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/placeholder.txt b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/placeholder.txt new file mode 100644 --- /dev/null +++ b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/chrome/browser/ui/ui_features.cc b/chrome/browser/ui/ui_features.cc --- a/chrome/browser/ui/ui_features.cc +++ b/chrome/browser/ui/ui_features.cc @@ -475,4 +475,5 @@ BASE_FEATURE_PARAM(bool, "tab_groups_focusing_default_to_focused", false); +#include "cromite_flags/chrome_browser_ui_ui_features_cc.inc" } // namespace features diff --git a/chrome/browser/unexpire_flags.cc b/chrome/browser/unexpire_flags.cc --- a/chrome/browser/unexpire_flags.cc +++ b/chrome/browser/unexpire_flags.cc @@ -10,6 +10,7 @@ #include "base/containers/flat_map.h" #include "base/feature_list.h" #include "base/no_destructor.h" +#include "chrome/browser/about_flags.h" #include "chrome/browser/expired_flags_list.h" #include "chrome/browser/unexpire_flags_gen.h" #include "chrome/common/chrome_version.h" @@ -116,7 +117,19 @@ bool IsFlagExpired(const flags_ui::FlagsStorage* storage, // Otherwise, the flag is expired if its expiration mstone is less than the // mstone of this copy of Chromium. - return mstone < CHROME_VERSION_MAJOR; + if (mstone < CHROME_VERSION_MAJOR) { + if (const flags_ui::FeatureEntry* entry = + about_flags::GetCurrentFlagsState()->FindFeatureEntryByName( + internal_name)) { + if (const base::Feature* feature = entry->feature.feature) { + if (feature->is_cromite) { + return false; + } + } + } + return true; + } + return false; } namespace testing { diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc @@ -1818,4 +1818,5 @@ BASE_FEATURE(kClassManagementEnabledMetricsProvider, BASE_FEATURE(kSmartRestartMetrics, base::FEATURE_ENABLED_BY_DEFAULT); #endif // BUILDFLAG(IS_ANDROID) +#include "cromite_flags/chrome_common_chrome_features_cc.inc" } // namespace features diff --git a/components/browser_ui/accessibility/android/BUILD.gn b/components/browser_ui/accessibility/android/BUILD.gn --- a/components/browser_ui/accessibility/android/BUILD.gn +++ b/components/browser_ui/accessibility/android/BUILD.gn @@ -73,6 +73,7 @@ android_library("lib_java") { ":page_zoom_utils_java", "//base:base_java", "//build/android:build_java", + "//chrome/browser/settings:java", "//components/browser_ui/settings/android:java", "//components/browser_ui/site_settings/android:java", "//components/browser_ui/styles/android:java", diff --git a/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml b/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml --- a/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml +++ b/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml @@ -5,7 +5,8 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> - + diff --git a/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java b/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java --- a/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java +++ b/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java @@ -38,9 +38,11 @@ import org.chromium.content_public.browser.ContentFeatureList; import org.chromium.content_public.browser.ContentFeatureMap; import org.chromium.ui.base.UiAndroidFeatureList; +import org.chromium.chrome.browser.settings.ChromeBaseSettingsFragment; + /** Fragment to keep track of all the accessibility related preferences. */ @NullMarked -public class AccessibilitySettings extends PreferenceFragmentCompat +public class AccessibilitySettings extends ChromeBaseSettingsFragment implements EmbeddableSettingsPage, Preference.OnPreferenceChangeListener, CustomDividerFragment { @@ -109,7 +111,7 @@ public class AccessibilitySettings extends PreferenceFragmentCompat } @Override - public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { + public void onCreatePreferencesCromite(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { SettingsUtils.addPreferencesFromResource(this, R.xml.accessibility_preferences); // TODO(crbug.com/439911511): Add PageZoomPreference directly to the xml file instead. diff --git a/components/browser_ui/settings/android/java/res/values/attrs.xml b/components/browser_ui/settings/android/java/res/values/attrs.xml --- a/components/browser_ui/settings/android/java/res/values/attrs.xml +++ b/components/browser_ui/settings/android/java/res/values/attrs.xml @@ -12,6 +12,10 @@ found in the LICENSE file. + + + + diff --git a/components/browser_ui/settings/android/widget/java/src/org/chromium/components/browser_ui/settings/ChromeSwitchPreference.java b/components/browser_ui/settings/android/widget/java/src/org/chromium/components/browser_ui/settings/ChromeSwitchPreference.java --- a/components/browser_ui/settings/android/widget/java/src/org/chromium/components/browser_ui/settings/ChromeSwitchPreference.java +++ b/components/browser_ui/settings/android/widget/java/src/org/chromium/components/browser_ui/settings/ChromeSwitchPreference.java @@ -14,6 +14,8 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.TextView; +import android.content.res.TypedArray; + import androidx.annotation.ColorInt; import androidx.annotation.VisibleForTesting; import androidx.preference.PreferenceViewHolder; @@ -38,6 +40,11 @@ public class ChromeSwitchPreference extends SwitchPreferenceCompat implements Co /** Indicates if the preference uses a custom layout. */ private final boolean mHasCustomLayout; + @Nullable + private String mFeatureName; + + private final boolean mNeedRestart; + // TOOD(crbug.com/1451550): This is an interim solution. In the long-term, we should migrate // away from a switch with dynamically changing summaries onto a radio group. /** @@ -62,6 +69,18 @@ public class ChromeSwitchPreference extends SwitchPreferenceCompat implements Co mHasCustomLayout = ManagedPreferencesUtils.isCustomLayoutApplied(context, attrs); mUseSummaryAsTitle = true; + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ChromeBasePreference); + mFeatureName = a.getString(R.styleable.ChromeBasePreference_featureName); + mNeedRestart = a.getBoolean(R.styleable.ChromeBasePreference_needRestart, false); + a.recycle(); + } + + public String getFeatureName() { + return mFeatureName; + } + + public boolean needRestart() { + return mNeedRestart; } /** diff --git a/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlag.java b/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlag.java --- a/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlag.java +++ b/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlag.java @@ -162,7 +162,7 @@ public class CachedFlag extends Flag { editor.putBoolean(getSharedPreferenceKey(), featureValue); } - String getSharedPreferenceKey() { + public String getSharedPreferenceKey() { // Create the key only once to avoid String concatenation every flag check. if (mPreferenceKey == null) { mPreferenceKey = CachedFlagsSharedPreferences.FLAGS_CACHED.createKey(mFeatureName); @@ -170,6 +170,12 @@ public class CachedFlag extends Flag { return mPreferenceKey; } + public void setValueReturnedOverride(@Nullable Boolean value) { + synchronized (ValuesReturned.sBoolValues) { + ValuesReturned.sBoolValues.put(getSharedPreferenceKey(), value); + } + } + /** Create a Map of feature names -> {@link CachedFlag} from multiple lists of CachedFlags. */ public static Map createCachedFlagMap( List> allCachedFlagsLists) { diff --git a/components/components_strings.grd b/components/components_strings.grd --- a/components/components_strings.grd +++ b/components/components_strings.grd @@ -282,6 +282,7 @@ + diff --git a/components/content_settings/core/common/features.cc b/components/content_settings/core/common/features.cc --- a/components/content_settings/core/common/features.cc +++ b/components/content_settings/core/common/features.cc @@ -68,5 +68,6 @@ BASE_FEATURE(kTrackingProtection3pcd, base::FEATURE_DISABLED_BY_DEFAULT); BASE_FEATURE(kBlockV8OptimizerOnUnfamiliarSitesSetting, base::FEATURE_ENABLED_BY_DEFAULT); +#include "cromite_flags/components_content_settings_core_common_features_cc.inc" } // namespace features } // namespace content_settings diff --git a/components/cromite_components_strings_grd/placeholder.txt b/components/cromite_components_strings_grd/placeholder.txt new file mode 100644 --- /dev/null +++ b/components/cromite_components_strings_grd/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/components/offline_pages/core/offline_page_feature.cc b/components/offline_pages/core/offline_page_feature.cc --- a/components/offline_pages/core/offline_page_feature.cc +++ b/components/offline_pages/core/offline_page_feature.cc @@ -47,4 +47,5 @@ bool IsOfflinePagesNetworkStateLikelyUnknown() { return base::FeatureList::IsEnabled(kOfflinePagesNetworkStateLikelyUnknown); } +#include "cromite_flags/components_offline_pages_core_offline_page_feature_cc.inc" } // namespace offline_pages diff --git a/components/offline_pages/core/offline_page_feature.h b/components/offline_pages/core/offline_page_feature.h --- a/components/offline_pages/core/offline_page_feature.h +++ b/components/offline_pages/core/offline_page_feature.h @@ -42,6 +42,7 @@ bool IsOnTheFlyMhtmlHashComputationEnabled(); // offline pages to avoid showing them even when the device is online. bool IsOfflinePagesNetworkStateLikelyUnknown(); +#include "cromite_flags/components_offline_pages_core_offline_page_feature_h.inc" } // namespace offline_pages #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_FEATURE_H_ diff --git a/components/password_manager/core/browser/features/password_features.cc b/components/password_manager/core/browser/features/password_features.cc --- a/components/password_manager/core/browser/features/password_features.cc +++ b/components/password_manager/core/browser/features/password_features.cc @@ -216,4 +216,5 @@ BASE_FEATURE(kWebAuthnUsePasskeyFromAnotherDeviceInContextMenu, #endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) +#include "cromite_flags/components_password_manager_core_browser_features_password_features_cc.inc" } // namespace password_manager::features diff --git a/components/permissions/features.cc b/components/permissions/features.cc --- a/components/permissions/features.cc +++ b/components/permissions/features.cc @@ -117,6 +117,7 @@ BASE_FEATURE(kPermissionPredictionsGeolocationAccuracy, BASE_FEATURE(kPermissionsGestureGatedPrompts, base::FEATURE_DISABLED_BY_DEFAULT); +#include "cromite_flags/components_permissions_features_cc.inc" } // namespace features namespace feature_params { diff --git a/components/variations/synthetic_trials_active_group_id_provider.cc b/components/variations/synthetic_trials_active_group_id_provider.cc --- a/components/variations/synthetic_trials_active_group_id_provider.cc +++ b/components/variations/synthetic_trials_active_group_id_provider.cc @@ -27,7 +27,7 @@ SyntheticTrialsActiveGroupIdProvider::GetActiveGroupIds() { return group_ids_; } -#if !defined(NDEBUG) +#if true std::vector SyntheticTrialsActiveGroupIdProvider::GetGroups() { base::AutoLock scoped_lock(lock_); @@ -53,7 +53,7 @@ void SyntheticTrialsActiveGroupIdProvider::OnSyntheticTrialsChanged( for (const auto& group : groups) { group_ids_.push_back(group.id()); } -#if !defined(NDEBUG) +#if true groups_ = groups; #endif // !defined(NDEBUG) } diff --git a/components/variations/synthetic_trials_active_group_id_provider.h b/components/variations/synthetic_trials_active_group_id_provider.h --- a/components/variations/synthetic_trials_active_group_id_provider.h +++ b/components/variations/synthetic_trials_active_group_id_provider.h @@ -36,7 +36,7 @@ class COMPONENT_EXPORT(VARIATIONS) SyntheticTrialsActiveGroupIdProvider // Returns currently active synthetic trial group IDs. std::vector GetActiveGroupIds(); -#if !defined(NDEBUG) +#if true // In debug mode, not only the group IDs are tracked but also the full group // info, to display the names unhashed in chrome://version. std::vector GetGroups(); @@ -60,7 +60,7 @@ class COMPONENT_EXPORT(VARIATIONS) SyntheticTrialsActiveGroupIdProvider base::Lock lock_; std::vector group_ids_; // GUARDED_BY(lock_); -#if !defined(NDEBUG) +#if true // In debug builds, keep the full group information to be able to display it // in chrome://version. std::vector groups_; // GUARDED_BY(lock_); diff --git a/components/webui/flags/flags_state.cc b/components/webui/flags/flags_state.cc --- a/components/webui/flags/flags_state.cc +++ b/components/webui/flags/flags_state.cc @@ -371,6 +371,21 @@ void FlagsState::GetSwitchesAndFeaturesFromFlags( for (const std::string& entry_name : enabled_entries) { const auto& entry_it = name_to_switch_map.find(entry_name); + if (entry_it == name_to_switch_map.end()) { + // check if is a cromite feature + std::string::size_type pos = entry_name.find('@'); + if (pos != std::string::npos) { + std::string feature_name = entry_name.substr(0, pos); + if (base::FeatureList::IsCromiteFlag(feature_name)) { + if (entry_name.ends_with("@1")) + features->insert(entry_name + ":enabled"); + else + features->insert(entry_name + ":disabled"); + continue; + } + } + NOTREACHED(); + } CHECK(entry_it != name_to_switch_map.end()); const SwitchEntry& entry = entry_it->second; @@ -701,6 +716,27 @@ void FlagsState::GetFlagFeatureEntries( data.Set("links", std::move(links)); } + if (entry.type == FeatureEntry::FEATURE_VALUE + || entry.type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE) { + DCHECK(entry.feature.feature); + if (base::FeatureList::IsCromiteChanged(*entry.feature.feature)) { + bool is_enabled = base::FeatureList::GetCromiteChange(*entry.feature.feature); + data.Set("is_cromite", true); + data.Set("default_value", + is_enabled ? "enabled" : "disabled"); + } else { + bool is_enabled = entry.feature.feature->default_state == base::FEATURE_ENABLED_BY_DEFAULT; + data.Set("default_value", is_enabled + ? "enabled" : "disabled"); + if (is_enabled) + data.Set("is_default_value_on", true); + } + if (entry.feature.feature->is_cromite) + data.Set("is_cromite", true); + if (entry.feature.feature->is_new) + data.Set("is_new", true); + } + switch (entry.type) { case FeatureEntry::SINGLE_VALUE: case FeatureEntry::SINGLE_DISABLE_VALUE: @@ -828,6 +864,16 @@ void FlagsState::AddSwitchesToCommandLine( for (const std::string& entry_name : enabled_entries) { const auto& entry_it = name_to_switch_map.find(entry_name); if (entry_it == name_to_switch_map.end()) { + // check if is a cromite feature + std::string::size_type pos = entry_name.find('@'); + if (pos != std::string::npos) { + std::string feature_name = entry_name.substr(0, pos); + if (base::FeatureList::IsCromiteFlag(feature_name)) { + feature_switches[feature_name] = + entry_name.ends_with("@1"); + continue; + } + } NOTREACHED(); } @@ -1074,6 +1120,14 @@ const FeatureEntry* FlagsState::FindFeatureEntryByName( bool FlagsState::IsSupportedFeature(const FlagsStorage* storage, const std::string& name, int platform_mask) const { + // check if is a cromite feature + std::string::size_type pos = name.find('@'); + if (pos != std::string::npos) { + std::string feature_name = name.substr(0, pos); + if (base::FeatureList::IsCromiteFlag(feature_name)) { + return true; + } + } for (const auto& entry : feature_entries_) { DCHECK(entry.IsValid()); if (!(entry.supported_platforms & platform_mask)) { @@ -1112,6 +1166,11 @@ void FlagsState::SetFlags( FindFeatureEntryByName(feature_internal_name); // Since this flag is currently enabled, we know for sure that we can find // its feature entry using its internal name. + if (!entry) { + if (base::FeatureList::IsCromiteFlag(feature_internal_name)) { + continue; + } + } CHECK(entry); if (entry->type == FeatureEntry::FEATURE_VALUE || diff --git a/components/webui/flags/resources/app.css b/components/webui/flags/resources/app.css --- a/components/webui/flags/resources/app.css +++ b/components/webui/flags/resources/app.css @@ -391,3 +391,35 @@ cr-tabs { padding-top: 1.5rem; } } + +#appcontainer { + overflow-y: scroll; +} + +.cromite #header { + display: none; +} + +.cromite .blurb-container { + display: none; +} + +.cromite #tabs { + display: none; +} + +.cromite #tab-content-available { + display: none; +} + +.cromite #tab-content-unavailable { + display: none; +} + +.cromite #tab-content-cromite { + display: block !important; +} + +.cromite .section-header-title { + display: none; +} diff --git a/components/webui/flags/resources/app.html.ts b/components/webui/flags/resources/app.html.ts --- a/components/webui/flags/resources/app.html.ts +++ b/components/webui/flags/resources/app.html.ts @@ -9,6 +9,7 @@ import type {AppElement} from './app.js'; export function getHtml(this: AppElement) { // clang-format off return html` +
+ `; // clang-format on } diff --git a/components/webui/flags/resources/app.ts b/components/webui/flags/resources/app.ts --- a/components/webui/flags/resources/app.ts +++ b/components/webui/flags/resources/app.ts @@ -132,6 +132,7 @@ export class FlagsAppElement extends CrLitElement { // loadTimeData.getString('unavailable'), // + "Cromite", ]; protected accessor selectedTabIndex_: number = 0; @@ -150,9 +151,12 @@ export class FlagsAppElement extends CrLitElement { protected accessor defaultFeatures: Feature[] = []; protected accessor nonDefaultFeatures: Feature[] = []; + protected defaultCromiteFeatures: Feature[] = []; + protected nonDefaultCromiteFeatures: Feature[] = []; protected accessor searching: boolean = false; protected accessor needsRestart: boolean = false; + private onlyCromiteFlags: boolean = false; private announceStatusDelayMs: number = 100; private featuresResolver: PromiseResolver = new PromiseResolver(); private flagSearch: FlagSearch|null = null; @@ -180,6 +184,11 @@ export class FlagsAppElement extends CrLitElement { override connectedCallback() { super.connectedCallback(); + if (location.pathname == '/cromite') { + this.onlyCromiteFlags = true; + this.getRequiredElement("#appcontainer").classList.add('cromite'); + document.title = "Cromite Flags List"; + } // const pathname = new URL(window.location.href).pathname; this.isFlagsDeprecatedUrl_ = @@ -252,10 +261,25 @@ export class FlagsAppElement extends CrLitElement { if (changedPrivateProperties.has('data')) { const defaultFeatures: Feature[] = []; const nonDefaultFeatures: Feature[] = []; + const defaultCromiteFeatures: Feature[] = []; + const nonDefaultCromiteFeatures: Feature[] = []; + + if (this.onlyCromiteFlags) { + this.data.supportedFeatures = + this.data.supportedFeatures.filter(item => item.is_new); + } + this.data.supportedFeatures.forEach( + f => (f.is_cromite + ? (f.is_default ? defaultCromiteFeatures : nonDefaultCromiteFeatures).push(f) + : undefined)); + this.data.supportedFeatures.sort( + (a,b) => (a.internal_name.localeCompare(b.internal_name))); this.data.supportedFeatures.forEach( f => (f.is_default ? defaultFeatures : nonDefaultFeatures).push(f)); + this.defaultCromiteFeatures = defaultCromiteFeatures; + this.nonDefaultCromiteFeatures = nonDefaultCromiteFeatures; this.defaultFeatures = defaultFeatures; this.nonDefaultFeatures = nonDefaultFeatures; diff --git a/components/webui/flags/resources/experiment.css b/components/webui/flags/resources/experiment.css --- a/components/webui/flags/resources/experiment.css +++ b/components/webui/flags/resources/experiment.css @@ -17,6 +17,7 @@ } .experiment { + padding-bottom: 25px; color: var(--secondary-color); line-height: 1.45; width: 100%; @@ -84,6 +85,11 @@ resize: none; } +.experiment-on select { + background: #ddd; + color: var(--link-color); +} + select { background: white; border: 1px solid var(--link-color); @@ -160,6 +166,7 @@ input { @media (max-width: 480px) { .experiment { border-bottom: 1px solid var(--separator-color); + padding-bottom: 8px; } .experiment-name { @@ -177,7 +184,6 @@ input { .experiment .experiment-actions { max-width: 100%; padding-top: 12px; - text-align: left; /* csschecker-disable-line left-right */ width: 100%; } @@ -185,7 +191,6 @@ input { .body { overflow: hidden; text-overflow: ellipsis; - white-space: nowrap; width: 100%; } diff --git a/components/webui/flags/resources/experiment.html.ts b/components/webui/flags/resources/experiment.html.ts --- a/components/webui/flags/resources/experiment.html.ts +++ b/components/webui/flags/resources/experiment.html.ts @@ -10,7 +10,8 @@ export function getHtml(this: ExperimentElement) { // clang-format off return html`
-
+
${this.showingSearchHit_? html`

${this.feature_.options!.map(option => html` `)} diff --git a/components/webui/flags/resources/experiment.ts b/components/webui/flags/resources/experiment.ts --- a/components/webui/flags/resources/experiment.ts +++ b/components/webui/flags/resources/experiment.ts @@ -85,6 +85,11 @@ export class ExperimentElement extends CrLitElement { enabled: false, is_default: false, supported_platforms: [], + is_default_value_on: false, + default_value: '', + is_cromite: false, + is_new: false, + permalink: true, }; // Whether the controls to change the experiment state should be hidden. @@ -125,9 +130,12 @@ export class ExperimentElement extends CrLitElement { } protected getExperimentTitle_(): string { + const suffix = + this.feature_.is_cromite && this.feature_.is_new + ? " (Cromite flag)" : ""; if (this.showEnableDisableSelect_()) { - return this.isDefault_ ? '' : - loadTimeData.getString('experiment-enabled'); + return (this.isDefault_ ? '' : + loadTimeData.getString('experiment-enabled')) + suffix; } return ''; diff --git a/components/webui/flags/resources/flags_browser_proxy.ts b/components/webui/flags/resources/flags_browser_proxy.ts --- a/components/webui/flags/resources/flags_browser_proxy.ts +++ b/components/webui/flags/resources/flags_browser_proxy.ts @@ -16,6 +16,11 @@ export interface Feature { description: string; enabled: boolean; is_default: boolean; + is_default_value_on: boolean; + default_value: string; + is_cromite: boolean; + is_new: boolean; + permalink: boolean; supported_platforms: string[]; origin_list_value?: string; string_value?: string; diff --git a/components/webui/version/version_handler_helper.cc b/components/webui/version/version_handler_helper.cc --- a/components/webui/version/version_handler_helper.cc +++ b/components/webui/version/version_handler_helper.cc @@ -21,7 +21,7 @@ namespace version_ui { namespace { -#if !defined(NDEBUG) +#if true std::string GetActiveGroupNameAsString( const base::FieldTrial::ActiveGroup& group) { static const unsigned char kNonBreakingHyphenUTF8[] = {0xE2, 0x80, 0x91, @@ -84,7 +84,7 @@ base::ListValue GetVariationsList() { base::FieldTrialListIncludingLowAnonymity::GetActiveFieldTrialGroups( &active_groups); -#if !defined(NDEBUG) +#if true for (const auto& group : active_groups) { variations.push_back(GetActiveGroupNameAsString(group)); } diff --git a/content/common/features.cc b/content/common/features.cc --- a/content/common/features.cc +++ b/content/common/features.cc @@ -841,4 +841,5 @@ bool IsEnforceSameDocumentOriginInvariantsEnabled() { blink::features::kTreatMhtmlInitialDocumentLoadsAsCrossDocument); } +#include "cromite_flags/content_common_features_cc.inc" } // namespace features diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc @@ -1502,4 +1502,5 @@ bool IsFluidResizeEnabled() { } #endif +#include "cromite_flags/content_public_common_content_features_cc.inc" } // namespace features diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h --- a/content/public/common/content_features.h +++ b/content/public/common/content_features.h @@ -441,6 +441,7 @@ CONTENT_EXPORT bool IsPushSubscriptionChangeEventEnabled(); CONTENT_EXPORT bool IsFluidResizeEnabled(); #endif +#include "cromite_flags/content_public_common_content_features_h.inc" } // namespace features #endif // CONTENT_PUBLIC_COMMON_CONTENT_FEATURES_H_ diff --git a/cromite_flags/BUILD.gn b/cromite_flags/BUILD.gn new file mode 100755 --- /dev/null +++ b/cromite_flags/BUILD.gn @@ -0,0 +1,174 @@ +# This file is part of Bromite. + +# Bromite is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# Bromite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Bromite. If not, see . + +# for placeholder.txt: +# +# this file is intentionally empty +# + +cpp_bromite_include("chrome_browser_about_flags_cc") { + inputs = [ "//cromite_flags/chrome/browser/about_flags_cc/placeholder.txt" ] + output_file = "chrome_browser_about_flags_cc.inc" +} + +cpp_bromite_include("chrome_common_chrome_features_cc") { + inputs = [ "//cromite_flags/chrome/common/chrome_features_cc/placeholder.txt" ] + output_file = "chrome_common_chrome_features_cc.inc" +} + +cpp_bromite_include("content_common_features_cc") { + inputs = [ "//cromite_flags/content/common/features_cc/placeholder.txt" ] + output_file = "content_common_features_cc.inc" +} + +cpp_bromite_include("content_public_common_content_features_h") { + inputs = [ "//cromite_flags/content/public/common/content_features_h/placeholder.txt" ] + output_file = "content_public_common_content_features_h.inc" +} + +cpp_bromite_include("content_public_common_content_features_cc") { + inputs = [ "//cromite_flags/content/public/common/content_features_cc/placeholder.txt" ] + output_file = "content_public_common_content_features_cc.inc" +} + +cpp_bromite_include("third_party_blink_common_features_cc") { + inputs = [ "//cromite_flags/third_party/blink/common/features_cc/placeholder.txt" ] + output_file = "third_party_blink_common_features_cc.inc" +} + +cpp_bromite_include("third_party_blink_common_features_h") { + inputs = [ "//cromite_flags/third_party/blink/common/features_h/placeholder.txt" ] + output_file = "third_party_blink_common_features_h.inc" +} + +cpp_bromite_include("chrome_browser_flags_android_chrome_feature_list_cc") { + inputs = [ "//cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/placeholder.txt" ] + output_file = "chrome_browser_flags_android_chrome_feature_list_cc.inc" +} + +cpp_bromite_include("chrome_browser_flags_android_chrome_feature_list_h") { + inputs = [ "//cromite_flags/chrome/browser/flags/android/chrome_feature_list_h/placeholder.txt" ] + output_file = "chrome_browser_flags_android_chrome_feature_list_h.inc" +} + +cpp_bromite_include("chrome_browser_browser_features_cc") { + inputs = [ "//cromite_flags/chrome/browser/browser_features_cc/placeholder.txt" ] + output_file = "chrome_browser_browser_features_cc.inc" +} + +cpp_bromite_include("chrome_browser_browser_features_h") { + inputs = [ "//cromite_flags/chrome/browser/browser_features_h/placeholder.txt" ] + output_file = "chrome_browser_browser_features_h.inc" +} + +cpp_bromite_include("chrome_browser_ui_ui_features_cc") { + inputs = [ "//cromite_flags/chrome/browser/ui/ui_features_cc/placeholder.txt" ] + output_file = "chrome_browser_ui_ui_features_cc.inc" +} + +cpp_bromite_include("media_base_media_switches_cc") { + inputs = [ "//cromite_flags/media/base/media_switches_cc/placeholder.txt" ] + output_file = "media_base_media_switches_cc.inc" +} + +cpp_bromite_include("media_base_media_switches_h") { + inputs = [ "//cromite_flags/media/base/media_switches_h/placeholder.txt" ] + output_file = "media_base_media_switches_h.inc" +} + +cpp_bromite_include("components_content_settings_core_common_features_cc") { + inputs = [ "//cromite_flags/components/content_settings/core/common/features_cc/placeholder.txt" ] + output_file = "components_content_settings_core_common_features_cc.inc" +} + +cpp_bromite_include("components_permissions_features_cc") { + inputs = [ "//cromite_flags/components/permissions/features_cc/placeholder.txt" ] + output_file = "components_permissions_features_cc.inc" +} + +cpp_bromite_include("components_offline_pages_core_offline_page_feature_cc") { + inputs = [ "//cromite_flags/components/offline_pages/core/offline_page_feature_cc/placeholder.txt" ] + output_file = "components_offline_pages_core_offline_page_feature_cc.inc" +} + +cpp_bromite_include("components_offline_pages_core_offline_page_feature_h") { + inputs = [ "//cromite_flags/components/offline_pages/core/offline_page_feature_h/placeholder.txt" ] + output_file = "components_offline_pages_core_offline_page_feature_h.inc" +} + +cpp_bromite_include("net_base_features_cc") { + inputs = [ "//cromite_flags/net/base/features_cc/placeholder.txt" ] + output_file = "net_base_features_cc.inc" +} + +cpp_bromite_include("net_base_features_h") { + inputs = [ "//cromite_flags/net/base/features_h/placeholder.txt" ] + output_file = "net_base_features_h.inc" +} + +cpp_bromite_include("services_network_public_cpp_features_cc") { + inputs = [ "//cromite_flags/services/network/public/cpp/features_cc/placeholder.txt" ] + output_file = "services_network_public_cpp_features_cc.inc" +} + +cpp_bromite_include("services_network_public_cpp_features_h") { + inputs = [ "//cromite_flags/services/network/public/cpp/features_h/placeholder.txt" ] + output_file = "services_network_public_cpp_features_h.inc" +} + +cpp_bromite_include("ui_base_features_cc") { + inputs = [ "//cromite_flags/ui/base/features_cc/placeholder.txt" ] + output_file = "ui_base_features_cc.inc" +} + +cpp_bromite_include("ui_base_features_h") { + inputs = [ "//cromite_flags/ui/base/features_h/placeholder.txt" ] + output_file = "ui_base_features_h.inc" +} + +cpp_bromite_include("components_password_manager_core_browser_features_password_features_cc") { + inputs = [ "//cromite_flags/components/password_manager/core/browser/features/password_features_cc/placeholder.txt" ] + output_file = "components_password_manager_core_browser_features_password_features_cc.inc" +} + +component("cromite_flags") { + deps = [ + ":content_common_features_cc", + ":content_public_common_content_features_cc", + ":content_public_common_content_features_h", + ":components_content_settings_core_common_features_cc", + ":components_permissions_features_cc", + ":components_offline_pages_core_offline_page_feature_cc", + ":components_offline_pages_core_offline_page_feature_h", + ":components_password_manager_core_browser_features_password_features_cc", + ":media_base_media_switches_cc", + ":media_base_media_switches_h", + ":net_base_features_cc", + ":net_base_features_h", + ":chrome_common_chrome_features_cc", + ":chrome_browser_about_flags_cc", + ":chrome_browser_flags_android_chrome_feature_list_cc", + ":chrome_browser_flags_android_chrome_feature_list_h", + ":chrome_browser_ui_ui_features_cc", + ":chrome_browser_browser_features_cc", + ":chrome_browser_browser_features_h", + ":services_network_public_cpp_features_cc", + ":services_network_public_cpp_features_h", + ":third_party_blink_common_features_cc", + ":third_party_blink_common_features_h", + ":ui_base_features_cc", + ":ui_base_features_h", + ] +} diff --git a/cromite_flags/chrome/browser/about_flags_cc/placeholder.txt b/cromite_flags/chrome/browser/about_flags_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/browser/about_flags_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/browser/browser_features_cc/placeholder.txt b/cromite_flags/chrome/browser/browser_features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/browser/browser_features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/browser/browser_features_h/placeholder.txt b/cromite_flags/chrome/browser/browser_features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/browser/browser_features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/placeholder.txt b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/browser/flags/android/chrome_feature_list_h/placeholder.txt b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/browser/ui/ui_features_cc/placeholder.txt b/cromite_flags/chrome/browser/ui/ui_features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/browser/ui/ui_features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/common/chrome_features_cc/placeholder.txt b/cromite_flags/chrome/common/chrome_features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/common/chrome_features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/chrome/common/chrome_features_h/placeholder.txt b/cromite_flags/chrome/common/chrome_features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/chrome/common/chrome_features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/components/content_settings/core/common/features_cc/placeholder.txt b/cromite_flags/components/content_settings/core/common/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/components/content_settings/core/common/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/components/offline_pages/core/offline_page_feature_cc/placeholder.txt b/cromite_flags/components/offline_pages/core/offline_page_feature_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/components/offline_pages/core/offline_page_feature_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/components/offline_pages/core/offline_page_feature_h/placeholder.txt b/cromite_flags/components/offline_pages/core/offline_page_feature_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/components/offline_pages/core/offline_page_feature_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/components/password_manager/core/browser/features/password_features_cc/placeholder.txt b/cromite_flags/components/password_manager/core/browser/features/password_features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/components/password_manager/core/browser/features/password_features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/components/permissions/features_cc/placeholder.txt b/cromite_flags/components/permissions/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/components/permissions/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/content/common/features_cc/placeholder.txt b/cromite_flags/content/common/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/content/common/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/content/public/common/content_features_cc/placeholder.txt b/cromite_flags/content/public/common/content_features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/content/public/common/content_features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/content/public/common/content_features_h/placeholder.txt b/cromite_flags/content/public/common/content_features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/content/public/common/content_features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/media/base/media_switches_cc/placeholder.txt b/cromite_flags/media/base/media_switches_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/media/base/media_switches_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/media/base/media_switches_h/placeholder.txt b/cromite_flags/media/base/media_switches_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/media/base/media_switches_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/net/base/features_cc/placeholder.txt b/cromite_flags/net/base/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/net/base/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/net/base/features_h/placeholder.txt b/cromite_flags/net/base/features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/net/base/features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/services/network/public/cpp/features_cc/placeholder.txt b/cromite_flags/services/network/public/cpp/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/services/network/public/cpp/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/services/network/public/cpp/features_h/placeholder.txt b/cromite_flags/services/network/public/cpp/features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/services/network/public/cpp/features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/third_party/blink/common/features_cc/placeholder.txt b/cromite_flags/third_party/blink/common/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/third_party/blink/common/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/third_party/blink/common/features_h/placeholder.txt b/cromite_flags/third_party/blink/common/features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/third_party/blink/common/features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/ui/base/features_cc/placeholder.txt b/cromite_flags/ui/base/features_cc/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/ui/base/features_cc/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/cromite_flags/ui/base/features_h/placeholder.txt b/cromite_flags/ui/base/features_h/placeholder.txt new file mode 100755 --- /dev/null +++ b/cromite_flags/ui/base/features_h/placeholder.txt @@ -0,0 +1 @@ +this file is intentionally empty diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc --- a/media/base/media_switches.cc +++ b/media/base/media_switches.cc @@ -1901,5 +1901,5 @@ uint32_t GetPassthroughAudioFormats() { return 0; #endif // BUILDFLAG(ENABLE_PASSTHROUGH_AUDIO_CODECS) } - +#include "cromite_flags/media_base_media_switches_cc.inc" } // namespace media diff --git a/media/base/media_switches.h b/media/base/media_switches.h --- a/media/base/media_switches.h +++ b/media/base/media_switches.h @@ -608,5 +608,5 @@ MEDIA_EXPORT bool IsOutOfProcessVideoDecodingEnabled(); MEDIA_EXPORT uint32_t GetPassthroughAudioFormats(); } // namespace media - +#include "cromite_flags/media_base_media_switches_h.inc" #endif // MEDIA_BASE_MEDIA_SWITCHES_H_ diff --git a/net/base/features.cc b/net/base/features.cc --- a/net/base/features.cc +++ b/net/base/features.cc @@ -841,4 +841,5 @@ BASE_FEATURE(kIgnoreQuicCryptoConfigMemoryPressureForDoh, BASE_FEATURE(kCookieParseRejectEmptyNameAmbiguous, base::FEATURE_ENABLED_BY_DEFAULT); +#include "cromite_flags/net_base_features_cc.inc" } // namespace net::features diff --git a/net/base/features.h b/net/base/features.h --- a/net/base/features.h +++ b/net/base/features.h @@ -865,6 +865,7 @@ NET_EXPORT BASE_DECLARE_FEATURE(kIgnoreQuicCryptoConfigMemoryPressureForDoh); // serialization. NET_EXPORT BASE_DECLARE_FEATURE(kCookieParseRejectEmptyNameAmbiguous); +#include "cromite_flags/net_base_features_h.inc" } // namespace net::features #endif // NET_BASE_FEATURES_H_ diff --git a/services/network/public/cpp/features.cc b/services/network/public/cpp/features.cc --- a/services/network/public/cpp/features.cc +++ b/services/network/public/cpp/features.cc @@ -649,4 +649,5 @@ BASE_FEATURE_PARAM(base::TimeDelta, "initial_doh_probe_timeout", base::Seconds(5)); +#include "cromite_flags/services_network_public_cpp_features_cc.inc" } // namespace network::features diff --git a/services/network/public/cpp/features.h b/services/network/public/cpp/features.h --- a/services/network/public/cpp/features.h +++ b/services/network/public/cpp/features.h @@ -438,6 +438,7 @@ BASE_DECLARE_FEATURE(kDelayInitialDohProbeTimeout); COMPONENT_EXPORT(NETWORK_CPP_FLAGS_AND_SWITCHES) BASE_DECLARE_FEATURE_PARAM(base::TimeDelta, kDelayInitialDohProbeTimeoutParam); +#include "cromite_flags/services_network_public_cpp_features_h.inc" } // namespace network::features #endif // SERVICES_NETWORK_PUBLIC_CPP_FEATURES_H_ diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc @@ -2801,4 +2801,5 @@ bool IsXrDevice() { // // DO NOT ADD NEW FEATURES HERE. +#include "cromite_flags/third_party_blink_common_features_cc.inc" } // namespace blink::features diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h --- a/third_party/blink/public/common/features.h +++ b/third_party/blink/public/common/features.h @@ -2053,6 +2053,7 @@ BLINK_COMMON_EXPORT bool IsXrDevice(); // // DO NOT ADD NEW FEATURES HERE. +#include "cromite_flags/third_party_blink_common_features_h.inc" } // namespace features } // namespace blink diff --git a/ui/base/ui_base_features.cc b/ui/base/ui_base_features.cc --- a/ui/base/ui_base_features.cc +++ b/ui/base/ui_base_features.cc @@ -463,4 +463,5 @@ BASE_FEATURE_PARAM(int, BASE_FEATURE(kSplitViewLinkOpen, base::FEATURE_DISABLED_BY_DEFAULT); +#include "cromite_flags/ui_base_features_cc.inc" } // namespace features diff --git a/ui/base/ui_base_features.h b/ui/base/ui_base_features.h --- a/ui/base/ui_base_features.h +++ b/ui/base/ui_base_features.h @@ -304,6 +304,7 @@ BASE_DECLARE_FEATURE_PARAM(int, kCompensationAcceptableLatencyMs); COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kSplitViewLinkOpen); +#include "cromite_flags/ui_base_features_h.inc" } // namespace features #endif // UI_BASE_UI_BASE_FEATURES_H_ --