#include "components/optimization_guide/core/model_execution/model_execution_features_controller.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "components/component_updater/pref_names.h"
#include "components/optimization_guide/core/feature_registry/mqls_feature_registry.h"
#include "components/optimization_guide/core/feature_registry/settings_ui_registry.h"
#include "components/optimization_guide/core/model_execution/feature_keys.h"
#include "components/optimization_guide/core/model_execution/model_execution_features.h"
#include "components/optimization_guide/core/model_execution/model_execution_prefs.h"
#include "components/optimization_guide/core/optimization_guide_prefs.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "third_party/tflite/buildflags.h"
namespace optimization_guide {
namespace {
class ScopedSettingsVisibilityResultHistogramRecorder { … };
enum class FeatureCurrentlyEnabledResult { … };
class ScopedFeatureCurrentlyEnabledHistogramRecorder { … };
bool CanUseModelExecutionFeaturesFromAccountInfo(
const AccountInfo account_info) { … }
bool CanUseModelExecutionFeatures(signin::IdentityManager* identity_manager) { … }
}
ModelExecutionFeaturesController::ModelExecutionFeaturesController(
PrefService* browser_context_profile_service,
signin::IdentityManager* identity_manager,
PrefService* local_state,
DogfoodStatus dogfood_status)
: … { … }
ModelExecutionFeaturesController::~ModelExecutionFeaturesController() = default;
bool ModelExecutionFeaturesController::ShouldFeatureBeCurrentlyEnabledForUser(
UserVisibleFeatureKey feature) const { … }
bool ModelExecutionFeaturesController::
ShouldFeatureBeCurrentlyAllowedForLogging(
const MqlsFeatureMetadata* metadata) const { … }
prefs::FeatureOptInState ModelExecutionFeaturesController::GetPrefState(
UserVisibleFeatureKey feature) const { … }
ModelExecutionFeaturesController::UserValidityResult
ModelExecutionFeaturesController::GetCurrentUserValidityResult(
UserVisibleFeatureKey feature) const { … }
ModelExecutionFeaturesController::SettingsVisibilityResult
ModelExecutionFeaturesController::ShouldHideHistorySearch() const { … }
bool ModelExecutionFeaturesController::IsSettingVisible(
UserVisibleFeatureKey feature) const { … }
void ModelExecutionFeaturesController::AddObserver(
SettingsEnabledObserver* observer) { … }
void ModelExecutionFeaturesController::RemoveObserver(
SettingsEnabledObserver* observer) { … }
void ModelExecutionFeaturesController::OnIdentityManagerShutdown(
signin::IdentityManager* identity_manager) { … }
void ModelExecutionFeaturesController::OnFeatureSettingPrefChanged(
UserVisibleFeatureKey feature) { … }
void ModelExecutionFeaturesController::OnFeatureEnterprisePolicyPrefChanged(
UserVisibleFeatureKey feature) { … }
void ModelExecutionFeaturesController::InitializeFeatureSettings() { … }
void ModelExecutionFeaturesController::StartObservingAccountChanges() { … }
void ModelExecutionFeaturesController::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) { … }
void ModelExecutionFeaturesController::OnExtendedAccountInfoUpdated(
const AccountInfo& info) { … }
void ModelExecutionFeaturesController::ResetInvalidFeaturePrefs() { … }
void ModelExecutionFeaturesController::OnMainToggleSettingStatePrefChanged() { … }
void ModelExecutionFeaturesController::InitializePrefListener() { … }
}