Commit 411ca979 authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

The default high annoyance threshold is platform-specific.

Update the policy documentation and the pref's default value
accordingly.

BUG=511300

Change-Id: I1160474dbe48478d95bfdcdd17017e808b398492
Reviewed-on: https://chromium-review.googlesource.com/968523Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544854}
parent 54b2402c
......@@ -173,3 +173,8 @@ UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() {
UpgradeDetector* UpgradeDetector::GetInstance() {
return UpgradeDetectorChromeos::GetInstance();
}
// static
base::TimeDelta UpgradeDetector::GetDefaultHighAnnoyanceThreshold() {
return base::TimeDelta::FromDays(kHighDaysThreshold);
}
......@@ -4,9 +4,11 @@
#include "chrome/browser/ui/browser_ui_prefs.h"
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
......@@ -40,8 +42,11 @@ void RegisterBrowserPrefs(PrefRegistrySimple* registry) {
#if !defined(OS_CHROMEOS)
registry->RegisterIntegerPref(prefs::kRelaunchNotification, 0);
#endif // !defined(OS_CHROMEOS)
registry->RegisterIntegerPref(prefs::kRelaunchNotificationPeriod,
7 * 24 * 60 * 60 * 1000); // 1 week.
registry->RegisterIntegerPref(
prefs::kRelaunchNotificationPeriod,
base::saturated_cast<int>(
UpgradeDetector::GetDefaultHighAnnoyanceThreshold()
.InMilliseconds()));
#endif // !defined(OS_ANDROID)
}
......
......@@ -51,6 +51,10 @@ class UpgradeDetector {
virtual ~UpgradeDetector();
// Returns the default delta from upgrade detection until high annoyance is
// reached.
static base::TimeDelta GetDefaultHighAnnoyanceThreshold();
static void RegisterPrefs(PrefRegistrySimple* registry);
// Returns the time at which an available upgrade was detected.
......
......@@ -43,6 +43,12 @@
namespace {
// The default thresholds for reaching annoyance levels.
constexpr base::TimeDelta kDefaultLowThreshold = base::TimeDelta::FromDays(2);
constexpr base::TimeDelta kDefaultElevatedThreshold =
base::TimeDelta::FromDays(4);
constexpr base::TimeDelta kDefaultHighThreshold = base::TimeDelta::FromDays(7);
// How long (in milliseconds) to wait (each cycle) before checking whether
// Chrome's been upgraded behind our back.
const int kCheckForUpgradeMs = 2 * 60 * 60 * 1000; // 2 hours.
......@@ -322,21 +328,26 @@ void UpgradeDetectorImpl::InitializeThresholds() {
if (!low_threshold_.is_zero())
return;
// Intervals are drastically shortened when test switches are used.
// Start with the default values.
low_threshold_ = kDefaultLowThreshold;
elevated_threshold_ = kDefaultElevatedThreshold;
high_threshold_ = kDefaultHighThreshold;
// When testing, scale everything back so that a day passes in ten seconds.
const bool is_testing = IsTesting();
const base::TimeDelta multiplier = is_testing
? base::TimeDelta::FromSeconds(10)
: base::TimeDelta::FromDays(1);
high_threshold_ = 7 * multiplier;
elevated_threshold_ = 4 * multiplier;
if (is_testing) {
static constexpr int64_t scale_factor =
base::TimeDelta::FromDays(1) / base::TimeDelta::FromSeconds(10);
low_threshold_ /= scale_factor;
elevated_threshold_ /= scale_factor;
high_threshold_ /= scale_factor;
}
// Canary and dev channels are extra special, and reach "low" annoyance after
// one hour (one second in testing) and never advance beyond that.
if (is_unstable_channel_) {
// Canary and dev channels reach "low" annoyance after one hour (one second
// in testing) and never advance beyond that.
low_threshold_ = is_testing ? base::TimeDelta::FromSeconds(1)
: base::TimeDelta::FromHours(1);
} else {
low_threshold_ = 2 * multiplier;
}
}
......@@ -511,3 +522,8 @@ base::TimeTicks UpgradeDetectorImpl::GetHighAnnoyanceDeadline() {
UpgradeDetector* UpgradeDetector::GetInstance() {
return UpgradeDetectorImpl::GetInstance();
}
// static
base::TimeDelta UpgradeDetector::GetDefaultHighAnnoyanceThreshold() {
return kDefaultHighThreshold;
}
......@@ -11354,7 +11354,7 @@
'example_value': 604800000,
'desc': '''Allows you to set the time period over which <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> relaunch notifications are shown to apply a pending update.
This policy setting can be used to control the time period, in milliseconds, over which a user is progressively informed that <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> must be relaunched (or <ph name="PRODUCT_OS_NAME">$2<ex>Google Chrome OS</ex></ph> must be restarted) for an update. Over this time period, the user will be repeatedly informed of the need for an update based on the setting of the <ph name="RELAUNCH_NOTIFICATION_POLICY_NAME">RelaunchNotification</ph> policy. If not set, the default period of 604800000 milliseconds (one week) is used.''',
This policy setting can be used to control the time period, in milliseconds, over which a user is progressively informed that <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> must be relaunched (or <ph name="PRODUCT_OS_NAME">$2<ex>Google Chrome OS</ex></ph> must be restarted) for an update. Over this time period, the user will be repeatedly informed of the need for an update based on the setting of the <ph name="RELAUNCH_NOTIFICATION_POLICY_NAME">RelaunchNotification</ph> policy. If not set, the default period of 345600000 milliseconds (four days) is used for <ph name="PRODUCT_OS_NAME">$2<ex>Google Chrome OS</ex></ph> and 604800000 milliseconds (one week) for all other platforms.''',
},
{
'name': 'VirtualMachinesAllowed',
......
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