LeOSium_webview/LeOS/patches/Disable-fetching-of-all-fie...

382 lines
20 KiB
Diff

From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sun, 8 Jul 2018 18:16:34 +0200
Subject: Disable fetching of all field trials
Disable seed-based field trials.
Disable reporting of Omnibox suggestions header.
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
android_webview/common/aw_features.cc | 4 +--
android_webview/nonembedded/BUILD.gn | 2 --
.../services/VariationsSeedServer.java | 2 --
.../metrics/chrome_browser_sampling_trials.cc | 4 +++
.../net/system_network_context_manager.cc | 1 -
components/ukm/ukm_recorder_impl.cc | 3 ++
.../firstrun/VariationsSeedBridge.java | 2 +-
.../firstrun/VariationsSeedFetcher.java | 32 +++----------------
components/variations/net/BUILD.gn | 2 --
.../variations/net/omnibox_http_headers.cc | 4 +--
.../variations/net/variations_http_headers.cc | 3 ++
.../variations_field_trial_creator_base.cc | 8 ++---
.../variations/service/variations_service.cc | 15 ++-------
.../browser/loader/url_loader_throttles.cc | 7 ----
.../origin_trials/origin_trials_utils.cc | 2 +-
content/public/common/content_features.cc | 4 +--
.../variations_render_thread_observer.cc | 9 ------
.../renderer/core/loader/document_loader.cc | 7 ----
18 files changed, 29 insertions(+), 82 deletions(-)
diff --git a/android_webview/common/aw_features.cc b/android_webview/common/aw_features.cc
--- a/android_webview/common/aw_features.cc
+++ b/android_webview/common/aw_features.cc
@@ -106,8 +106,8 @@ BASE_FEATURE(kWebViewMetricsFiltering,
// Field trial feature for controlling support of Origin Trials on WebView.
BASE_FEATURE(kWebViewOriginTrials,
- "WebViewOriginTrials",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ "WebViewOriginTrials", // disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // by default
// Whether to record size of the embedding app's data directory to the UMA
// histogram Android.WebView.AppDataDirectorySize.
diff --git a/android_webview/nonembedded/BUILD.gn b/android_webview/nonembedded/BUILD.gn
--- a/android_webview/nonembedded/BUILD.gn
+++ b/android_webview/nonembedded/BUILD.gn
@@ -104,7 +104,6 @@ android_library("services_java") {
sources = [
"java/src/org/chromium/android_webview/services/AwMinidumpUploadJobService.java",
"java/src/org/chromium/android_webview/services/AwMinidumpUploaderDelegate.java",
- "java/src/org/chromium/android_webview/services/AwVariationsSeedFetcher.java",
"java/src/org/chromium/android_webview/services/ComponentUpdaterResetSafeModeAction.java",
"java/src/org/chromium/android_webview/services/ComponentUpdaterSafeModeUtils.java",
"java/src/org/chromium/android_webview/services/ComponentsProviderPathUtil.java",
@@ -123,7 +122,6 @@ android_library("services_java") {
"java/src/org/chromium/android_webview/services/SafeModeService.java",
"java/src/org/chromium/android_webview/services/SafeModeVariationsSeedContentProvider.java",
"java/src/org/chromium/android_webview/services/StartupFeatureMetadataHolder.java",
- "java/src/org/chromium/android_webview/services/VariationsSeedHolder.java",
"java/src/org/chromium/android_webview/services/VariationsSeedServer.java",
]
deps = [
diff --git a/android_webview/nonembedded/java/src/org/chromium/android_webview/services/VariationsSeedServer.java b/android_webview/nonembedded/java/src/org/chromium/android_webview/services/VariationsSeedServer.java
--- a/android_webview/nonembedded/java/src/org/chromium/android_webview/services/VariationsSeedServer.java
+++ b/android_webview/nonembedded/java/src/org/chromium/android_webview/services/VariationsSeedServer.java
@@ -30,8 +30,6 @@ public class VariationsSeedServer extends Service {
@Override
public void getSeed(ParcelFileDescriptor newSeedFile, long oldSeedDate,
IVariationsSeedServerCallback callback) {
- maybeReportMetrics(callback);
- VariationsSeedHolder.getInstance().writeSeedIfNewer(newSeedFile, oldSeedDate);
}
};
diff --git a/chrome/browser/metrics/chrome_browser_sampling_trials.cc b/chrome/browser/metrics/chrome_browser_sampling_trials.cc
--- a/chrome/browser/metrics/chrome_browser_sampling_trials.cc
+++ b/chrome/browser/metrics/chrome_browser_sampling_trials.cc
@@ -55,6 +55,8 @@ void CreateFallbackSamplingTrial(
const int sampled_in_rate_per_mille,
const bool starts_active,
base::FeatureList* feature_list) {
+ if ((true))
+ return;
scoped_refptr<base::FieldTrial> trial(
base::FieldTrialList::FactoryGetFieldTrial(
trial_name, /*total_probability=*/1000, "Default", entropy_provider));
@@ -98,6 +100,8 @@ void CreateFallbackUkmSamplingTrial(
const base::FieldTrial::EntropyProvider& entropy_provider,
bool is_stable_channel,
base::FeatureList* feature_list) {
+ if ((true))
+ return;
static const char kSampledGroup_Stable[] = "Sampled_NoSeed_Stable";
static const char kSampledGroup_Other[] = "Sampled_NoSeed_Other";
const char* sampled_group = kSampledGroup_Other;
diff --git a/chrome/browser/net/system_network_context_manager.cc b/chrome/browser/net/system_network_context_manager.cc
--- a/chrome/browser/net/system_network_context_manager.cc
+++ b/chrome/browser/net/system_network_context_manager.cc
@@ -818,7 +818,6 @@ void SystemNetworkContextManager::AddSSLConfigToNetworkContextParams(
void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(
network::mojom::NetworkContextParams* network_context_params) {
- variations::UpdateCorsExemptHeaderForVariations(network_context_params);
network_context_params->enable_brotli = true;
diff --git a/components/ukm/ukm_recorder_impl.cc b/components/ukm/ukm_recorder_impl.cc
--- a/components/ukm/ukm_recorder_impl.cc
+++ b/components/ukm/ukm_recorder_impl.cc
@@ -166,6 +166,9 @@ bool HasUnknownMetrics(const builders::DecodeMap& decode_map,
UkmRecorderImpl::UkmRecorderImpl()
: sampling_seed_(static_cast<uint32_t>(base::RandUint64())) {
+ if ((true))
+ return;
+
max_kept_sources_ =
static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
kUkmFeature, "MaxKeptSources", max_kept_sources_));
diff --git a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
--- a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
+++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
@@ -51,7 +51,7 @@ public class VariationsSeedBridge {
}
@CalledByNative
- private static void clearFirstRunPrefs() {
+ public static void clearFirstRunPrefs() {
ContextUtils.getAppSharedPreferences()
.edit()
.remove(VARIATIONS_FIRST_RUN_SEED_BASE64)
diff --git a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
--- a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
+++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
@@ -453,35 +453,13 @@ public class VariationsSeedFetcher {
*/
public void fetchSeed(String restrictMode, String milestone, String channel) {
assert !ThreadUtils.runningOnUiThread();
- // Prevent multiple simultaneous fetches
- synchronized (sLock) {
- SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
- // Early return if an attempt has already been made to fetch the seed, even if it
- // failed. Only attempt to get the initial Java seed once, since a failure probably
- // indicates a network problem that is unlikely to be resolved by a second attempt.
- // Note that VariationsSeedBridge.hasNativePref() is a pure Java function, reading an
- // Android preference that is set when the seed is fetched by the native code.
- if (prefs.getBoolean(VARIATIONS_INITIALIZED_PREF, false)
- || VariationsSeedBridge.hasNativePref()) {
- return;
- }
+ synchronized (sLock) {
+ VariationsSeedBridge.clearFirstRunPrefs();
- SeedFetchParameters params =
- SeedFetchParameters.Builder.newBuilder()
- .setPlatform(VariationsSeedFetcher.VariationsPlatform.ANDROID)
- .setRestrictMode(null)
- .setMilestone(milestone)
- .setChannel(channel)
- .build();
- SeedFetchInfo fetchInfo = downloadContent(params, null);
- if (fetchInfo.seedInfo != null) {
- SeedInfo info = fetchInfo.seedInfo;
- VariationsSeedBridge.setVariationsFirstRunSeed(info.seedData, info.signature,
- info.country, info.date, info.isGzipCompressed);
- }
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
// VARIATIONS_INITIALIZED_PREF should still be set to true when exceptions occur
prefs.edit().putBoolean(VARIATIONS_INITIALIZED_PREF, true).apply();
- }
+ }
}
private void recordFetchResultOrCode(int resultOrCode) {
@@ -525,7 +503,7 @@ public class VariationsSeedFetcher {
* @param curSeedInfo optional currently saved seed info to set the `If-None-Match` header.
* @return the object holds the request result and seed data with its related header fields.
*/
- public SeedFetchInfo downloadContent(SeedFetchParameters params, SeedInfo currInfo) {
+ private SeedFetchInfo downloadContent(SeedFetchParameters params, SeedInfo currInfo) {
SeedFetchInfo fetchInfo = new SeedFetchInfo();
HttpURLConnection connection = null;
try {
diff --git a/components/variations/net/BUILD.gn b/components/variations/net/BUILD.gn
--- a/components/variations/net/BUILD.gn
+++ b/components/variations/net/BUILD.gn
@@ -34,8 +34,6 @@ static_library("net") {
if (use_blink) {
sources += [
- "variations_url_loader_throttle.cc",
- "variations_url_loader_throttle.h",
]
deps += [
"//components/variations:variations_mojom",
diff --git a/components/variations/net/omnibox_http_headers.cc b/components/variations/net/omnibox_http_headers.cc
--- a/components/variations/net/omnibox_http_headers.cc
+++ b/components/variations/net/omnibox_http_headers.cc
@@ -21,8 +21,8 @@ const char kOmniboxOnDeviceSuggestionsHeader[] =
// Whether to enable reporting the header. Included as a quick escape hatch in
// case of crashes.
BASE_FEATURE(kReportOmniboxOnDeviceSuggestionsHeader,
- "ReportOmniboxOnDeviceSuggestionsHeader",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ "ReportOmniboxOnDeviceSuggestionsHeader", // disabled by default
+ base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite
std::string GetHeaderValue() {
const std::string group =
diff --git a/components/variations/net/variations_http_headers.cc b/components/variations/net/variations_http_headers.cc
--- a/components/variations/net/variations_http_headers.cc
+++ b/components/variations/net/variations_http_headers.cc
@@ -250,6 +250,9 @@ class VariationsHeaderHelper {
VariationsHeaderHelper& operator=(const VariationsHeaderHelper&) = delete;
bool AppendHeaderIfNeeded(const GURL& url, InIncognito incognito) {
+ if((true))
+ return false;
+
AppendOmniboxOnDeviceSuggestionsHeaderIfNeeded(url, resource_request_);
// Note the criteria for attaching client experiment headers:
diff --git a/components/variations/service/variations_field_trial_creator_base.cc b/components/variations/service/variations_field_trial_creator_base.cc
--- a/components/variations/service/variations_field_trial_creator_base.cc
+++ b/components/variations/service/variations_field_trial_creator_base.cc
@@ -118,6 +118,7 @@ Study::CpuArchitecture GetCurrentCpuArchitecture() {
}
#if BUILDFLAG(FIELDTRIAL_TESTING_ENABLED)
+#error FIELDTRIAL_TESTING_ENABLED should be disabled.
// Determines whether the field trial testing config defined in
// testing/variations/fieldtrial_testing_config.json should be applied. If the
// "disable_fieldtrial_testing_config" GN flag is set to true, then the testing
@@ -302,11 +303,6 @@ bool VariationsFieldTrialCreatorBase::SetUpFieldTrials(
safe_seed_manager);
}
- platform_field_trials->SetUpClientSideFieldTrials(
- used_seed, *entropy_providers, feature_list.get());
-
- platform_field_trials->RegisterFeatureOverrides(feature_list.get());
-
base::FeatureList::SetInstance(std::move(feature_list));
// For testing Variations Safe Mode, maybe crash here.
@@ -585,6 +581,7 @@ bool VariationsFieldTrialCreatorBase::CreateTrialsFromSeed(
const EntropyProviders& entropy_providers,
base::FeatureList* feature_list,
SafeSeedManagerInterface* safe_seed_manager) {
+ if ((true)) return false;
// This histogram name uses "VariationsFieldTrialCreator" rather than
// "VariationsFieldTrialCreatorBase" for consistency with historical data
TRACE_EVENT0("startup", "VariationsFieldTrialCreator::CreateTrialsFromSeed");
@@ -678,6 +675,7 @@ bool VariationsFieldTrialCreatorBase::CreateTrialsFromSeed(
void VariationsFieldTrialCreatorBase::LoadSeedFromJsonFile(
const base::FilePath& json_seed_path) {
+ if ((true)) return;
VLOG(1) << "Loading seed from JSON file:" << json_seed_path;
JSONFileValueDeserializer file_deserializer(json_seed_path);
int error_code;
diff --git a/components/variations/service/variations_service.cc b/components/variations/service/variations_service.cc
--- a/components/variations/service/variations_service.cc
+++ b/components/variations/service/variations_service.cc
@@ -220,17 +220,8 @@ bool GetInstanceManipulations(const net::HttpResponseHeaders* headers,
// Variations seed fetching is only enabled in official Chrome builds, if a URL
// is specified on the command line, and for testing.
bool IsFetchingEnabled() {
-#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
- if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kVariationsServerURL) &&
- !g_should_fetch_for_testing) {
- DVLOG(1)
- << "Not performing repeated fetching in unofficial build without --"
- << switches::kVariationsServerURL << " specified.";
- return false;
- }
-#endif
- return true;
+ // set to false even if not used on Android
+ return false;
}
// Returns the already downloaded first run seed, and clear the seed from the
@@ -599,7 +590,7 @@ bool VariationsService::DoFetchFromURL(const GURL& url, bool is_http_retry) {
// debugger or if the machine was suspended) and OnURLFetchComplete() hasn't
// had a chance to run yet from the previous request. In this case, don't
// start a new request and just let the previous one finish.
- if (pending_seed_request_)
+ if ((true) || pending_seed_request_)
return false;
last_request_was_http_retry_ = is_http_retry;
diff --git a/content/browser/loader/url_loader_throttles.cc b/content/browser/loader/url_loader_throttles.cc
--- a/content/browser/loader/url_loader_throttles.cc
+++ b/content/browser/loader/url_loader_throttles.cc
@@ -49,8 +49,6 @@ CreateContentBrowserURLLoaderThrottles(
// TODO(crbug.com/1094303): Consider whether we want to use the WebContents to
// determine the value for variations::Owner. Alternatively, this is the
// browser side, and we might be fine with Owner::kUnknown.
- variations::VariationsURLLoaderThrottle::AppendThrottleIfNeeded(
- browser_context->GetVariationsClient(), &throttles);
ClientHintsControllerDelegate* client_hint_delegate =
browser_context->GetClientHintsControllerDelegate();
@@ -128,11 +126,6 @@ CreateContentBrowserURLLoaderThrottlesForKeepAlive(
GetContentClient()->browser()->CreateURLLoaderThrottlesForKeepAlive(
request, browser_context, wc_getter, frame_tree_node_id);
variations::OmniboxURLLoaderThrottle::AppendThrottleIfNeeded(&throttles);
- // TODO(crbug.com/1094303): Consider whether we want to use the WebContents to
- // determine the value for variations::Owner. Alternatively, this is the
- // browser side, and we might be fine with Owner::kUnknown.
- variations::VariationsURLLoaderThrottle::AppendThrottleIfNeeded(
- browser_context->GetVariationsClient(), &throttles);
return throttles;
}
diff --git a/content/browser/origin_trials/origin_trials_utils.cc b/content/browser/origin_trials/origin_trials_utils.cc
--- a/content/browser/origin_trials/origin_trials_utils.cc
+++ b/content/browser/origin_trials/origin_trials_utils.cc
@@ -14,7 +14,7 @@ namespace {
std::vector<std::string> GetHeaderValues(
base::StringPiece header_name,
const net::HttpResponseHeaders* headers) {
- if (!headers) {
+ if ((true)) {
return {};
}
size_t iter = 0;
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
@@ -630,8 +630,8 @@ BASE_FEATURE(kPepperCrossOriginRedirectRestriction,
// things before receiving the response, for instance it can affect the next
// navigation's network request.
BASE_FEATURE(kPersistentOriginTrials,
- "PersistentOriginTrials",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ "PersistentOriginTrials", // always disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // in bromite
// If enabled, then an updated prefetch request limit policy will be used that
// separates eager and non-eager prefetches, and allows for evictions.
diff --git a/content/renderer/variations_render_thread_observer.cc b/content/renderer/variations_render_thread_observer.cc
--- a/content/renderer/variations_render_thread_observer.cc
+++ b/content/renderer/variations_render_thread_observer.cc
@@ -56,15 +56,6 @@ void VariationsRenderThreadObserver::AppendThrottleIfNeeded(
const url::Origin& top_frame_origin,
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>* throttles) {
variations::OmniboxURLLoaderThrottle::AppendThrottleIfNeeded(throttles);
-
- variations::mojom::VariationsHeadersPtr variations_headers =
- GetVariationsData()->GetVariationsHeaders();
-
- if (!variations_headers.is_null()) {
- throttles->push_back(
- std::make_unique<variations::VariationsURLLoaderThrottle>(
- std::move(variations_headers), top_frame_origin));
- }
}
void VariationsRenderThreadObserver::RegisterMojoInterfaces(
diff --git a/third_party/blink/renderer/core/loader/document_loader.cc b/third_party/blink/renderer/core/loader/document_loader.cc
--- a/third_party/blink/renderer/core/loader/document_loader.cc
+++ b/third_party/blink/renderer/core/loader/document_loader.cc
@@ -187,13 +187,6 @@ Vector<OriginTrialFeature> CopyInitiatorOriginTrials(
WebVector<int> CopyInitiatorOriginTrials(
const Vector<OriginTrialFeature>& initiator_origin_trial_features) {
WebVector<int> result;
- for (auto feature : initiator_origin_trial_features) {
- // Convert from OriginTrialFeature to int. These values are passed between
- // blink navigations. OriginTrialFeature isn't visible outside of blink (and
- // doesn't need to be) so the values are transferred outside of blink as
- // ints and casted to OriginTrialFeature once being processed in blink.
- result.emplace_back(static_cast<int>(feature));
- }
return result;
}
--
2.25.1