inputs: migrate Dogfood flag to chromeos for consistency
This is the reland of https://chromium-review.googlesource.com/c/chromium/src/+/4871016
There is also another flag that is enabled only during the Dogfood period. Currently, the main flag sits inside chromeos folder, and the Dogfood flag sits inside ash/ folder. The logic to enable EditorMenuController is currently only relying on the main flag,
and it needs to also rely on the Dogfood flag as well.
This CL migrates the Dogfood flag to chromeos. This CL ensures that both `ash/` and `chromeos/` can have access to both main and dogfood flag values.
Bug: b:295440693
Change-Id: Ieeb353e7b013ce07ff8e9d224c074279b2b270fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4870980
Commit-Queue: Chuong Ho <hdchuong@google.com>
Reviewed-by: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1200777}
diff --git a/ash/constants/ash_features.cc b/ash/constants/ash_features.cc
index bfb50fa..b83f55e1b 100644
--- a/ash/constants/ash_features.cc
+++ b/ash/constants/ash_features.cc
@@ -186,9 +186,6 @@
"AssistMultiWordExpanded",
base::FEATURE_DISABLED_BY_DEFAULT);
-// Controls enabling / disabling the orca feature for dogfood population.
-BASE_FEATURE(kOrcaDogfood, "OrcaDogfood", base::FEATURE_DISABLED_BY_DEFAULT);
-
// Controls enabling / disabling the orca feature from the feature management
// module.
BASE_FEATURE(kFeatureManagementOrca,
diff --git a/ash/constants/ash_features.h b/ash/constants/ash_features.h
index debe78ea..495299f 100644
--- a/ash/constants/ash_features.h
+++ b/ash/constants/ash_features.h
@@ -551,7 +551,6 @@
COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kOnlyShowNewShortcutsApp);
COMPONENT_EXPORT(ASH_CONSTANTS)
BASE_DECLARE_FEATURE(kSearchCustomizableShortcutsInLauncher);
-COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kOrcaDogfood);
COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kFeatureManagementOrca);
COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kOobeChoobe);
COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kOobeDrivePinning);
diff --git a/chrome/browser/ash/input_method/editor_consent_store.cc b/chrome/browser/ash/input_method/editor_consent_store.cc
index 955dc65..926644a 100644
--- a/chrome/browser/ash/input_method/editor_consent_store.cc
+++ b/chrome/browser/ash/input_method/editor_consent_store.cc
@@ -10,13 +10,8 @@
namespace ash::input_method {
EditorConsentStore::EditorConsentStore(PrefService* pref_service)
- : pref_service_(pref_service),
- pref_change_registrar_(std::make_unique<PrefChangeRegistrar>()) {
- pref_change_registrar_->Init(pref_service_);
- pref_change_registrar_->Add(
- ash::prefs::kOrcaEnabled,
- base::BindRepeating(&EditorConsentStore::OnUserPrefChanged,
- weak_ptr_factory_.GetWeakPtr()));
+ : pref_service_(pref_service) {
+ InitializePrefChangeRegistrar(pref_service);
}
EditorConsentStore::~EditorConsentStore() = default;
@@ -74,8 +69,20 @@
pref_service_->SetBoolean(prefs::kOrcaEnabled, new_pref_value);
}
+void EditorConsentStore::InitializePrefChangeRegistrar(
+ PrefService* pref_service) {
+ pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
+ pref_change_registrar_->Init(pref_service);
+ pref_change_registrar_->Add(
+ ash::prefs::kOrcaEnabled,
+ base::BindRepeating(&EditorConsentStore::OnUserPrefChanged,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
void EditorConsentStore::SetPrefService(PrefService* pref_service) {
pref_service_ = pref_service;
+ pref_change_registrar_.reset();
+ InitializePrefChangeRegistrar(pref_service_);
}
} // namespace ash::input_method
diff --git a/chrome/browser/ash/input_method/editor_consent_store.h b/chrome/browser/ash/input_method/editor_consent_store.h
index eb9545fa..e1143bf 100644
--- a/chrome/browser/ash/input_method/editor_consent_store.h
+++ b/chrome/browser/ash/input_method/editor_consent_store.h
@@ -39,6 +39,8 @@
void OverrideUserPref(bool new_pref_value);
+ void InitializePrefChangeRegistrar(PrefService* pref_service);
+
// Not owned by this class.
raw_ptr<PrefService> pref_service_;
diff --git a/chrome/browser/ash/input_method/editor_mediator.cc b/chrome/browser/ash/input_method/editor_mediator.cc
index 009eba5..d8916936 100644
--- a/chrome/browser/ash/input_method/editor_mediator.cc
+++ b/chrome/browser/ash/input_method/editor_mediator.cc
@@ -200,7 +200,9 @@
profile_observation_.Observe(profile_);
editor_switch_->SetProfile(profile_);
consent_store_->SetPrefService(profile_->GetPrefs());
- text_query_provider_->OnProfileChanged(profile_);
+ if (text_query_provider_ != nullptr) {
+ text_query_provider_->OnProfileChanged(profile_);
+ }
}
void EditorMediator::OnProfileWillBeDestroyed(Profile* profile) {
diff --git a/chrome/browser/ash/input_method/editor_switch.cc b/chrome/browser/ash/input_method/editor_switch.cc
index 0d2d3bb..ab39f73 100644
--- a/chrome/browser/ash/input_method/editor_switch.cc
+++ b/chrome/browser/ash/input_method/editor_switch.cc
@@ -74,10 +74,10 @@
bool is_managed = profile_->GetProfilePolicyConnector()->IsManaged();
return // Conditions required for dogfooding.
- (base::FeatureList::IsEnabled(features::kOrcaDogfood)) ||
+ (base::FeatureList::IsEnabled(chromeos::features::kOrcaDogfood)) ||
// Conditions required for the feature to be enabled for non-dogfood
// population.
- (chromeos::features::IsOrcaEnabled() &&
+ (base::FeatureList::IsEnabled(chromeos::features::kOrca) &&
base::FeatureList::IsEnabled(features::kFeatureManagementOrca) &&
!is_managed && IsCountryAllowed(country_code_));
}
@@ -92,7 +92,6 @@
!tablet_mode_enabled_ &&
// user pref value
profile_->GetPrefs()->GetBoolean(prefs::kOrcaEnabled);
- ;
}
EditorMode EditorSwitch::GetEditorMode() const {
diff --git a/chrome/browser/ash/input_method/editor_switch_unittest.cc b/chrome/browser/ash/input_method/editor_switch_unittest.cc
index 69ca443..da1b958 100644
--- a/chrome/browser/ash/input_method/editor_switch_unittest.cc
+++ b/chrome/browser/ash/input_method/editor_switch_unittest.cc
@@ -48,6 +48,7 @@
EditorSwitch editor_switch(/*profile=*/&profile_,
/*country_code=*/kAllowedTestCountry);
+ EXPECT_FALSE(chromeos::features::IsOrcaEnabled());
EXPECT_FALSE(editor_switch.IsAllowedForUse());
}
@@ -66,6 +67,18 @@
EXPECT_FALSE(editor_switch.IsAllowedForUse());
}
+TEST_F(EditorSwitchTest,
+ FeatureWillBeAvailableForUseWhenReceivingOrcaDogfoodFlag) {
+ base::test::ScopedFeatureList feature_list(chromeos::features::kOrcaDogfood);
+ TestingProfile profile_;
+ profile_.GetProfilePolicyConnector()->OverrideIsManagedForTesting(false);
+ EditorSwitch editor_switch(/*profile=*/&profile_,
+ /*country_code=*/kAllowedTestCountry);
+
+ EXPECT_TRUE(chromeos::features::IsOrcaEnabled());
+ EXPECT_TRUE(editor_switch.IsAllowedForUse());
+}
+
TEST_F(EditorSwitchTest, FeatureWillNotBeAvailableForACountryNotApprovedYet) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures(
diff --git a/chrome/browser/ash/input_method/editor_text_query_provider.cc b/chrome/browser/ash/input_method/editor_text_query_provider.cc
index 732b101..d813b3f 100644
--- a/chrome/browser/ash/input_method/editor_text_query_provider.cc
+++ b/chrome/browser/ash/input_method/editor_text_query_provider.cc
@@ -6,6 +6,7 @@
#include "base/notreached.h"
#include "base/values.h"
+#include "chrome/browser/browser_features.h"
#include "chrome/browser/manta/manta_service.h"
#include "chrome/browser/manta/manta_service_factory.h"
#include "chrome/browser/manta/manta_status.h"
@@ -15,7 +16,7 @@
namespace {
std::unique_ptr<manta::OrcaProvider> CreateProvider(Profile* profile) {
- if (manta::MantaServiceFactory::GetInstance() == nullptr) {
+ if (!base::FeatureList::IsEnabled(::features::kMantaService)) {
return nullptr;
}
diff --git a/chrome/browser/ui/quick_answers/read_write_cards_manager_impl.cc b/chrome/browser/ui/quick_answers/read_write_cards_manager_impl.cc
index f0d849b..a6246fc 100644
--- a/chrome/browser/ui/quick_answers/read_write_cards_manager_impl.cc
+++ b/chrome/browser/ui/quick_answers/read_write_cards_manager_impl.cc
@@ -29,7 +29,7 @@
"\x7a\xf3\xa1\x57\x28\x48\xc4\x14\x27\x13\x53\x5a\x09\xf3\x0e\xfc\xee\xa6"
"\xbb\xa4";
-void CheckOrcaKey() {
+bool CheckOrcaKey() {
const std::string& debug_key_hash = base::SHA1HashString(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
/*ash::switches::kOrcaKey=*/kOrcaKey));
@@ -37,8 +37,11 @@
// Commandline looks like:
// out/Default/chrome --user-data-dir=/tmp/auuf123 --orca-key="INSERT KEY
// HERE" --enable-features=Orca
- CHECK_EQ(debug_key_hash, kOrcaKeyHash)
- << "Provided debug key does not match with the expected one.";
+ bool orca_key_check = (debug_key_hash == kOrcaKeyHash);
+ if (!orca_key_check) {
+ LOG(ERROR) << "Provided debug key does not match with the expected one.";
+ }
+ return orca_key_check;
}
} // namespace
@@ -71,8 +74,7 @@
if (chromeos::features::IsOrcaEnabled()) {
if (params.is_editable) {
- CheckOrcaKey();
- return editor_menu_controller_.get();
+ return CheckOrcaKey() ? editor_menu_controller_.get() : nullptr;
}
}
diff --git a/chrome/browser/ui/views/editor_menu/editor_menu_browsertest.cc b/chrome/browser/ui/views/editor_menu/editor_menu_browsertest.cc
index 346ec6d..6310035 100644
--- a/chrome/browser/ui/views/editor_menu/editor_menu_browsertest.cc
+++ b/chrome/browser/ui/views/editor_menu/editor_menu_browsertest.cc
@@ -54,6 +54,17 @@
base::test::ScopedFeatureList feature_list_;
};
+class EditorMenuBrowserFeatureDisabledTest : public EditorMenuBrowserTest {
+ public:
+ EditorMenuBrowserFeatureDisabledTest() {
+ feature_list_.InitWithFeatures(
+ /*enabled_features=*/{},
+ /*disabled_features=*/{chromeos::features::kOrcaDogfood});
+ }
+
+ ~EditorMenuBrowserFeatureDisabledTest() override = default;
+};
+
class EditorMenuBrowserFeatureEnabledTest : public EditorMenuBrowserTest {
public:
EditorMenuBrowserFeatureEnabledTest() {
@@ -63,7 +74,7 @@
~EditorMenuBrowserFeatureEnabledTest() override = default;
};
-IN_PROC_BROWSER_TEST_F(EditorMenuBrowserTest,
+IN_PROC_BROWSER_TEST_F(EditorMenuBrowserFeatureDisabledTest,
ShouldNotCreateWhenFeatureNotEnabled) {
EXPECT_FALSE(chromeos::features::IsOrcaEnabled());
EXPECT_EQ(nullptr, GetControllerImpl());
diff --git a/chromeos/constants/chromeos_features.cc b/chromeos/constants/chromeos_features.cc
index 0da62b7..61f57cde 100644
--- a/chromeos/constants/chromeos_features.cc
+++ b/chromeos/constants/chromeos_features.cc
@@ -93,6 +93,9 @@
// Controls enabling / disabling the orca feature.
BASE_FEATURE(kOrca, "Orca", base::FEATURE_DISABLED_BY_DEFAULT);
+// Controls enabling / disabling the orca feature for dogfood population.
+BASE_FEATURE(kOrcaDogfood, "OrcaDogfood", base::FEATURE_DISABLED_BY_DEFAULT);
+
// Controls whether to enable quick answers V2 settings sub-toggles.
BASE_FEATURE(kQuickAnswersV2SettingsSubToggle,
"QuickAnswersV2SettingsSubToggle",
@@ -165,7 +168,8 @@
}
bool IsOrcaEnabled() {
- return base::FeatureList::IsEnabled(kOrca);
+ return base::FeatureList::IsEnabled(kOrca) ||
+ base::FeatureList::IsEnabled(kOrcaDogfood);
}
bool IsQuickAnswersV2TranslationDisabled() {
diff --git a/chromeos/constants/chromeos_features.h b/chromeos/constants/chromeos_features.h
index 91dcfe22..02cdcaa 100644
--- a/chromeos/constants/chromeos_features.h
+++ b/chromeos/constants/chromeos_features.h
@@ -43,6 +43,7 @@
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kJelly);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kJellyroll);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kOrca);
+COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kOrcaDogfood);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
BASE_DECLARE_FEATURE(kQuickAnswersRichCard);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)