diff --git a/ios/browser/api/brave_shields/adblock_service.h b/ios/browser/api/brave_shields/adblock_service.h index 8fa2982e3c84..3a12dd2c3dc5 100644 --- a/ios/browser/api/brave_shields/adblock_service.h +++ b/ios/browser/api/brave_shields/adblock_service.h @@ -44,6 +44,8 @@ OBJC_EXPORT - (instancetype)init NS_UNAVAILABLE; ++ (NSString*)cosmeticFiltersScript; + @end NS_ASSUME_NONNULL_END diff --git a/ios/browser/api/brave_shields/adblock_service.mm b/ios/browser/api/brave_shields/adblock_service.mm index 8105990126ff..6e7d0e77ffd2 100644 --- a/ios/browser/api/brave_shields/adblock_service.mm +++ b/ios/browser/api/brave_shields/adblock_service.mm @@ -19,7 +19,9 @@ #include "brave/ios/browser/api/brave_shields/adblock_filter_list_catalog_entry+private.h" #include "brave/ios/browser/api/brave_shields/adblock_service+private.h" #include "components/component_updater/component_updater_service.h" +#include "components/grit/brave_components_resources.h" #include "ios/chrome/browser/shared/model/application_context/application_context.h" +#include "ui/base/resource/resource_bundle.h" namespace brave_shields { using OnFilterListUpdatedCallback = @@ -201,4 +203,19 @@ - (void)updateFilterLists:(void (^)(bool))callback { _serviceManager->UpdateFilterLists(base::BindOnce(callback)); } ++ (NSString*)cosmeticFiltersScript { + // The resource bundle is not available until after WebMainParts is setup + auto& resource_bundle = ui::ResourceBundle::GetSharedInstance(); + std::string resource_string = ""; + if (resource_bundle.IsGzipped( + IDR_COSMETIC_FILTERS_COSMETIC_FILTERS_CORE_BUNDLE_JS)) { + resource_string = std::string(resource_bundle.LoadDataResourceString( + IDR_COSMETIC_FILTERS_COSMETIC_FILTERS_CORE_BUNDLE_JS)); + } else { + resource_string = std::string(resource_bundle.GetRawDataResource( + IDR_COSMETIC_FILTERS_COSMETIC_FILTERS_CORE_BUNDLE_JS)); + } + return base::SysUTF8ToNSString(resource_string); +} + @end