Commit 222d6d42 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Add testing option to change GAIA cookie refresh delay.

Allows manual testing of the GAIA refresh feature by reducing the delay
between polls to verify if GAIA cookies are available for a signed-in
user.

Bug: 1131027
Change-Id: Ib163a91ec3e5b922d652cff68c60b4e08708a828
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440505
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812310}
parent c9b7db96
......@@ -3096,6 +3096,11 @@
],
"expiry_milestone": 95
},
{
"name": "minutes-delay-to-restore-gaia-cookies-if-deleted",
"owners": ["fernandex", "chrome-signin-team"],
"expiry_milestone": 90
},
{
"name": "mixed-forms-disable-autofill",
"owners": [ "carlosil" ],
......
......@@ -7,10 +7,12 @@
#import <WebKit/WebKit.h>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
#import "base/mac/foundation_util.h"
#include "base/macros.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/google/core/common/google_util.h"
......@@ -65,6 +67,23 @@ static std::string GetDomainFromUrl(const GURL& url) {
url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
}
// Allows for manual testing by reducing the polling interval for verifying the
// existence of the GAIA cookie.
base::TimeDelta GetDelayThresholdToUpdateGaiaCookie() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(
signin::kDelayThresholdMinutesToUpdateGaiaCookie)) {
std::string delayString = command_line->GetSwitchValueASCII(
signin::kDelayThresholdMinutesToUpdateGaiaCookie);
int commandLineDelay = 0;
if (base::StringToInt(delayString, &commandLineDelay)) {
return base::TimeDelta::FromMinutes(commandLineDelay);
}
}
return kDelayThresholdToUpdateGaiaCookie;
}
// WebStatePolicyDecider that monitors the HTTP headers on Gaia responses,
// reacting on the X-Chrome-Manage-Accounts header and notifying its delegate.
// It also notifies the AccountConsistencyService of domains it should add the
......@@ -279,7 +298,7 @@ void AccountConsistencyService::SetGaiaCookiesIfDeleted() {
// for signed-in users to prevent calling the expensive method
// |GetAllCookies| in the cookie manager.
if (base::Time::Now() - last_gaia_cookie_verification_time_ <
kDelayThresholdToUpdateGaiaCookie ||
GetDelayThresholdToUpdateGaiaCookie() ||
!identity_manager_->HasPrimaryAccount()) {
return;
}
......
......@@ -16,4 +16,7 @@ bool ForceStartupSigninPromo() {
const base::Feature kRestoreGaiaCookiesIfDeleted{
"RestoreGAIACookiesIfDeleted", base::FEATURE_DISABLED_BY_DEFAULT};
const char kDelayThresholdMinutesToUpdateGaiaCookie[] =
"minutes-delay-to-restore-gaia-cookies-if-deleted";
} // namespace signin
......@@ -18,6 +18,10 @@ bool ForceStartupSigninPromo();
// Feature controlling whether to restore GAIA cookies if they are deleted.
extern const base::Feature kRestoreGaiaCookiesIfDeleted;
// Name of multi-value switch that controls the delay (in minutes) for polling
// for the existence of Gaia cookies for google.com.
extern const char kDelayThresholdMinutesToUpdateGaiaCookie[];
} // namespace signin
#endif // COMPONENTS_SIGNIN_IOS_BROWSER_FEATURES_H_
......@@ -125,6 +125,13 @@ const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
{"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
};
const FeatureEntry::Choice kDelayThresholdMinutesToUpdateGaiaCookieChoices[] = {
{flags_ui::kGenericExperimentChoiceDefault, "", ""},
{"0", signin::kDelayThresholdMinutesToUpdateGaiaCookie, "0"},
{"10", signin::kDelayThresholdMinutesToUpdateGaiaCookie, "10"},
{"60", signin::kDelayThresholdMinutesToUpdateGaiaCookie, "60"},
};
const FeatureEntry::FeatureVariation
kOmniboxOnDeviceHeadSuggestNonIncognitoExperimentVariations[] = {
{
......@@ -682,6 +689,11 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flag_descriptions::kRestoreGaiaCookiesIfDeletedDescription,
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(signin::kRestoreGaiaCookiesIfDeleted)},
{"minutes-delay-to-restore-gaia-cookies-if-deleted",
flag_descriptions::kDelayThresholdMinutesToUpdateGaiaCookieName,
flag_descriptions::kDelayThresholdMinutesToUpdateGaiaCookieDescription,
flags_ui::kOsIos,
MULTI_VALUE_TYPE(kDelayThresholdMinutesToUpdateGaiaCookieChoices)},
};
bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
......
......@@ -182,6 +182,12 @@ const char kDefaultBrowserFullscreenPromoDescription[] =
"users informing them about the default browser feature and providing a "
"button that takes users to Settings.app to update their default browser.";
const char kDelayThresholdMinutesToUpdateGaiaCookieName[] =
"Delay for polling (in minutes) to verify the existence of GAIA cookies.";
const char kDelayThresholdMinutesToUpdateGaiaCookieDescription[] =
"Used for testing purposes to reduce the amount of delay between polling "
"intervals.";
const char kDetectMainThreadFreezeName[] = "Detect freeze in the main thread.";
const char kDetectMainThreadFreezeDescription[] =
"A crash report will be uploaded if the main thread is frozen more than "
......
......@@ -151,6 +151,11 @@ extern const char kDefaultToDesktopOnIPadDescription[];
extern const char kDefaultBrowserFullscreenPromoName[];
extern const char kDefaultBrowserFullscreenPromoDescription[];
// Title and description for the flag to control the delay (in minutes) for
// polling for the existence of Gaia cookies for google.com.
extern const char kDelayThresholdMinutesToUpdateGaiaCookieName[];
extern const char kDelayThresholdMinutesToUpdateGaiaCookieDescription[];
// Title and description for the flag to control if a crash report is generated
// on main thread freeze.
extern const char kDetectMainThreadFreezeName[];
......
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