Files
helium/patches/helium/ui/ublock-show-in-settings.patch
wukko e64526ce10 helium/core: component updates via helium services
managed by the same toggle as general browser updates
2025-12-12 17:35:27 +06:00

223 lines
9.6 KiB
C++

--- a/extensions/browser/ui_util.h
+++ b/extensions/browser/ui_util.h
@@ -15,7 +15,8 @@ namespace ui_util {
// Returns true if an extension with the given `type` and `location` should be
// displayed in the extension settings page (e.g. chrome://extensions).
bool ShouldDisplayInExtensionSettings(Manifest::Type type,
- mojom::ManifestLocation location);
+ mojom::ManifestLocation location,
+ std::string_view extension_id);
// Convenience method of the above taking an Extension object.
bool ShouldDisplayInExtensionSettings(const Extension& extension);
--- a/extensions/browser/ui_util.cc
+++ b/extensions/browser/ui_util.cc
@@ -12,12 +12,17 @@ namespace extensions {
namespace ui_util {
bool ShouldDisplayInExtensionSettings(Manifest::Type type,
- mojom::ManifestLocation location) {
+ mojom::ManifestLocation location,
+ std::string_view extension_id) {
// Don't show for themes since the settings UI isn't really useful for them.
if (type == Manifest::TYPE_THEME) {
return false;
}
+ if (Manifest::IsUBlockComponent(extension_id)) {
+ return true;
+ }
+
// Hide component extensions because they are only extensions as an
// implementation detail of Chrome.
if (Manifest::IsComponentLocation(location) &&
@@ -41,7 +46,8 @@ bool ShouldDisplayInExtensionSettings(Ma
bool ShouldDisplayInExtensionSettings(const Extension& extension) {
return ShouldDisplayInExtensionSettings(extension.GetType(),
- extension.location());
+ extension.location(),
+ extension.id());
}
} // namespace ui_util
--- a/extensions/browser/extension_util.cc
+++ b/extensions/browser/extension_util.cc
@@ -304,7 +304,7 @@ bool CanWithholdPermissionsFromExtension
// withheld permissions couldn't be granted), extensions that are part of
// chrome or corporate policy, and extensions that are allowlisted to script
// everywhere must always have permission to run on a page.
- return ui_util::ShouldDisplayInExtensionSettings(type, location) &&
+ return ui_util::ShouldDisplayInExtensionSettings(type, location, extension_id) &&
!Manifest::IsPolicyLocation(location) &&
!Manifest::IsComponentLocation(location) &&
!PermissionsData::CanExecuteScriptEverywhere(extension_id, location);
--- a/extensions/browser/api/management/management_api.cc
+++ b/extensions/browser/api/management/management_api.cc
@@ -82,7 +82,8 @@ AutoConfirmForTest auto_confirm_for_test
// Returns true if the extension should be exposed via the chrome.management
// API.
bool ShouldExposeViaManagementAPI(const Extension& extension) {
- return !Manifest::IsComponentLocation(extension.location());
+ return !Manifest::IsComponentLocation(extension.location())
+ || Manifest::IsUBlockComponent(extension.id());
}
// Utility function to make the code below less ifdef-y.
@@ -780,7 +781,9 @@ ExtensionFunction::ResponseAction Manage
extensions::ExtensionRegistry::Get(browser_context())
->GetExtensionById(target_extension_id_,
ExtensionRegistry::EVERYTHING);
- if (!target_extension || !ShouldExposeViaManagementAPI(*target_extension)) {
+ if (!target_extension
+ || !ShouldExposeViaManagementAPI(*target_extension)
+ || Manifest::IsUBlockComponent(target_extension->id())) {
return RespondNow(Error(keys::kNoExtensionError, target_extension_id_));
}
--- a/chrome/common/extensions/api/developer_private.idl
+++ b/chrome/common/extensions/api/developer_private.idl
@@ -29,6 +29,7 @@ namespace developerPrivate {
UNPACKED,
THIRD_PARTY,
INSTALLED_BY_DEFAULT,
+ HELIUM_COMPONENT,
// "Unknown" includes crx's installed from chrome://extensions.
UNKNOWN
};
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -13444,6 +13444,9 @@ Check your passwords anytime in <ph name
<message name="IDS_EXTENSIONS_INSTALL_LOCATION_SHARED_MODULE" desc="The text explaining the the installation of the extension was because of extensions that depend on this shared module">
Installed because of dependent extension(s).
</message>
+ <message name="IDS_EXTENSIONS_INSTALL_LOCATION_HELIUM" desc="The text explaining the the installation location is a Helium component.">
+ Helium component
+ </message>
<!-- Extension blocklist state -->
<message name="IDS_EXTENSIONS_BLOCKLISTED_MALWARE" desc="The text explaining the reason for disabling extension or app. The extension in question contains malware.">
--- a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
+++ b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
@@ -770,7 +770,10 @@ void ExtensionInfoGenerator::FillExtensi
// Location text.
int location_text = -1;
- if (info.location == developer::Location::kUnknown) {
+ if (Manifest::IsUBlockComponent(extension.id())) {
+ location_text = IDS_EXTENSIONS_INSTALL_LOCATION_HELIUM;
+ info.location = developer::Location::kHeliumComponent;
+ } else if (info.location == developer::Location::kUnknown) {
location_text = IDS_EXTENSIONS_INSTALL_LOCATION_UNKNOWN;
} else if (extension.location() ==
mojom::ManifestLocation::kExternalRegistry) {
--- a/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -239,6 +239,8 @@ content::WebUIDataSource* CreateAndAddEx
{"itemSource", IDS_EXTENSIONS_ITEM_SOURCE},
{"itemSourceInstalledByDefault",
IDS_EXTENSIONS_ITEM_SOURCE_INSTALLED_BY_DEFAULT},
+ {"itemSourceHeliumComponent",
+ IDS_EXTENSIONS_INSTALL_LOCATION_HELIUM},
{"itemSourcePolicy", IDS_EXTENSIONS_ITEM_SOURCE_POLICY},
{"itemSourceSideloaded", IDS_EXTENSIONS_ITEM_SOURCE_SIDELOADED},
{"itemSourceUnpacked", IDS_EXTENSIONS_ITEM_SOURCE_UNPACKED},
--- a/chrome/browser/resources/extensions/item_util.ts
+++ b/chrome/browser/resources/extensions/item_util.ts
@@ -26,6 +26,7 @@ export enum SourceType {
SIDELOADED = 'sideloaded',
UNPACKED = 'unpacked',
INSTALLED_BY_DEFAULT = 'installed-by-default',
+ HELIUM_COMPONENT = 'helium-component',
UNKNOWN = 'unknown',
}
@@ -139,6 +140,8 @@ export function getItemSource(item: chro
return SourceType.WEBSTORE;
case chrome.developerPrivate.Location.INSTALLED_BY_DEFAULT:
return SourceType.INSTALLED_BY_DEFAULT;
+ case chrome.developerPrivate.Location.HELIUM_COMPONENT:
+ return SourceType.HELIUM_COMPONENT;
default:
assertNotReached(item.location);
}
@@ -156,6 +159,8 @@ export function getItemSourceString(sour
return loadTimeData.getString('itemSourceWebstore');
case SourceType.INSTALLED_BY_DEFAULT:
return loadTimeData.getString('itemSourceInstalledByDefault');
+ case SourceType.HELIUM_COMPONENT:
+ return loadTimeData.getString('itemSourceHeliumComponent');
case SourceType.UNKNOWN:
// Nothing to return. Calling code should use
// chrome.developerPrivate.ExtensionInfo's |locationText| instead.
--- a/tools/typescript/definitions/developer_private.d.ts
+++ b/tools/typescript/definitions/developer_private.d.ts
@@ -25,6 +25,7 @@ declare global {
UNPACKED = 'UNPACKED',
THIRD_PARTY = 'THIRD_PARTY',
INSTALLED_BY_DEFAULT = 'INSTALLED_BY_DEFAULT',
+ HELIUM_COMPONENT = 'HELIUM_COMPONENT',
UNKNOWN = 'UNKNOWN',
}
--- a/chrome/browser/resources/extensions/item.css
+++ b/chrome/browser/resources/extensions/item.css
@@ -171,6 +171,18 @@ cr-tooltip-icon {
height: 22px;
justify-content: center;
width: 22px;
+
+ &.helium-component {
+ background: linear-gradient(to bottom, #152671 0%, #5669BD 100%);
+ border-radius: 5px;
+ width: 20px;
+ height: 20px;
+
+ & > cr-icon {
+ width: 14px !important;
+ height: 14px !important;
+ }
+ }
}
#source-indicator cr-icon {
--- a/chrome/browser/resources/extensions/item.ts
+++ b/chrome/browser/resources/extensions/item.ts
@@ -323,6 +323,15 @@ export class ExtensionsItemElement exten
return classes;
}
+ protected computeSourceIndicatorExtraClass_(): string {
+ switch (getItemSource(this.data)) {
+ case SourceType.HELIUM_COMPONENT:
+ return 'helium-component';
+ default:
+ return '';
+ }
+ }
+
protected computeSourceIndicatorIcon_(): string {
switch (getItemSource(this.data)) {
case SourceType.POLICY:
@@ -334,6 +343,8 @@ export class ExtensionsItemElement exten
return 'extensions-icons:input';
case SourceType.UNPACKED:
return 'extensions-icons:unpacked';
+ case SourceType.HELIUM_COMPONENT:
+ return 'cr:chrome-product';
case SourceType.WEBSTORE:
case SourceType.INSTALLED_BY_DEFAULT:
return '';
--- a/chrome/browser/resources/extensions/item.html.ts
+++ b/chrome/browser/resources/extensions/item.html.ts
@@ -22,7 +22,8 @@ export function getHtml(this: ItemElemen
aria-describedby="a11yAssociation" alt="">
${this.computeSourceIndicatorIcon_() ? html`
<div id="source-indicator">
- <div class="source-icon-wrapper" role="img"
+ <div class="source-icon-wrapper ${this.computeSourceIndicatorExtraClass_()}"
+ role="img"
aria-describedby="a11yAssociation"
aria-label="${this.computeSourceIndicatorText_()}">
<cr-icon .icon="${this.computeSourceIndicatorIcon_()}">