helium/core/components: descriptive helium services state error

now components show an error about disabled helium services if autoupdating is disabled
This commit is contained in:
wukko
2025-12-11 21:03:27 +06:00
parent db5ddc92c1
commit 714939df2c
2 changed files with 60 additions and 1 deletions

View File

@@ -159,3 +159,62 @@
Register(base::BindOnce(&ComponentUpdateService::RegisterComponent,
base::Unretained(cus)),
std::move(callback), cus->GetRegisteredVersion(crx_id),
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6957,6 +6957,9 @@ Keep your key file in a safe place. You
<message name="IDS_COMPONENTS_SVC_STATUS_UPDATE_ERROR" desc="Service Status">
Update error
</message>
+ <message name="IDS_COMPONENTS_SVC_STATUS_ERROR_HELIUM_SERVICES" desc="Service Status">
+ Component updates are disabled. See Helium services in settings.
+ </message>
<message name="IDS_COMPONENTS_UNKNOWN" desc="Service Status">
Unknown
</message>
--- a/chrome/browser/ui/webui/components/components_handler.cc
+++ b/chrome/browser/ui/webui/components/components_handler.cc
@@ -12,8 +12,12 @@
#include "base/notreached.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
+#include "components/helium_services/helium_services_helpers.h"
+#include "components/prefs/pref_service.h"
#include "components/update_client/crx_update_item.h"
+#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
ComponentsHandler::ComponentsHandler(
@@ -82,6 +86,20 @@ void ComponentsHandler::OnEvent(const up
std::u16string ComponentsHandler::ServiceStatusToString(
update_client::ComponentState state) {
+
+ if (state == update_client::ComponentState::kUpdateError) {
+ Profile* profile = Profile::FromBrowserContext(
+ web_ui()->GetWebContents()->GetBrowserContext());
+
+ if (profile) {
+ PrefService* prefs = profile->GetPrefs();
+ if (prefs && !helium::ShouldAccessComponentUpdateService(*prefs)) {
+ return l10n_util::GetStringUTF16(
+ IDS_COMPONENTS_SVC_STATUS_ERROR_HELIUM_SERVICES);
+ }
+ }
+ }
+
switch (state) {
case update_client::ComponentState::kNew:
return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_NEW);
--- a/chrome/browser/ui/webui/components/components_handler.h
+++ b/chrome/browser/ui/webui/components/components_handler.h
@@ -40,7 +40,7 @@ class ComponentsHandler : public content
void OnEvent(const update_client::CrxUpdateItem& item) override;
private:
- static std::u16string ServiceStatusToString(
+ std::u16string ServiceStatusToString(
update_client::ComponentState state);
base::Value::List LoadComponents();

View File

@@ -517,7 +517,7 @@
// The container (and extensions-menu button) should not be visible if we have
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -10466,6 +10466,9 @@ Keep your key file in a safe place. You
@@ -10469,6 +10469,9 @@ Keep your key file in a safe place. You
<message name="IDS_ACCNAME_FIND" desc="The accessible name for the find button.">
Find
</message>