summaryrefslogtreecommitdiff
path: root/chromium/components/variations
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-06 12:48:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:33:43 +0000
commit7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (patch)
treefa14ba0ca8d2683ba2efdabd246dc9b18a1229c6 /chromium/components/variations
parent79b4f909db1049fca459c07cca55af56a9b54fe3 (diff)
downloadqtwebengine-chromium-7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3.tar.gz
BASELINE: Update Chromium to 84.0.4147.141
Change-Id: Ib85eb4cfa1cbe2b2b81e5022c8cad5c493969535 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/variations')
-rw-r--r--chromium/components/variations/android/BUILD.gn5
-rw-r--r--chromium/components/variations/android/java/src/org/chromium/components/variations/VariationsAssociatedData.java13
-rw-r--r--chromium/components/variations/android/junit/src/org/chromium/components/variations/firstrun/VariationsSeedFetcherTest.java11
-rw-r--r--chromium/components/variations/android/variations_associated_data_android.cc7
-rw-r--r--chromium/components/variations/entropy_provider.cc2
-rw-r--r--chromium/components/variations/net/omnibox_url_loader_throttle.cc3
-rw-r--r--chromium/components/variations/net/omnibox_url_loader_throttle.h12
-rw-r--r--chromium/components/variations/net/variations_http_headers.cc4
-rw-r--r--chromium/components/variations/net/variations_http_headers.h16
-rw-r--r--chromium/components/variations/net/variations_url_loader_throttle.cc3
-rw-r--r--chromium/components/variations/net/variations_url_loader_throttle.h12
-rw-r--r--chromium/components/variations/proto/study.proto9
-rw-r--r--chromium/components/variations/service/ui_string_overrider.cc2
-rw-r--r--chromium/components/variations/service/variations_service_unittest.cc28
-rw-r--r--chromium/components/variations/variations_associated_data.cc2
-rw-r--r--chromium/components/variations/variations_associated_data.h3
-rw-r--r--chromium/components/variations/variations_http_header_provider.cc20
-rw-r--r--chromium/components/variations/variations_http_header_provider.h19
-rw-r--r--chromium/components/variations/variations_http_header_provider_unittest.cc20
-rw-r--r--chromium/components/variations/variations_murmur_hash.cc4
-rw-r--r--chromium/components/variations/variations_seed_processor.cc11
21 files changed, 160 insertions, 46 deletions
diff --git a/chromium/components/variations/android/BUILD.gn b/chromium/components/variations/android/BUILD.gn
index ae5831c9098..287ad61216b 100644
--- a/chromium/components/variations/android/BUILD.gn
+++ b/chromium/components/variations/android/BUILD.gn
@@ -18,7 +18,10 @@ android_library("variations_java") {
]
}
-junit_binary("components_variations_junit_tests") {
+java_library("components_variations_junit_tests") {
+ # Platform checks are broken for Robolectric. See https://crbug.com/1071638.
+ bypass_platform_checks = true
+ testonly = true
sources = [ "junit/src/org/chromium/components/variations/firstrun/VariationsSeedFetcherTest.java" ]
deps = [
":variations_java",
diff --git a/chromium/components/variations/android/java/src/org/chromium/components/variations/VariationsAssociatedData.java b/chromium/components/variations/android/java/src/org/chromium/components/variations/VariationsAssociatedData.java
index 914e84a5190..76343e2123c 100644
--- a/chromium/components/variations/android/java/src/org/chromium/components/variations/VariationsAssociatedData.java
+++ b/chromium/components/variations/android/java/src/org/chromium/components/variations/VariationsAssociatedData.java
@@ -34,9 +34,22 @@ public final class VariationsAssociatedData {
return map;
}
+ /**
+ * Returns the list of Google App variations from active finch field trials.
+ * @return A space separated list of ids with leading and trailing space.
+ * For example, " 123 456 ".
+ * IMPORTANT: This string is only approved for integrations with the Android
+ * Google App and must receive a privacy review before extending to other apps.
+ */
+ public static String getGoogleAppVariations() {
+ String variations = VariationsAssociatedDataJni.get().getGoogleAppVariations();
+ return variations;
+ }
+
@NativeMethods
interface Natives {
String getVariationParamValue(String trialName, String paramName);
String getFeedbackVariations();
+ String getGoogleAppVariations();
}
}
diff --git a/chromium/components/variations/android/junit/src/org/chromium/components/variations/firstrun/VariationsSeedFetcherTest.java b/chromium/components/variations/android/junit/src/org/chromium/components/variations/firstrun/VariationsSeedFetcherTest.java
index 400906870ed..b230d42d772 100644
--- a/chromium/components/variations/android/junit/src/org/chromium/components/variations/firstrun/VariationsSeedFetcherTest.java
+++ b/chromium/components/variations/android/junit/src/org/chromium/components/variations/firstrun/VariationsSeedFetcherTest.java
@@ -19,6 +19,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.SharedPreferences;
+import android.os.Handler;
import android.os.Looper;
import android.util.Base64;
@@ -47,6 +48,7 @@ public class VariationsSeedFetcherTest {
private HttpURLConnection mConnection;
private VariationsSeedFetcher mFetcher;
private SharedPreferences mPrefs;
+ private Looper mOrigLooper;
private static final String sRestrict = "restricted";
private static final String sMilestone = "64";
@@ -56,6 +58,10 @@ public class VariationsSeedFetcherTest {
public void setUp() throws IOException {
// Pretend we are not on the UI thread, since the class we are testing is supposed to run
// only on a background thread.
+ Handler handler = ThreadUtils.getUiThreadHandler();
+ if (handler != null) mOrigLooper = handler.getLooper();
+ ThreadUtils.setUiThread(null);
+ ThreadUtils.setWillOverrideUiThread(true);
ThreadUtils.setUiThread(mock(Looper.class));
mFetcher = spy(VariationsSeedFetcher.get());
mConnection = mock(HttpURLConnection.class);
@@ -69,6 +75,11 @@ public class VariationsSeedFetcherTest {
@After
public void tearDown() {
ThreadUtils.setUiThread(null);
+ if (mOrigLooper != null) {
+ ThreadUtils.setUiThread(mOrigLooper);
+ mOrigLooper = null;
+ }
+ ThreadUtils.setWillOverrideUiThread(false);
}
/**
diff --git a/chromium/components/variations/android/variations_associated_data_android.cc b/chromium/components/variations/android/variations_associated_data_android.cc
index b4d14395db5..6b12a30644b 100644
--- a/chromium/components/variations/android/variations_associated_data_android.cc
+++ b/chromium/components/variations/android/variations_associated_data_android.cc
@@ -35,5 +35,12 @@ ScopedJavaLocalRef<jstring> JNI_VariationsAssociatedData_GetFeedbackVariations(
return ConvertUTF8ToJavaString(env, values);
}
+ScopedJavaLocalRef<jstring> JNI_VariationsAssociatedData_GetGoogleAppVariations(
+ JNIEnv* env) {
+ const std::string values = VariationsHttpHeaderProvider::GetInstance()
+ ->GetGoogleAppVariationsString();
+ return ConvertUTF8ToJavaString(env, values);
+}
+
} // namespace android
} // namespace variations
diff --git a/chromium/components/variations/entropy_provider.cc b/chromium/components/variations/entropy_provider.cc
index 23e040d02df..e4acb9b4ba5 100644
--- a/chromium/components/variations/entropy_provider.cc
+++ b/chromium/components/variations/entropy_provider.cc
@@ -8,8 +8,8 @@
#include <limits>
#include <vector>
+#include "base/check_op.h"
#include "base/hash/sha1.h"
-#include "base/logging.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/sys_byteorder.h"
diff --git a/chromium/components/variations/net/omnibox_url_loader_throttle.cc b/chromium/components/variations/net/omnibox_url_loader_throttle.cc
index 6acf2aa5e2b..b623955e9b3 100644
--- a/chromium/components/variations/net/omnibox_url_loader_throttle.cc
+++ b/chromium/components/variations/net/omnibox_url_loader_throttle.cc
@@ -41,7 +41,8 @@ void OmniboxURLLoaderThrottle::WillRedirectRequest(
const network::mojom::URLResponseHead& response_head,
bool* defer,
std::vector<std::string>* to_be_removed_headers,
- net::HttpRequestHeaders* modified_headers) {
+ net::HttpRequestHeaders* modified_headers,
+ net::HttpRequestHeaders* modified_cors_exempt_headers) {
// Note: No need to check the kReportOmniboxOnDeviceSuggestionsHeader feature
// state here, as this class is only instantiated when the feature is enabled.
if (!ShouldAppendHeader(redirect_info->new_url))
diff --git a/chromium/components/variations/net/omnibox_url_loader_throttle.h b/chromium/components/variations/net/omnibox_url_loader_throttle.h
index 0b6334d0cdc..a1a976b66f4 100644
--- a/chromium/components/variations/net/omnibox_url_loader_throttle.h
+++ b/chromium/components/variations/net/omnibox_url_loader_throttle.h
@@ -40,11 +40,13 @@ class COMPONENT_EXPORT(OMNIBOX_HTTP_HEADERS) OmniboxURLLoaderThrottle
void DetachFromCurrentSequence() override;
void WillStartRequest(network::ResourceRequest* request,
bool* defer) override;
- void WillRedirectRequest(net::RedirectInfo* redirect_info,
- const network::mojom::URLResponseHead& response_head,
- bool* defer,
- std::vector<std::string>* to_be_removed_headers,
- net::HttpRequestHeaders* modified_headers) override;
+ void WillRedirectRequest(
+ net::RedirectInfo* redirect_info,
+ const network::mojom::URLResponseHead& response_head,
+ bool* defer,
+ std::vector<std::string>* to_be_removed_headers,
+ net::HttpRequestHeaders* modified_headers,
+ net::HttpRequestHeaders* modified_cors_exempt_headers) override;
};
} // namespace variations
diff --git a/chromium/components/variations/net/variations_http_headers.cc b/chromium/components/variations/net/variations_http_headers.cc
index 4dac191db47..c4f4f56d837 100644
--- a/chromium/components/variations/net/variations_http_headers.cc
+++ b/chromium/components/variations/net/variations_http_headers.cc
@@ -27,12 +27,12 @@
namespace variations {
-namespace {
-
// The name string for the header for variations information.
// Note that prior to M33 this header was named X-Chrome-Variations.
const char kClientDataHeader[] = "X-Client-Data";
+namespace {
+
// The result of checking if a URL should have variations headers appended.
// This enum is used to record UMA histogram values, and should not be
// reordered.
diff --git a/chromium/components/variations/net/variations_http_headers.h b/chromium/components/variations/net/variations_http_headers.h
index cc2ae5926d0..29506e0f81f 100644
--- a/chromium/components/variations/net/variations_http_headers.h
+++ b/chromium/components/variations/net/variations_http_headers.h
@@ -31,12 +31,16 @@ enum class InIncognito { kNo, kYes };
enum class SignedIn { kNo, kYes };
+extern const char kClientDataHeader[];
+
// Adds Chrome experiment and metrics state as custom headers to |request|.
// The content of the headers will depend on |incognito| and |signed_in|
// parameters. It is fine to pass SignedIn::NO if the state is not known to the
// caller. This will prevent addition of ids of type
// GOOGLE_WEB_PROPERTIES_SIGNED_IN, which is not the case for any ids that come
-// from the variations server. These headers are never transmitted to non-Google
+// from the variations server. The |incognito| param must be the actual
+// Incognito state. It is not correct to pass InIncognito:kNo if the state is
+// unknown. These headers are never transmitted to non-Google
// web sites, which is checked based on the destination |url|.
// Returns true if custom headers are added. Returns false otherwise.
bool AppendVariationsHeader(const GURL& url,
@@ -66,7 +70,10 @@ void RemoveVariationsHeaderIfNeeded(
// Creates a SimpleURLLoader that will include the variations header for
// requests to Google and ensures they're removed if a redirect to a non-Google
-// URL occurs.
+// URL occurs. The content of the headers will depend on |incognito| and
+// |signed_in| parameters. It is fine to pass SignedIn::NO if the state is not
+// known to the caller. The |incognito| param must be the actual Incognito
+// state. It is not correct to pass InIncognito:kNo if the state is unknown.
std::unique_ptr<network::SimpleURLLoader>
CreateSimpleURLLoaderWithVariationsHeader(
std::unique_ptr<network::ResourceRequest> request,
@@ -76,7 +83,10 @@ CreateSimpleURLLoaderWithVariationsHeader(
// Creates a SimpleURLLoader that will include the variations header for
// requests to Google when the signed-in state is unknown and ensures they're
-// removed if a redirect to a non-Google URL occurs.
+// removed if a redirect to a non-Google URL occurs. The content of the headers
+// will depend on |incognito| parameters. The |incognito| param must be the
+// actual Incognito state. It is not correct to pass InIncognito:kNo if the
+// state is unknown.
std::unique_ptr<network::SimpleURLLoader>
CreateSimpleURLLoaderWithVariationsHeaderUnknownSignedIn(
std::unique_ptr<network::ResourceRequest> request,
diff --git a/chromium/components/variations/net/variations_url_loader_throttle.cc b/chromium/components/variations/net/variations_url_loader_throttle.cc
index 046c670ba8d..2f1aed783c6 100644
--- a/chromium/components/variations/net/variations_url_loader_throttle.cc
+++ b/chromium/components/variations/net/variations_url_loader_throttle.cc
@@ -45,7 +45,8 @@ void VariationsURLLoaderThrottle::WillRedirectRequest(
const network::mojom::URLResponseHead& response_head,
bool* defer,
std::vector<std::string>* to_be_removed_headers,
- net::HttpRequestHeaders* modified_headers) {
+ net::HttpRequestHeaders* modified_headers,
+ net::HttpRequestHeaders* modified_cors_exempt_headers) {
variations::RemoveVariationsHeaderIfNeeded(*redirect_info, response_head,
to_be_removed_headers);
}
diff --git a/chromium/components/variations/net/variations_url_loader_throttle.h b/chromium/components/variations/net/variations_url_loader_throttle.h
index 38ac5e88d23..c15d2c9fb44 100644
--- a/chromium/components/variations/net/variations_url_loader_throttle.h
+++ b/chromium/components/variations/net/variations_url_loader_throttle.h
@@ -44,11 +44,13 @@ class VariationsURLLoaderThrottle
void DetachFromCurrentSequence() override;
void WillStartRequest(network::ResourceRequest* request,
bool* defer) override;
- void WillRedirectRequest(net::RedirectInfo* redirect_info,
- const network::mojom::URLResponseHead& response_head,
- bool* defer,
- std::vector<std::string>* to_be_removed_headers,
- net::HttpRequestHeaders* modified_headers) override;
+ void WillRedirectRequest(
+ net::RedirectInfo* redirect_info,
+ const network::mojom::URLResponseHead& response_head,
+ bool* defer,
+ std::vector<std::string>* to_be_removed_headers,
+ net::HttpRequestHeaders* modified_headers,
+ net::HttpRequestHeaders* modified_cors_exempt_headers) override;
const std::string variation_ids_header_;
};
diff --git a/chromium/components/variations/proto/study.proto b/chromium/components/variations/proto/study.proto
index fd106d68fe9..0e891106904 100644
--- a/chromium/components/variations/proto/study.proto
+++ b/chromium/components/variations/proto/study.proto
@@ -46,7 +46,7 @@ message Study {
// An experiment within the study.
//
- // Next tag: 14
+ // Next tag: 16
message Experiment {
// A named parameter value for this experiment.
//
@@ -78,6 +78,13 @@ message Study {
// Optional id used to uniquely identify this experiment for Chrome Sync.
optional uint64 chrome_sync_experiment_id = 10;
+ // Optional id used to uniquely identify this experiment when activating
+ // integrations with the Android Google App.
+ // IMPORTANT: This field is only approved for integrations with the Android
+ // Google App and must receive a privacy review before extending to other
+ // apps.
+ optional uint64 google_app_experiment_id = 15;
+
// Specifies the feature association parameters for this experiment group.
//
// Next tag: 5
diff --git a/chromium/components/variations/service/ui_string_overrider.cc b/chromium/components/variations/service/ui_string_overrider.cc
index 36f7d4b3f42..ce6470ae74a 100644
--- a/chromium/components/variations/service/ui_string_overrider.cc
+++ b/chromium/components/variations/service/ui_string_overrider.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/base/resource/resource_bundle.h"
namespace variations {
diff --git a/chromium/components/variations/service/variations_service_unittest.cc b/chromium/components/variations/service/variations_service_unittest.cc
index 107879e8258..75cc1a21aa2 100644
--- a/chromium/components/variations/service/variations_service_unittest.cc
+++ b/chromium/components/variations/service/variations_service_unittest.cc
@@ -28,7 +28,7 @@
#include "components/metrics/client_info.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_state_manager.h"
-#include "components/metrics/test_enabled_state_provider.h"
+#include "components/metrics/test/test_enabled_state_provider.h"
#include "components/prefs/testing_pref_service.h"
#include "components/variations/pref_names.h"
#include "components/variations/proto/study.pb.h"
@@ -535,13 +535,13 @@ TEST_F(VariationsServiceTest, InstanceManipulations) {
bool gzip_compressed;
bool seed_stored;
} cases[] = {
- {"", false, false, true},
- {"IM:gzip", false, true, true},
- {"IM:x-bm", true, false, true},
- {"IM:x-bm,gzip", true, true, true},
- {"IM: x-bm, gzip", true, true, true},
- {"IM:gzip,x-bm", false, false, false},
- {"IM:deflate,x-bm,gzip", false, false, false},
+ {"", false, false, true},
+ {"gzip", false, true, true},
+ {"x-bm", true, false, true},
+ {"x-bm,gzip", true, true, true},
+ {" x-bm, gzip", true, true, true},
+ {"gzip,x-bm", false, false, false},
+ {"deflate,x-bm,gzip", false, false, false},
};
std::string serialized_seed = SerializeSeed(CreateTestSeed());
@@ -558,7 +558,7 @@ TEST_F(VariationsServiceTest, InstanceManipulations) {
head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
net::HttpUtil::AssembleRawHeaders(headers));
if (!cases[i].im.empty())
- head->headers->AddHeader(cases[i].im);
+ head->headers->SetHeader("IM", cases[i].im);
network::URLLoaderCompletionStatus status;
status.decoded_body_length = serialized_seed.size();
service.test_url_loader_factory()->AddResponse(
@@ -587,7 +587,7 @@ TEST_F(VariationsServiceTest, CountryHeader) {
auto head = network::mojom::URLResponseHead::New();
head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
net::HttpUtil::AssembleRawHeaders(headers));
- head->headers->AddHeader("X-Country: test");
+ head->headers->SetHeader("X-Country", "test");
network::URLLoaderCompletionStatus status;
status.decoded_body_length = serialized_seed.size();
service.test_url_loader_factory()->AddResponse(
@@ -888,14 +888,12 @@ TEST_F(VariationsServiceTest, SafeMode_SuccessfulFetchClearsFailureStreaks) {
std::string response;
ASSERT_TRUE(base::Base64Decode(kBase64SeedData, &response));
- const std::string seed_signature_header =
- std::string("X-Seed-Signature:") + kBase64SeedSignature;
std::string headers("HTTP/1.1 200 OK\n\n");
auto head = network::mojom::URLResponseHead::New();
head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
net::HttpUtil::AssembleRawHeaders(headers));
- head->headers->AddHeader(seed_signature_header);
+ head->headers->SetHeader("X-Seed-Signature", kBase64SeedSignature);
network::URLLoaderCompletionStatus status;
status.decoded_body_length = response.size();
service.test_url_loader_factory()->AddResponse(
@@ -1058,8 +1056,6 @@ TEST_F(VariationsServiceTest, NullResponseReceivedWithHTTPOk) {
std::string response;
ASSERT_TRUE(base::Base64Decode(kBase64SeedData, &response));
- const std::string seed_signature_header =
- std::string("X-Seed-Signature:") + kBase64SeedSignature;
std::string headers("HTTP/1.1 200 OK\n\n");
auto head = network::mojom::URLResponseHead::New();
@@ -1067,7 +1063,7 @@ TEST_F(VariationsServiceTest, NullResponseReceivedWithHTTPOk) {
net::HttpUtil::AssembleRawHeaders(headers));
head->headers = http_response_headers;
EXPECT_EQ(net::HTTP_OK, http_response_headers->response_code());
- http_response_headers->AddHeader(seed_signature_header);
+ http_response_headers->SetHeader("X-Seed-Signature", kBase64SeedSignature);
// Set ERR_FAILED status code despite the 200 response code.
network::URLLoaderCompletionStatus status(net::ERR_FAILED);
status.decoded_body_length = response.size();
diff --git a/chromium/components/variations/variations_associated_data.cc b/chromium/components/variations/variations_associated_data.cc
index 07443b18098..5ca29b0110c 100644
--- a/chromium/components/variations/variations_associated_data.cc
+++ b/chromium/components/variations/variations_associated_data.cc
@@ -37,7 +37,7 @@ class GroupMapAccessor {
const ActiveGroupId& group_identifier,
const VariationID id,
const bool force) {
- static_assert(3 == ID_COLLECTION_COUNT,
+ static_assert(4 == ID_COLLECTION_COUNT,
"If you add a new collection key, add handling code here!");
#if DCHECK_IS_ON()
// Ensure that at most one of the trigger/non-trigger/signed-in web property
diff --git a/chromium/components/variations/variations_associated_data.h b/chromium/components/variations/variations_associated_data.h
index 55b9021c896..aa581ca15d9 100644
--- a/chromium/components/variations/variations_associated_data.h
+++ b/chromium/components/variations/variations_associated_data.h
@@ -65,6 +65,9 @@ enum IDCollectionKey {
// server side experimental behavior, transmitted through the
// X-Client-Data header.
GOOGLE_WEB_PROPERTIES_TRIGGER,
+ // This collection is used by the Google App and is passed at the time
+ // the cross-app communication is triggered.
+ GOOGLE_APP,
// The total count of collections.
ID_COLLECTION_COUNT,
};
diff --git a/chromium/components/variations/variations_http_header_provider.cc b/chromium/components/variations/variations_http_header_provider.cc
index 99e21de2889..d620cc5af5d 100644
--- a/chromium/components/variations/variations_http_header_provider.cc
+++ b/chromium/components/variations/variations_http_header_provider.cc
@@ -55,7 +55,8 @@ std::string VariationsHttpHeaderProvider::GetClientDataHeader(
return variation_ids_header_copy;
}
-std::string VariationsHttpHeaderProvider::GetVariationsString() {
+std::string VariationsHttpHeaderProvider::GetVariationsString(
+ IDCollectionKey key) {
InitVariationIDsCacheIfNeeded();
// Construct a space-separated string with leading and trailing spaces from
@@ -65,7 +66,7 @@ std::string VariationsHttpHeaderProvider::GetVariationsString() {
{
base::AutoLock scoped_lock(lock_);
for (const VariationIDEntry& entry : GetAllVariationIds()) {
- if (entry.second == GOOGLE_WEB_PROPERTIES) {
+ if (entry.second == key) {
ids_string.append(base::NumberToString(entry.first));
ids_string.push_back(' ');
}
@@ -74,6 +75,14 @@ std::string VariationsHttpHeaderProvider::GetVariationsString() {
return ids_string;
}
+std::string VariationsHttpHeaderProvider::GetGoogleAppVariationsString() {
+ return GetVariationsString(GOOGLE_APP);
+}
+
+std::string VariationsHttpHeaderProvider::GetVariationsString() {
+ return GetVariationsString(GOOGLE_WEB_PROPERTIES);
+}
+
std::vector<VariationID> VariationsHttpHeaderProvider::GetVariationsVector(
IDCollectionKey key) {
InitVariationIDsCacheIfNeeded();
@@ -157,6 +166,7 @@ void VariationsHttpHeaderProvider::OnFieldTrialGroupFinalized(
CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES);
CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES_SIGNED_IN);
CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES_TRIGGER);
+ CacheVariationsId(trial_name, group_name, GOOGLE_APP);
if (variation_ids_set_.size() != old_size)
UpdateVariationIDsHeaderValue();
}
@@ -179,6 +189,8 @@ void VariationsHttpHeaderProvider::OnSyntheticTrialsChanged(
synthetic_variation_ids_set_.insert(
VariationIDEntry(id, GOOGLE_WEB_PROPERTIES_SIGNED_IN));
}
+ // Google App IDs omitted because they should never be defined
+ // synthetically.
}
UpdateVariationIDsHeaderValue();
}
@@ -203,6 +215,7 @@ void VariationsHttpHeaderProvider::InitVariationIDsCacheIfNeeded() {
GOOGLE_WEB_PROPERTIES_SIGNED_IN);
CacheVariationsId(entry.trial_name, entry.group_name,
GOOGLE_WEB_PROPERTIES_TRIGGER);
+ CacheVariationsId(entry.trial_name, entry.group_name, GOOGLE_APP);
}
UpdateVariationIDsHeaderValue();
@@ -255,6 +268,9 @@ std::string VariationsHttpHeaderProvider::GenerateBase64EncodedProto(
case GOOGLE_WEB_PROPERTIES_TRIGGER:
proto.add_trigger_variation_id(entry.first);
break;
+ case GOOGLE_APP:
+ // These IDs should not be added into Google Web headers.
+ break;
case ID_COLLECTION_COUNT:
// This case included to get full enum coverage for switch, so that
// new enums introduce compiler warnings. Nothing to do for this.
diff --git a/chromium/components/variations/variations_http_header_provider.h b/chromium/components/variations/variations_http_header_provider.h
index 73ced9a69a4..bf324c7ef80 100644
--- a/chromium/components/variations/variations_http_header_provider.h
+++ b/chromium/components/variations/variations_http_header_provider.h
@@ -52,10 +52,18 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
// Returns a space-separated string containing the list of current active
// variations (as would be reported in the |variation_id| repeated field of
// the ClientVariations proto). Does not include variation ids that should be
- // sent for signed-in users only. The returned string is guaranteed to have a
- // a leading and trailing space, e.g. " 123 234 345 ".
+ // sent for signed-in users only and does not include Google app variations.
+ // The returned string is guaranteed to have a leading and trailing space,
+ // e.g. " 123 234 345 ".
std::string GetVariationsString();
+ // Same as GetVariationString(), but returns Google App variation ids rather
+ // than Google Web variations.
+ // IMPORTANT: This string is only approved for integrations with the Android
+ // Google App and must receive a privacy review before extending to other
+ // apps.
+ std::string GetGoogleAppVariationsString();
+
// Returns the collection of of variation ids matching the given |key|. Each
// entry in the returned vector will be unique.
std::vector<VariationID> GetVariationsVector(IDCollectionKey key);
@@ -108,6 +116,8 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
OnFieldTrialGroupFinalized);
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
+ GetGoogleAppVariationsString);
+ FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
GetVariationsString);
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
GetVariationsVector);
@@ -115,6 +125,11 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
VariationsHttpHeaderProvider();
~VariationsHttpHeaderProvider() override;
+ // Returns a space-separated string containing the list of current active
+ // variations (as would be reported in the |variation_id| repeated field of
+ // the ClientVariations proto) for a given ID collection.
+ std::string GetVariationsString(IDCollectionKey key);
+
// base::FieldTrialList::Observer:
// This will add the variation ID associated with |trial_name| and
// |group_name| to the variation ID cache.
diff --git a/chromium/components/variations/variations_http_header_provider_unittest.cc b/chromium/components/variations/variations_http_header_provider_unittest.cc
index 58bd69f4740..e4bdf31630d 100644
--- a/chromium/components/variations/variations_http_header_provider_unittest.cc
+++ b/chromium/components/variations/variations_http_header_provider_unittest.cc
@@ -211,6 +211,21 @@ TEST_F(VariationsHttpHeaderProviderTest, OnFieldTrialGroupFinalized) {
}
}
+TEST_F(VariationsHttpHeaderProviderTest, GetGoogleAppVariationsString) {
+ base::test::SingleThreadTaskEnvironment task_environment;
+ // All GOOGLE_WEB_PROPERTIES(_X) ids shouldn't be included.
+ CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES, 123);
+ CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES, 124);
+ CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
+
+ // GOOGLE_APP ids should be included.
+ CreateTrialAndAssociateId("t4", "g4", GOOGLE_APP, 126);
+
+ VariationsHttpHeaderProvider provider;
+ provider.ForceVariationIds({"100", "200"}, "");
+ EXPECT_EQ(" 126 ", provider.GetGoogleAppVariationsString());
+}
+
TEST_F(VariationsHttpHeaderProviderTest, GetVariationsString) {
base::test::SingleThreadTaskEnvironment task_environment;
@@ -218,6 +233,8 @@ TEST_F(VariationsHttpHeaderProviderTest, GetVariationsString) {
CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES, 124);
// SIGNED_IN ids shouldn't be included.
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
+ // GOOGLE_APP ids shouldn't be included.
+ CreateTrialAndAssociateId("t4", "g4", GOOGLE_APP, 126);
VariationsHttpHeaderProvider provider;
provider.ForceVariationIds({"100", "200"}, "");
@@ -231,6 +248,7 @@ TEST_F(VariationsHttpHeaderProviderTest, GetVariationsVector) {
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_TRIGGER, 123);
CreateTrialAndAssociateId("t4", "g4", GOOGLE_WEB_PROPERTIES_TRIGGER, 124);
CreateTrialAndAssociateId("t5", "g5", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
+ CreateTrialAndAssociateId("t6", "g6", GOOGLE_APP, 126);
VariationsHttpHeaderProvider provider;
provider.ForceVariationIds({"100", "200", "t101"}, "");
@@ -241,6 +259,8 @@ TEST_F(VariationsHttpHeaderProviderTest, GetVariationsVector) {
provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_TRIGGER));
EXPECT_EQ((std::vector<VariationID>{125}),
provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_SIGNED_IN));
+ EXPECT_EQ((std::vector<VariationID>{126}),
+ provider.GetVariationsVector(GOOGLE_APP));
}
} // namespace variations
diff --git a/chromium/components/variations/variations_murmur_hash.cc b/chromium/components/variations/variations_murmur_hash.cc
index 750e51d6bc0..1692af8d013 100644
--- a/chromium/components/variations/variations_murmur_hash.cc
+++ b/chromium/components/variations/variations_murmur_hash.cc
@@ -4,8 +4,10 @@
#include "components/variations/variations_murmur_hash.h"
+#include <string.h>
+
+#include "base/check_op.h"
#include "base/compiler_specific.h"
-#include "base/logging.h"
#include "base/sys_byteorder.h"
#include "build/build_config.h"
diff --git a/chromium/components/variations/variations_seed_processor.cc b/chromium/components/variations/variations_seed_processor.cc
index 2a61928beaa..ab5d7063ca6 100644
--- a/chromium/components/variations/variations_seed_processor.cc
+++ b/chromium/components/variations/variations_seed_processor.cc
@@ -50,9 +50,14 @@ void RegisterVariationIds(const Study_Experiment& experiment,
if (experiment.has_google_web_trigger_experiment_id()) {
const VariationID variation_id =
static_cast<VariationID>(experiment.google_web_trigger_experiment_id());
- AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES_TRIGGER,
- trial_name,
- experiment.name(),
+ AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES_TRIGGER, trial_name,
+ experiment.name(), variation_id);
+ }
+
+ if (experiment.has_google_app_experiment_id()) {
+ const VariationID variation_id =
+ static_cast<VariationID>(experiment.google_app_experiment_id());
+ AssociateGoogleVariationIDForce(GOOGLE_APP, trial_name, experiment.name(),
variation_id);
}
}