Commit 98cc92c5 authored by Swapnil's avatar Swapnil Committed by Commit Bot

Add more known misconfiguration failures occurred in case of force

installed extensions

Some failures occur due to NOT_PERORMING_NEW_INSTALL error. The reason
for this is a deprecated extension which should not be used, thus it is
a misconfiguration from admin.

Some failures occur due to REPLACED_BY_ARC_APP error. If a device
doesn't support ARC++, the app will be installed, otherwise the ARC++
app will be used and this one will fail as expected. This error is
considered a misconfiguration only if ARC++ is enabled for the
profile.

Bug: 1067605, 1067606
Change-Id: I8001c70c5b13a3aa1c06c4c3ab4549dfe1e04eda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144027
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760047}
parent e83db3d1
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/extensions/extension_management_constants.h" #include "chrome/browser/extensions/extension_management_constants.h"
#include "chrome/browser/extensions/forced_extensions/installation_reporter.h" #include "chrome/browser/extensions/forced_extensions/installation_reporter.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/prefs/pref_service.h"
#include "extensions/browser/disable_reason.h" #include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/install/crx_install_error.h" #include "extensions/browser/install/crx_install_error.h"
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
#include "extensions/browser/updater/extension_downloader_delegate.h" #include "extensions/browser/updater/extension_downloader_delegate.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "components/arc/arc_prefs.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -88,17 +90,33 @@ InstallationMetrics::~InstallationMetrics() = default; ...@@ -88,17 +90,33 @@ InstallationMetrics::~InstallationMetrics() = default;
bool InstallationMetrics::IsMisconfiguration( bool InstallationMetrics::IsMisconfiguration(
const InstallationReporter::InstallationData& installation_data, const InstallationReporter::InstallationData& installation_data,
const ExtensionId& id) { const ExtensionId& id) {
ExtensionManagement* management = if (installation_data.install_error_detail) {
ExtensionManagementFactory::GetForBrowserContext(profile_); ExtensionManagement* management =
CrxInstallErrorDetail detail = installation_data.install_error_detail.value(); ExtensionManagementFactory::GetForBrowserContext(profile_);
if (detail == CrxInstallErrorDetail::KIOSK_MODE_ONLY) CrxInstallErrorDetail detail =
installation_data.install_error_detail.value();
if (detail == CrxInstallErrorDetail::KIOSK_MODE_ONLY)
return true;
if (detail == CrxInstallErrorDetail::DISALLOWED_BY_POLICY &&
!management->IsAllowedManifestType(
installation_data.extension_type.value(), id)) {
return true;
}
}
#if defined(OS_CHROMEOS)
// REPLACED_BY_ARC_APP error is a misconfiguration if it ARC++ is enabled for
// the device.
if (profile_->GetPrefs()->IsManagedPreference(arc::prefs::kArcEnabled) &&
profile_->GetPrefs()->GetBoolean(arc::prefs::kArcEnabled) &&
installation_data.failure_reason ==
InstallationReporter::FailureReason::REPLACED_BY_ARC_APP)
return true; return true;
#endif // defined(OS_CHROMEOS)
if (detail == CrxInstallErrorDetail::DISALLOWED_BY_POLICY && if (installation_data.failure_reason ==
!management->IsAllowedManifestType( InstallationReporter::FailureReason::NOT_PERFORMING_NEW_INSTALL)
installation_data.extension_type.value(), id)) {
return true; return true;
}
return false; return false;
} }
...@@ -184,6 +202,8 @@ void InstallationMetrics::ReportMetrics() { ...@@ -184,6 +202,8 @@ void InstallationMetrics::ReportMetrics() {
"Extensions.ForceInstalledDownloadingStage", downloading_stage); "Extensions.ForceInstalledDownloadingStage", downloading_stage);
} }
} }
if (IsMisconfiguration(installation, extension_id))
misconfigured_extensions++;
InstallationReporter::FailureReason failure_reason = InstallationReporter::FailureReason failure_reason =
installation.failure_reason.value_or( installation.failure_reason.value_or(
InstallationReporter::FailureReason::UNKNOWN); InstallationReporter::FailureReason::UNKNOWN);
...@@ -245,8 +265,6 @@ void InstallationMetrics::ReportMetrics() { ...@@ -245,8 +265,6 @@ void InstallationMetrics::ReportMetrics() {
<< InstallationReporter::GetFormattedInstallationData(installation); << InstallationReporter::GetFormattedInstallationData(installation);
if (installation.install_error_detail) { if (installation.install_error_detail) {
CrxInstallErrorDetail detail = installation.install_error_detail.value(); CrxInstallErrorDetail detail = installation.install_error_detail.value();
if (IsMisconfiguration(installation, extension_id))
misconfigured_extensions++;
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
"Extensions.ForceInstalledFailureCrxInstallError", detail); "Extensions.ForceInstalledFailureCrxInstallError", detail);
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "components/arc/arc_prefs.h"
#include "components/user_manager/fake_user_manager.h" #include "components/user_manager/fake_user_manager.h"
#include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user_names.h" #include "components/user_manager/user_names.h"
...@@ -618,6 +619,70 @@ TEST_F(ForcedExtensionsInstallationTrackerTest, ...@@ -618,6 +619,70 @@ TEST_F(ForcedExtensionsInstallationTrackerTest,
1); 1);
} }
#if defined(OS_CHROMEOS)
// Session in which either all the extensions installed successfully, or all
// failures are admin-side misconfigurations. This test verifies that failure
// REPLACED_BY_ARC_APP is not considered as misconfiguration when ARC++ is
// enabled for the profile.
TEST_F(ForcedExtensionsInstallationTrackerTest,
NonMisconfigurationFailureNotPresentReplacedByArcAppErrorArcEnabled) {
// Enable ARC++ for this profile.
prefs_->SetManagedPref(arc::prefs::kArcEnabled,
std::make_unique<base::Value>(true));
SetupForceList();
auto extension =
ExtensionBuilder(kExtensionName1).SetID(kExtensionId1).Build();
tracker_->OnExtensionLoaded(&profile_, extension.get());
installation_reporter_->ReportFailure(
kExtensionId2, InstallationReporter::FailureReason::REPLACED_BY_ARC_APP);
// InstallationTracker shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectBucketCount(kPossibleNonMisconfigurationFailures, 0,
1);
}
// Session in which at least one non misconfiguration failure occurred. This
// test verifies that failure REPLACED_BY_ARC_APP is not considered as
// misconfiguration when ARC++ is disabled for the profile.
TEST_F(ForcedExtensionsInstallationTrackerTest,
NonMisconfigurationFailureNotPresentReplacedByArcAppErrorArcDisabled) {
// Enable ARC++ for this profile.
prefs_->SetManagedPref(arc::prefs::kArcEnabled,
std::make_unique<base::Value>(false));
SetupForceList();
auto extension =
ExtensionBuilder(kExtensionName1).SetID(kExtensionId1).Build();
tracker_->OnExtensionLoaded(&profile_, extension.get());
installation_reporter_->ReportFailure(
kExtensionId2, InstallationReporter::FailureReason::REPLACED_BY_ARC_APP);
// InstallationTracker shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectBucketCount(kPossibleNonMisconfigurationFailures, 1,
1);
}
#endif // defined(OS_CHROMEOS)
// Session in which either all the extensions installed successfully, or all
// failures are admin-side misconfigurations. This test verifies that failure
// NOT_PERFORMING_NEW_INSTALL is considered as misconfiguration.
TEST_F(ForcedExtensionsInstallationTrackerTest,
NonMisconfigurationFailureNotPresentNotPerformingNewInstallError) {
SetupForceList();
auto extension =
ExtensionBuilder(kExtensionName1).SetID(kExtensionId1).Build();
tracker_->OnExtensionLoaded(&profile_, extension.get());
installation_reporter_->ReportFailure(
kExtensionId2,
InstallationReporter::FailureReason::NOT_PERFORMING_NEW_INSTALL);
// InstallationTracker shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectBucketCount(kPossibleNonMisconfigurationFailures, 0,
1);
}
TEST_F(ForcedExtensionsInstallationTrackerTest, NoExtensionsConfigured) { TEST_F(ForcedExtensionsInstallationTrackerTest, NoExtensionsConfigured) {
EXPECT_TRUE(fake_timer_->IsRunning()); EXPECT_TRUE(fake_timer_->IsRunning());
fake_timer_->Fire(); fake_timer_->Fire();
......
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