From: uazo <uazo@users.noreply.github.com>
Date: Tue, 25 Jan 2022 12:22:52 +0000
Subject: Disable all predictors code

Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
 .../chrome_hints_manager.cc                   |  1 +
 chrome/common/chrome_features.cc              |  8 ++--
 .../optimization_guide/core/hints_fetcher.cc  |  1 +
 .../optimization_guide/core/hints_manager.cc  |  5 +++
 .../core/optimization_guide_features.cc       | 38 +++++++++----------
 .../core/prediction_model_download_manager.cc |  6 ++-
 .../core/prediction_model_fetcher_impl.cc     |  1 +
 components/optimization_guide/features.gni    |  4 +-
 components/permissions/features.cc            |  8 ++--
 third_party/blink/common/features.cc          |  8 +---
 10 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/chrome/browser/optimization_guide/chrome_hints_manager.cc b/chrome/browser/optimization_guide/chrome_hints_manager.cc
--- a/chrome/browser/optimization_guide/chrome_hints_manager.cc
+++ b/chrome/browser/optimization_guide/chrome_hints_manager.cc
@@ -26,6 +26,7 @@ bool IsAllowedToFetchForNavigationPrediction(
     const absl::optional<NavigationPredictorKeyedService::Prediction>
         prediction) {
   DCHECK(prediction);
+  if ((true)) return false;
 
   if (prediction->prediction_source() !=
       NavigationPredictorKeyedService::PredictionSource::
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
@@ -883,8 +883,8 @@ BASE_FEATURE(kPermissionAuditing,
 // Enables using the prediction service for permission prompts. We will keep
 // this feature in order to allow us to update the holdback chance via finch.
 BASE_FEATURE(kPermissionPredictions,
-             "PermissionPredictions",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "PermissionPredictions",               // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);    // in Bromite
 
 // The holdback chance is 30% but it can also be configured/updated
 // through finch if needed.
@@ -895,8 +895,8 @@ const base::FeatureParam<double> kPermissionPredictionsHoldbackChance(
 
 // Enables using the prediction service for geolocation permission prompts.
 BASE_FEATURE(kPermissionGeolocationPredictions,
-             "PermissionGeolocationPredictions",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "PermissionGeolocationPredictions",        // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);        // in Bromite
 
 const base::FeatureParam<double>
     kPermissionGeolocationPredictionsHoldbackChance(
diff --git a/components/optimization_guide/core/hints_fetcher.cc b/components/optimization_guide/core/hints_fetcher.cc
--- a/components/optimization_guide/core/hints_fetcher.cc
+++ b/components/optimization_guide/core/hints_fetcher.cc
@@ -174,6 +174,7 @@ bool HintsFetcher::FetchOptimizationGuideServiceHints(
     optimization_guide::proto::RequestContext request_context,
     const std::string& locale,
     HintsFetchedCallback hints_fetched_callback) {
+  if ((true)) return false;
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
   DCHECK_GT(optimization_types.size(), 0u);
   request_context_ = request_context;
diff --git a/components/optimization_guide/core/hints_manager.cc b/components/optimization_guide/core/hints_manager.cc
--- a/components/optimization_guide/core/hints_manager.cc
+++ b/components/optimization_guide/core/hints_manager.cc
@@ -352,6 +352,7 @@ void HintsManager::Shutdown() {
 OptimizationGuideDecision
 HintsManager::GetOptimizationGuideDecisionFromOptimizationTypeDecision(
     OptimizationTypeDecision optimization_type_decision) {
+  if ((true)) return OptimizationGuideDecision::kFalse;
   switch (optimization_type_decision) {
     case OptimizationTypeDecision::kAllowedByOptimizationFilter:
     case OptimizationTypeDecision::kAllowedByHint:
@@ -1056,6 +1057,7 @@ void HintsManager::CanApplyOptimizationOnDemand(
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
 
   // TODO(crbug/1275612): Check whether we have consent to fetch.
+  if ((true)) return; // no consent on bromite
 
   // This set contains URLs that require some information to be fetched, whether
   // that be a URL-keyed hint or a host-keyed hint.
@@ -1263,6 +1265,9 @@ OptimizationTypeDecision HintsManager::CanApplyOptimization(
     proto::OptimizationType optimization_type,
     OptimizationMetadata* optimization_metadata) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+  if ((true)) {
+    return OptimizationTypeDecision::kNoHintAvailable;
+  }
 
   ScopedCanApplyOptimizationLogger scoped_logger(
       optimization_type, navigation_url, optimization_guide_logger_);
diff --git a/components/optimization_guide/core/optimization_guide_features.cc b/components/optimization_guide/core/optimization_guide_features.cc
--- a/components/optimization_guide/core/optimization_guide_features.cc
+++ b/components/optimization_guide/core/optimization_guide_features.cc
@@ -78,17 +78,17 @@ bool IsSupportedLocaleForFeature(const std::string locale,
 // Enables the syncing of the Optimization Hints component, which provides
 // hints for what optimizations can be applied on a page load.
 BASE_FEATURE(kOptimizationHints,
-             "OptimizationHints",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "OptimizationHints",                   // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);    // in Bromite
 
 // Enables fetching from a remote Optimization Guide Service.
 BASE_FEATURE(kRemoteOptimizationGuideFetching,
-             "OptimizationHintsFetching",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "OptimizationHintsFetching",           // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);    // in Bromite
 
 BASE_FEATURE(kRemoteOptimizationGuideFetchingAnonymousDataConsent,
-             "OptimizationHintsFetchingAnonymousDataConsent",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "OptimizationHintsFetchingAnonymousDataConsent",        // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);                     // in Bromite
 
 // Enables performance info in the context menu and fetching from a remote
 // Optimization Guide Service.
@@ -98,17 +98,13 @@ BASE_FEATURE(kContextMenuPerformanceInfoAndRemoteHintFetching,
 
 // Enables the prediction of optimization targets.
 BASE_FEATURE(kOptimizationTargetPrediction,
-             "OptimizationTargetPrediction",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "OptimizationTargetPrediction",                         // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);                     // in Bromite
 
 // Enables the downloading of models.
 BASE_FEATURE(kOptimizationGuideModelDownloading,
-             "OptimizationGuideModelDownloading",
-#if BUILDFLAG(BUILD_WITH_TFLITE_LIB)
-             base::FEATURE_ENABLED_BY_DEFAULT
-#else   // BUILD_WITH_TFLITE_LIB
-             base::FEATURE_DISABLED_BY_DEFAULT
-#endif  // !BUILD_WITH_TFLITE_LIB
+             "OptimizationGuideModelDownloading",                    // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT                       // in Bromite
 );
 
 // Enables page content to be annotated.
@@ -143,8 +139,8 @@ BASE_FEATURE(kPageEntitiesModelResetOnShutdown,
 
 // Enables push notification of hints.
 BASE_FEATURE(kPushNotifications,
-             "OptimizationGuidePushNotifications",
-             base::FEATURE_DISABLED_BY_DEFAULT);
+             "OptimizationGuidePushNotifications",    // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);      // in Bromite
 
 // This feature flag does not turn off any behavior, it is only used for
 // experiment parameters.
@@ -158,15 +154,15 @@ BASE_FEATURE(kOptimizationGuideMetadataValidation,
              base::FEATURE_DISABLED_BY_DEFAULT);
 
 BASE_FEATURE(kPageTopicsBatchAnnotations,
-             "PageTopicsBatchAnnotations",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "PageTopicsBatchAnnotations",             // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);       // in Bromite
 BASE_FEATURE(kPageVisibilityBatchAnnotations,
              "PageVisibilityBatchAnnotations",
              base::FEATURE_ENABLED_BY_DEFAULT);
 
 BASE_FEATURE(kUseLocalPageEntitiesMetadataProvider,
-             "UseLocalPageEntitiesMetadataProvider",
-             base::FEATURE_DISABLED_BY_DEFAULT);
+             "UseLocalPageEntitiesMetadataProvider",   // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);       // in Bromite
 
 BASE_FEATURE(kPageContentAnnotationsValidation,
              "PageContentAnnotationsValidation",
@@ -408,7 +404,7 @@ size_t MaxURLKeyedHintCacheSize() {
 
 bool ShouldPersistHintsToDisk() {
   return GetFieldTrialParamByFeatureAsBool(kOptimizationHints,
-                                           "persist_hints_to_disk", true);
+                                           "persist_hints_to_disk", false);
 }
 
 bool ShouldOverrideOptimizationTargetDecisionForMetricsPurposes(
diff --git a/components/optimization_guide/core/prediction_model_download_manager.cc b/components/optimization_guide/core/prediction_model_download_manager.cc
--- a/components/optimization_guide/core/prediction_model_download_manager.cc
+++ b/components/optimization_guide/core/prediction_model_download_manager.cc
@@ -46,7 +46,7 @@ constexpr char kGoogApiKey[] = "X-Goog-Api-Key";
 // we require models to come from.
 constexpr uint8_t kPublisherKeyHash[] = {
     0x66, 0xa1, 0xd9, 0x3e, 0x4e, 0x5a, 0x66, 0x8a, 0x0f, 0xd3, 0xfa,
-    0xa3, 0x70, 0x71, 0x42, 0x16, 0x0d, 0x2d, 0x68, 0xb0, 0x53, 0x02,
+    0x01, 0x02, 0x03, 0x04, 0x16, 0x0d, 0x2d, 0x68, 0xb0, 0x53, 0x02,
     0x5c, 0x7f, 0xd0, 0x0c, 0xa1, 0x6e, 0xef, 0xdd, 0x63, 0x7a};
 const net::NetworkTrafficAnnotationTag
     kOptimizationGuidePredictionModelsTrafficAnnotation =
@@ -99,7 +99,7 @@ PredictionModelDownloadManager::PredictionModelDownloadManager(
     const base::FilePath& models_dir_path,
     scoped_refptr<base::SequencedTaskRunner> background_task_runner)
     : download_service_(download_service),
-      is_available_for_downloads_(true),
+      is_available_for_downloads_(false),
       api_key_(features::GetOptimizationGuideServiceAPIKey()),
       models_dir_path_(models_dir_path),
       background_task_runner_(background_task_runner) {}
@@ -114,6 +114,7 @@ base::FilePath::StringType PredictionModelDownloadManager::ModelInfoFileName() {
 void PredictionModelDownloadManager::StartDownload(
     const GURL& download_url,
     proto::OptimizationTarget optimization_target) {
+  if ((true)) return;
   download::DownloadParams download_params;
   download_params.client =
       download::DownloadClient::OPTIMIZATION_GUIDE_PREDICTION_MODELS;
@@ -250,6 +251,7 @@ void PredictionModelDownloadManager::OnDownloadFailed(
 absl::optional<std::pair<base::FilePath, base::FilePath>>
 PredictionModelDownloadManager::VerifyDownload(const base::FilePath& file_path,
                                                bool delete_file_on_error) {
+  if ((true)) return absl::nullopt;
   if (!switches::ShouldSkipModelDownloadVerificationForTesting()) {
     // Verify that the |file_path| contains a valid CRX file.
     std::string public_key;
diff --git a/components/optimization_guide/core/prediction_model_fetcher_impl.cc b/components/optimization_guide/core/prediction_model_fetcher_impl.cc
--- a/components/optimization_guide/core/prediction_model_fetcher_impl.cc
+++ b/components/optimization_guide/core/prediction_model_fetcher_impl.cc
@@ -50,6 +50,7 @@ bool PredictionModelFetcherImpl::FetchOptimizationGuideServiceModels(
     proto::RequestContext request_context,
     const std::string& locale,
     ModelsFetchedCallback models_fetched_callback) {
+  if ((true)) return false;
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
 
   if (url_loader_)
diff --git a/components/optimization_guide/features.gni b/components/optimization_guide/features.gni
--- a/components/optimization_guide/features.gni
+++ b/components/optimization_guide/features.gni
@@ -10,9 +10,7 @@ if (is_android) {
 declare_args() {
   # This enables build with TFLite library.
   # Currently only available for Desktop and Android.
-  build_with_tflite_lib =
-      is_android || (is_win && target_cpu != "arm64") || is_linux || is_mac ||
-      is_chromeos || is_fuchsia || is_ios
+  build_with_tflite_lib = false
 
   # You can set the variable 'build_with_internal_optimization_guide' to true
   # even in a developer build in args.gn.  Setting this variable explicitly to true will
diff --git a/components/permissions/features.cc b/components/permissions/features.cc
--- a/components/permissions/features.cc
+++ b/components/permissions/features.cc
@@ -85,12 +85,12 @@ BASE_FEATURE(kPermissionChipRequestTypeSensitive,
 // When enabled, use the value of the `service_url` FeatureParam as the url
 // for the Web Permission Predictions Service.
 BASE_FEATURE(kPermissionPredictionServiceUseUrlOverride,
-             "kPermissionPredictionServiceUseUrlOverride",
-             base::FEATURE_DISABLED_BY_DEFAULT);
+             "kPermissionPredictionServiceUseUrlOverride",       // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);                 // in Bromite
 
 BASE_FEATURE(kPermissionOnDeviceNotificationPredictions,
-             "PermissionOnDeviceNotificationPredictions",
-             base::FEATURE_ENABLED_BY_DEFAULT);
+             "PermissionOnDeviceNotificationPredictions",        // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT);                 // in Bromite
 
 BASE_FEATURE(kPermissionOnDeviceGeolocationPredictions,
              "PermissionOnDeviceGeolocationPredictions",
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
@@ -214,12 +214,8 @@ BASE_FEATURE(kMixedContentAutoupgrade,
 // predictor may preconnect/prefetch to resources/origins to make the
 // future navigations faster.
 BASE_FEATURE(kNavigationPredictor,
-             "NavigationPredictor",
-#if BUILDFLAG(IS_ANDROID)
-             base::FEATURE_ENABLED_BY_DEFAULT
-#else
-             base::FEATURE_DISABLED_BY_DEFAULT
-#endif
+             "NavigationPredictor",                // disabled by default
+             base::FEATURE_DISABLED_BY_DEFAULT     // in Bromite
 );
 
 // Anchor Element Interaction
--
2.25.1
