diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/variations/service | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/variations/service')
7 files changed, 15 insertions, 106 deletions
diff --git a/chromium/components/variations/service/variations_field_trial_creator.cc b/chromium/components/variations/service/variations_field_trial_creator.cc index 131250bf138..386b8585eba 100644 --- a/chromium/components/variations/service/variations_field_trial_creator.cc +++ b/chromium/components/variations/service/variations_field_trial_creator.cc @@ -84,28 +84,6 @@ base::Time GetReferenceDateForExpiryChecks(PrefService* local_state) { return reference_date; } -// TODO(b/957197): Improve how we handle OS versions. -// Add os_version.h and os_version_<platform>.cc that handle retrieving and -// parsing OS versions. Then get rid of all the platform-dependent code here. -base::Version GetOSVersion() { - base::Version ret; - -#if defined(OS_WIN) - std::string win_version = base::SysInfo::OperatingSystemVersion(); - base::ReplaceSubstringsAfterOffset(&win_version, 0, " SP", "."); - ret = base::Version(win_version); - DCHECK(ret.IsValid()) << win_version; -#else - // Every other OS is supported by OperatingSystemVersionNumbers - int major, minor, build; - base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &build); - ret = base::Version(base::StringPrintf("%d.%d.%d", major, minor, build)); - DCHECK(ret.IsValid()); -#endif - - return ret; -} - // Just maps one set of enum values to another. Nothing to see here. Study::Channel ConvertProductChannelToStudyChannel( version_info::Channel product_channel) { @@ -257,7 +235,7 @@ VariationsFieldTrialCreator::GetClientFilterableStateForVersion( state->locale = application_locale_; state->reference_date = GetReferenceDateForExpiryChecks(local_state()); state->version = version; - state->os_version = GetOSVersion(); + state->os_version = ClientFilterableState::GetOSVersion(); state->channel = ConvertProductChannelToStudyChannel(client_->GetChannelForVariations()); state->form_factor = GetCurrentFormFactor(); @@ -463,7 +441,6 @@ bool VariationsFieldTrialCreator::SetupFieldTrials( const char* kEnableGpuBenchmarking, const char* kEnableFeatures, const char* kDisableFeatures, - const std::set<std::string>& unforceable_field_trials, const std::vector<std::string>& variation_ids, const std::vector<base::FeatureList::FeatureOverrideInfo>& extra_overrides, std::unique_ptr<const base::FieldTrial::EntropyProvider> @@ -497,8 +474,7 @@ bool VariationsFieldTrialCreator::SetupFieldTrials( // Create field trials without activating them, so that this behaves in a // consistent manner with field trials created from the server. bool result = base::FieldTrialList::CreateTrialsFromString( - command_line->GetSwitchValueASCII(::switches::kForceFieldTrials), - unforceable_field_trials); + command_line->GetSwitchValueASCII(::switches::kForceFieldTrials)); if (!result) { ExitWithMessage(base::StringPrintf("Invalid --%s list specified.", ::switches::kForceFieldTrials)); diff --git a/chromium/components/variations/service/variations_field_trial_creator.h b/chromium/components/variations/service/variations_field_trial_creator.h index f2ea1364945..a67ec4f4283 100644 --- a/chromium/components/variations/service/variations_field_trial_creator.h +++ b/chromium/components/variations/service/variations_field_trial_creator.h @@ -6,7 +6,6 @@ #define COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_FIELD_TRIAL_CREATOR_H_ #include <memory> -#include <set> #include <string> #include <unordered_map> #include <vector> @@ -62,8 +61,6 @@ class VariationsFieldTrialCreator { // setup completed successfully. // |kEnableGpuBenchmarking|, |kEnableFeatures|, |kDisableFeatures| are // feature controlling flags not directly accesible from variations. - // |unforcable_field_trials| contains the list of trials that can not be - // overridden. // |variation_ids| allows for forcing ids selected in chrome://flags and/or // specified using the command-line flag. // |low_entropy_provider| allows for field trial randomization. @@ -84,7 +81,6 @@ class VariationsFieldTrialCreator { const char* kEnableGpuBenchmarking, const char* kEnableFeatures, const char* kDisableFeatures, - const std::set<std::string>& unforceable_field_trials, const std::vector<std::string>& variation_ids, const std::vector<base::FeatureList::FeatureOverrideInfo>& extra_overrides, diff --git a/chromium/components/variations/service/variations_field_trial_creator_unittest.cc b/chromium/components/variations/service/variations_field_trial_creator_unittest.cc index 27fead4996a..6729a080f31 100644 --- a/chromium/components/variations/service/variations_field_trial_creator_unittest.cc +++ b/chromium/components/variations/service/variations_field_trial_creator_unittest.cc @@ -246,7 +246,7 @@ class TestVariationsFieldTrialCreator : public VariationsFieldTrialCreator { bool SetupFieldTrials() { TestPlatformFieldTrials platform_field_trials; return VariationsFieldTrialCreator::SetupFieldTrials( - "", "", "", std::set<std::string>(), std::vector<std::string>(), + "", "", "", std::vector<std::string>(), std::vector<base::FeatureList::FeatureOverrideInfo>(), nullptr, std::make_unique<base::FeatureList>(), &platform_field_trials, safe_seed_manager_); @@ -487,7 +487,7 @@ TEST_F(FieldTrialCreatorTest, SetupFieldTrials_LoadsCountryOnFirstRun) { // the interaction between these two classes is what's being tested. auto seed_store = std::make_unique<VariationsSeedStore>( &prefs_, std::move(initial_seed), - /*on_initial_seed_stored=*/base::DoNothing()); + /*signature_verification_enabled=*/false); VariationsFieldTrialCreator field_trial_creator( &prefs_, &variations_service_client, std::move(seed_store), UIStringOverrider()); @@ -497,7 +497,7 @@ TEST_F(FieldTrialCreatorTest, SetupFieldTrials_LoadsCountryOnFirstRun) { // |initial_seed| included the country code for India, this study should be // active. EXPECT_TRUE(field_trial_creator.SetupFieldTrials( - "", "", "", std::set<std::string>(), std::vector<std::string>(), + "", "", "", std::vector<std::string>(), std::vector<base::FeatureList::FeatureOverrideInfo>(), nullptr, std::make_unique<base::FeatureList>(), &platform_field_trials, &safe_seed_manager)); diff --git a/chromium/components/variations/service/variations_service.cc b/chromium/components/variations/service/variations_service.cc index b86adfc671e..3ca55f6bcba 100644 --- a/chromium/components/variations/service/variations_service.cc +++ b/chromium/components/variations/service/variations_service.cc @@ -267,14 +267,6 @@ std::unique_ptr<SeedResponse> MaybeImportFirstRunSeed( return nullptr; } -// Called when the VariationsSeedStore first stores a seed. -void OnInitialSeedStored() { -#if defined(OS_ANDROID) - android::MarkVariationsSeedAsStored(); - android::ClearJavaFirstRunPrefs(); -#endif -} - } // namespace #if defined(OS_CHROMEOS) @@ -377,7 +369,7 @@ VariationsService::VariationsService( std::make_unique<VariationsSeedStore>( local_state, MaybeImportFirstRunSeed(local_state), - base::BindOnce(&OnInitialSeedStored)), + /*signature_verification_enabled=*/true), ui_string_overrider), last_request_was_http_retry_(false) { DCHECK(client_); @@ -699,15 +691,13 @@ bool VariationsService::StoreSeed(const std::string& seed_data, const std::string& country_code, base::Time date_fetched, bool is_delta_compressed, - bool is_gzip_compressed, - bool fetched_insecurely) { + bool is_gzip_compressed) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); std::unique_ptr<VariationsSeed> seed(new VariationsSeed); if (!field_trial_creator_.seed_store()->StoreSeedData( seed_data, seed_signature, country_code, date_fetched, - is_delta_compressed, is_gzip_compressed, fetched_insecurely, - seed.get())) { + is_delta_compressed, is_gzip_compressed, seed.get())) { return false; } @@ -810,19 +800,12 @@ void VariationsService::OnSimpleLoaderCompleteOrRedirect( scoped_refptr<net::HttpResponseHeaders> headers; int response_code = -1; - // We use the final URL HTTPS/HTTP value to pass to StoreSeed, since - // signature validation should be forced on for any HTTP fetch, including - // redirects from HTTPS to HTTP. We default to false since we can't get this - // value (nor will it be used) in the redirect case. - bool final_url_was_https = false; // Variations seed fetches should not follow redirects, so if this request was // redirected, keep the default values for |net_error| and |is_success| (treat // it as a net::ERR_INVALID_REDIRECT), and the fetch will be cancelled when // pending_seed_request is reset. if (!was_redirect) { - final_url_was_https = - pending_seed_request_->GetFinalURL().SchemeIs(url::kHttpsScheme); const network::mojom::URLResponseHead* response_info = pending_seed_request_->ResponseInfo(); if (response_info && response_info->headers) { @@ -919,7 +902,7 @@ void VariationsService::OnSimpleLoaderCompleteOrRedirect( const std::string country_code = GetHeaderValue(headers.get(), "X-Country"); const bool store_success = StoreSeed(*response_body, signature, country_code, response_date, - is_delta_compressed, is_gzip_compressed, !final_url_was_https); + is_delta_compressed, is_gzip_compressed); if (!store_success && is_delta_compressed) { disable_deltas_for_next_request_ = true; // |request_scheduler_| will be null during unit tests. @@ -1016,15 +999,13 @@ bool VariationsService::SetupFieldTrials( const char* kEnableGpuBenchmarking, const char* kEnableFeatures, const char* kDisableFeatures, - const std::set<std::string>& unforceable_field_trials, const std::vector<std::string>& variation_ids, const std::vector<base::FeatureList::FeatureOverrideInfo>& extra_overrides, std::unique_ptr<base::FeatureList> feature_list, variations::PlatformFieldTrials* platform_field_trials) { return field_trial_creator_.SetupFieldTrials( - kEnableGpuBenchmarking, kEnableFeatures, kDisableFeatures, - unforceable_field_trials, variation_ids, extra_overrides, - CreateLowEntropyProvider(), std::move(feature_list), + kEnableGpuBenchmarking, kEnableFeatures, kDisableFeatures, variation_ids, + extra_overrides, CreateLowEntropyProvider(), std::move(feature_list), platform_field_trials, &safe_seed_manager_); } diff --git a/chromium/components/variations/service/variations_service.h b/chromium/components/variations/service/variations_service.h index f57077723ed..af9449648b1 100644 --- a/chromium/components/variations/service/variations_service.h +++ b/chromium/components/variations/service/variations_service.h @@ -6,7 +6,6 @@ #define COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ #include <memory> -#include <set> #include <string> #include <vector> @@ -194,7 +193,6 @@ class VariationsService const char* kEnableGpuBenchmarking, const char* kEnableFeatures, const char* kDisableFeatures, - const std::set<std::string>& unforceable_field_trials, const std::vector<std::string>& variation_ids, const std::vector<base::FeatureList::FeatureOverrideInfo>& extra_overrides, @@ -235,8 +233,7 @@ class VariationsService const std::string& country_code, base::Time date_fetched, bool is_delta_compressed, - bool is_gzip_compressed, - bool fetched_insecurely); + bool is_gzip_compressed); // Create an entropy provider based on low entropy. This is used to create // trials for studies that should only depend on low entropy, such as studies diff --git a/chromium/components/variations/service/variations_service_client.cc b/chromium/components/variations/service/variations_service_client.cc index bda4511f546..80a3df48668 100644 --- a/chromium/components/variations/service/variations_service_client.cc +++ b/chromium/components/variations/service/variations_service_client.cc @@ -5,6 +5,7 @@ #include "components/variations/service/variations_service_client.h" #include "base/command_line.h" +#include "base/logging.h" #include "components/variations/variations_switches.h" namespace variations { diff --git a/chromium/components/variations/service/variations_service_unittest.cc b/chromium/components/variations/service/variations_service_unittest.cc index 75cc1a21aa2..ecad3d15b14 100644 --- a/chromium/components/variations/service/variations_service_unittest.cc +++ b/chromium/components/variations/service/variations_service_unittest.cc @@ -136,8 +136,7 @@ class TestVariationsService : public VariationsService { fetch_attempted_(false), seed_stored_(false), delta_compressed_seed_(false), - gzip_compressed_seed_(false), - insecurely_fetched_seed_(false) { + gzip_compressed_seed_(false) { interception_url_ = GetVariationsServerURL(use_secure_url ? USE_HTTPS : USE_HTTP); set_variations_server_url(interception_url_); @@ -160,7 +159,6 @@ class TestVariationsService : public VariationsService { const std::string& stored_country() const { return stored_country_; } bool delta_compressed_seed() const { return delta_compressed_seed_; } bool gzip_compressed_seed() const { return gzip_compressed_seed_; } - bool insecurely_fetched_seed() const { return insecurely_fetched_seed_; } bool CallMaybeRetryOverHTTP() { return CallMaybeRetryOverHTTPForTesting(); } @@ -188,14 +186,12 @@ class TestVariationsService : public VariationsService { const std::string& country_code, base::Time date_fetched, bool is_delta_compressed, - bool is_gzip_compressed, - bool fetched_insecurely) override { + bool is_gzip_compressed) override { seed_stored_ = true; stored_seed_data_ = seed_data; stored_country_ = country_code; delta_compressed_seed_ = is_delta_compressed; gzip_compressed_seed_ = is_gzip_compressed; - insecurely_fetched_seed_ = fetched_insecurely; RecordSuccessfulFetch(); return true; } @@ -223,7 +219,6 @@ class TestVariationsService : public VariationsService { std::string stored_country_; bool delta_compressed_seed_; bool gzip_compressed_seed_; - bool insecurely_fetched_seed_; DISALLOW_COPY_AND_ASSIGN(TestVariationsService); }; @@ -944,43 +939,6 @@ TEST_F(VariationsServiceTest, FieldTrialCreatorInitializedCorrectly) { service.GetClientFilterableStateForVersionCalledForTesting(); } -TEST_F(VariationsServiceTest, InsecurelyFetchedSetWhenHTTP) { - std::string serialized_seed = SerializeSeed(CreateTestSeed()); - VariationsService::EnableFetchForTesting(); - TestVariationsService service( - std::make_unique<web_resource::TestRequestAllowedNotifier>( - &prefs_, network_tracker_), - &prefs_, GetMetricsStateManager(), false); - service.set_intercepts_fetch(false); - service.test_url_loader_factory()->AddResponse( - service.interception_url().spec(), serialized_seed); - base::HistogramTester histogram_tester; - // Note: We call DoFetchFromURL() here instead of DoActualFetch() since the - // latter doesn't pass true to |http_retry|. - service.DoFetchFromURL(service.interception_url(), true); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(service.insecurely_fetched_seed()); - histogram_tester.ExpectUniqueSample( - "Variations.SeedFetchResponseOrErrorCode.HTTP", net::HTTP_OK, 1); -} - -TEST_F(VariationsServiceTest, InsecurelyFetchedNotSetWhenHTTPS) { - std::string serialized_seed = SerializeSeed(CreateTestSeed()); - TestVariationsService service( - std::make_unique<web_resource::TestRequestAllowedNotifier>( - &prefs_, network_tracker_), - &prefs_, GetMetricsStateManager(), true); - VariationsService::EnableFetchForTesting(); - service.set_intercepts_fetch(false); - service.test_url_loader_factory()->AddResponse( - service.interception_url().spec(), serialized_seed); - base::HistogramTester histogram_tester; - service.DoActualFetch(); - EXPECT_FALSE(service.insecurely_fetched_seed()); - histogram_tester.ExpectUniqueSample("Variations.SeedFetchResponseOrErrorCode", - net::HTTP_OK, 1); -} - TEST_F(VariationsServiceTest, RetryOverHTTPIfURLisSet) { TestVariationsService service( std::make_unique<web_resource::TestRequestAllowedNotifier>( |