Commit 84a07f87 authored by stuartmorgan's avatar stuartmorgan Committed by Commit bot

Keep WKWebView control group users in the control group

Don't require users who have entered the control group to be eligible
for the trial in subsequent launches in order to stay in the control
group. This makes the control group persistent for users who enter
it (just as the experiment group is persistent for users who are
migrated, although the mechanism there is very different) so there
won't be different biasing around crashing or incognito use.

Also fixes a recent regression that would cause force-enabled or
force-disabled users not to report the group.

TBR=rohitrao

BUG=557115
TEST=For a control group user, either terminate in incognito, or
crash. On the next launch, the user should still be in the control
group.

Review URL: https://codereview.chromium.org/1495443006

Cr-Commit-Position: refs/heads/master@{#362992}
parent f7e6422c
...@@ -94,6 +94,8 @@ void ApplicationContextImpl::RegisterPrefs(PrefRegistrySimple* registry) { ...@@ -94,6 +94,8 @@ void ApplicationContextImpl::RegisterPrefs(PrefRegistrySimple* registry) {
false); false);
registry->RegisterBooleanPref(prefs::kLastSessionExitedCleanly, true); registry->RegisterBooleanPref(prefs::kLastSessionExitedCleanly, true);
registry->RegisterBooleanPref(prefs::kMetricsReportingWifiOnly, true); registry->RegisterBooleanPref(prefs::kMetricsReportingWifiOnly, true);
registry->RegisterBooleanPref(prefs::kLastSessionUsedWKWebViewControlGroup,
false);
} }
void ApplicationContextImpl::PreCreateThreads() { void ApplicationContextImpl::PreCreateThreads() {
......
...@@ -32,6 +32,14 @@ bool IsLRUSnapshotCacheEnabled(); ...@@ -32,6 +32,14 @@ bool IsLRUSnapshotCacheEnabled();
// The returned value will not change within a given session. // The returned value will not change within a given session.
bool IsWKWebViewEnabled(); bool IsWKWebViewEnabled();
// Whether the user would be put into a control group for the WKWebView
// experiment assuming they were eligible. Calling this will *not* activate a
// trial, so is safe to call without checking eligibility.
bool IsTargetedToWKWebViewExperimentControlGroup();
// Whether the user is part of a control group for the WKWebView experiment.
bool IsInWKWebViewExperimentControlGroup();
// Returns a string containing extra params that should be sent along with // Returns a string containing extra params that should be sent along with
// omnibox search requests. The returned value contains a leading "&". // omnibox search requests. The returned value contains a leading "&".
std::string GetWKWebViewSearchParams(); std::string GetWKWebViewSearchParams();
......
...@@ -27,6 +27,7 @@ NSString* const kEnableAlertOnBackgroundUpload = ...@@ -27,6 +27,7 @@ NSString* const kEnableAlertOnBackgroundUpload =
NSString* const kEnableViewCopyPasswords = @"EnableViewCopyPasswords"; NSString* const kEnableViewCopyPasswords = @"EnableViewCopyPasswords";
NSString* const kHeuristicsForPasswordGeneration = NSString* const kHeuristicsForPasswordGeneration =
@"HeuristicsForPasswordGeneration"; @"HeuristicsForPasswordGeneration";
const char* const kWKWebViewTrialName = "IOSUseWKWebView";
enum class WKWebViewEligibility { enum class WKWebViewEligibility {
// UNSET indicates that no explicit call to set eligibility has been made, // UNSET indicates that no explicit call to set eligibility has been made,
...@@ -128,6 +129,11 @@ bool IsWKWebViewEnabled() { ...@@ -128,6 +129,11 @@ bool IsWKWebViewEnabled() {
return false; return false;
} }
// Now that it's been established that user is a candidate, set up the trial
// by checking the group.
std::string group_name =
base::FieldTrialList::FindFullName(kWKWebViewTrialName);
// Check if the experimental flag is turned on. // Check if the experimental flag is turned on.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableIOSWKWebView)) if (command_line->HasSwitch(switches::kEnableIOSWKWebView))
...@@ -135,22 +141,36 @@ bool IsWKWebViewEnabled() { ...@@ -135,22 +141,36 @@ bool IsWKWebViewEnabled() {
else if (command_line->HasSwitch(switches::kDisableIOSWKWebView)) else if (command_line->HasSwitch(switches::kDisableIOSWKWebView))
return false; return false;
// Now that it's been established that user is a candidate, set up the trial
// by checking the group.
std::string group_name =
base::FieldTrialList::FindFullName("IOSUseWKWebView");
// Check if the finch experiment is turned on. // Check if the finch experiment is turned on.
return base::StartsWith(group_name, "Enabled", return base::StartsWith(group_name, "Enabled",
base::CompareCase::INSENSITIVE_ASCII); base::CompareCase::INSENSITIVE_ASCII);
} }
bool IsTargetedToWKWebViewExperimentControlGroup() {
base::FieldTrial* trial = base::FieldTrialList::Find(kWKWebViewTrialName);
if (!trial)
return false;
std::string group_name = trial->GetGroupNameWithoutActivation();
return base::StartsWith(group_name, "Control",
base::CompareCase::INSENSITIVE_ASCII);
}
bool IsInWKWebViewExperimentControlGroup() {
if (!CanCheckWKWebViewExperiment()) {
return false;
}
std::string group_name =
base::FieldTrialList::FindFullName(kWKWebViewTrialName);
return base::StartsWith(group_name, "Control",
base::CompareCase::INSENSITIVE_ASCII);
}
std::string GetWKWebViewSearchParams() { std::string GetWKWebViewSearchParams() {
if (!CanCheckWKWebViewExperiment()) { if (!CanCheckWKWebViewExperiment()) {
return std::string(); return std::string();
} }
return variations::GetVariationParamValue("IOSUseWKWebView", "esrch"); return variations::GetVariationParamValue(kWKWebViewTrialName, "esrch");
} }
bool AreKeyboardCommandsEnabled() { bool AreKeyboardCommandsEnabled() {
......
...@@ -70,6 +70,10 @@ const char kIosHandoffToOtherDevices[] = "ios.handoff_to_other_devices"; ...@@ -70,6 +70,10 @@ const char kIosHandoffToOtherDevices[] = "ios.handoff_to_other_devices";
const char kLastSessionExitedCleanly[] = const char kLastSessionExitedCleanly[] =
"ios.user_experience_metrics.last_session_exited_cleanly"; "ios.user_experience_metrics.last_session_exited_cleanly";
// True if the previous session was selected into the WKWebView control group.
const char kLastSessionUsedWKWebViewControlGroup[] =
"ios.wkwebview_trial.was_control";
// Preference that hold a boolean indicating whether metrics reporting should // Preference that hold a boolean indicating whether metrics reporting should
// be limited to wifi (when enabled). // be limited to wifi (when enabled).
const char kMetricsReportingWifiOnly[] = const char kMetricsReportingWifiOnly[] =
......
...@@ -36,6 +36,7 @@ extern const char kBrowsingDataMigrationHasBeenPossible[]; ...@@ -36,6 +36,7 @@ extern const char kBrowsingDataMigrationHasBeenPossible[];
extern const char kOTRStashStatePathSystemBackupExcluded[]; extern const char kOTRStashStatePathSystemBackupExcluded[];
extern const char kIosHandoffToOtherDevices[]; extern const char kIosHandoffToOtherDevices[];
extern const char kLastSessionExitedCleanly[]; extern const char kLastSessionExitedCleanly[];
extern const char kLastSessionUsedWKWebViewControlGroup[];
extern const char kMetricsReportingWifiOnly[]; extern const char kMetricsReportingWifiOnly[];
// TODO(stkhapugin): Consider migrating from these two bools to an integer. // TODO(stkhapugin): Consider migrating from these two bools to an integer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment