Commit af173123 authored by Andrey Zaytsev's avatar Andrey Zaytsev Committed by Commit Bot

Safety check: added the "unknown" update state and string

This state is present on non-Google branded browsers, where it is not possible to check for updates directly. In this case Safety check simply prints out the current version.

Bug: 1015841
Change-Id: I23e54330366fb722f36a7b6732970c0627a9a705
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144038Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Commit-Queue: Andrey Zaytsev <andzaytsev@google.com>
Cr-Commit-Position: refs/heads/master@{#759623}
parent 4677fa6f
......@@ -118,6 +118,9 @@
<message name="IDS_SETTINGS_SAFETY_CHECK_UPDATES_FAILED" desc="This text describes that Chromium cannot update due to an unknown error.">
Chromium didn't update, something went wrong. <ph name="BEGIN_LINK">&lt;a target="_blank" href="$1"&gt;</ph>Fix Chromium update problems and failed updates.<ph name="END_LINK">&lt;/a&gt;</ph>
</message>
<message name="IDS_SETTINGS_SAFETY_CHECK_UPDATES_UNKNOWN" desc="This text displays the installed version of Chromium when it is not possible to check for updates on non-Chrome branded browsers.">
Chromium version <ph name="PRODUCT_VERSION">$1<ex>15.0.865.0</ex></ph> is installed
</message>
<message name="IDS_SETTINGS_SAFETY_CHECK_PASSWORDS_SIGNED_OUT" desc="This text points out that the password check can only run when the user is signed in.">
Chromium can't check your passwords because you're not signed in
</message>
......
......@@ -118,6 +118,9 @@
<message name="IDS_SETTINGS_SAFETY_CHECK_UPDATES_FAILED" desc="This text describes that Chrome cannot update due to an unknown error.">
Chrome didn't update, something went wrong. <ph name="BEGIN_LINK">&lt;a target="_blank" href="$1"&gt;</ph>Fix Chrome update problems and failed updates.<ph name="END_LINK">&lt;/a&gt;</ph>
</message>
<message name="IDS_SETTINGS_SAFETY_CHECK_UPDATES_UNKNOWN" desc="This text displays the installed version of Chrome when it is not possible to check for updates.">
Chrome version <ph name="PRODUCT_VERSION">$1<ex>15.0.865.0</ex></ph> is installed
</message>
<message name="IDS_SETTINGS_SAFETY_CHECK_PASSWORDS_SIGNED_OUT" desc="This text points out that the password check can only run when the user is signed in.">
Chrome can't check your passwords because you're not signed in
</message>
......
......@@ -20,6 +20,7 @@
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/version_info/version_info.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_id.h"
......@@ -65,9 +66,8 @@ SafetyCheckHandler::UpdateStatus ConvertToUpdateStatus(
case VersionUpdater::DISABLED_BY_ADMIN:
return SafetyCheckHandler::UpdateStatus::kDisabledByAdmin;
// The disabled state can only be returned on non Chrome-branded browsers.
// Since we don't know the actual state of updates, this is the same as a
// generic error.
case VersionUpdater::DISABLED:
return SafetyCheckHandler::UpdateStatus::kUnknown;
case VersionUpdater::FAILED:
case VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED:
return SafetyCheckHandler::UpdateStatus::kFailed;
......@@ -337,6 +337,10 @@ base::string16 SafetyCheckHandler::GetStringForUpdates(UpdateStatus status) {
return l10n_util::GetStringFUTF16(
IDS_SETTINGS_SAFETY_CHECK_UPDATES_FAILED,
base::ASCIIToUTF16(chrome::kChromeFixUpdateProblems));
case UpdateStatus::kUnknown:
return l10n_util::GetStringFUTF16(
IDS_SETTINGS_SAFETY_CHECK_UPDATES_UNKNOWN,
base::UTF8ToUTF16(version_info::GetVersionNumber()));
}
}
......
......@@ -42,8 +42,11 @@ class SafetyCheckHandler
kDisabledByAdmin = 4,
kFailedOffline = 5,
kFailed = 6,
// Non-Google branded browsers cannot check for updates using
// VersionUpdater.
kUnknown = 7,
// New enum values must go above here.
kMaxValue = kFailed,
kMaxValue = kUnknown,
};
enum class SafeBrowsingStatus {
kChecking = 0,
......
......@@ -29,6 +29,7 @@
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/version_info/version_info.h"
#include "content/public/test/test_web_ui.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/common/extension.h"
......@@ -372,16 +373,14 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Disabled) {
const base::DictionaryValue* event =
GetSafetyCheckStatusChangedWithDataIfExists(
kUpdates,
static_cast<int>(SafetyCheckHandler::UpdateStatus::kFailed));
static_cast<int>(SafetyCheckHandler::UpdateStatus::kUnknown));
ASSERT_TRUE(event);
VerifyDisplayString(
event,
"Browser didn't update, something went wrong. <a target=\"_blank\" "
"href=\"https://support.google.com/chrome?p=fix_chrome_updates\">Fix "
"Browser update problems and failed updates.</a>");
histogram_tester_.ExpectBucketCount("Settings.SafetyCheck.UpdatesResult",
SafetyCheckHandler::UpdateStatus::kFailed,
1);
"Browser version " + version_info::GetVersionNumber() + " is installed");
histogram_tester_.ExpectBucketCount(
"Settings.SafetyCheck.UpdatesResult",
SafetyCheckHandler::UpdateStatus::kUnknown, 1);
}
TEST_F(SafetyCheckHandlerTest, CheckUpdates_DisabledByAdmin) {
......
......@@ -58077,6 +58077,7 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
<int value="4" label="DISABLED_BY_ADMIN"/>
<int value="5" label="FAILED_OFFLINE"/>
<int value="6" label="FAILED"/>
<int value="7" label="UNKNOWN"/>
</enum>
<enum name="SafetyTipInteraction">
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