diff --git a/browser/ui/webui/brave_adblock_ui.cc b/browser/ui/webui/brave_adblock_ui.cc index bd3b23e9b7f..db49ab02b45 100644 --- a/browser/ui/webui/brave_adblock_ui.cc +++ b/browser/ui/webui/brave_adblock_ui.cc @@ -20,13 +20,11 @@ #include "brave/components/brave_shields/browser/ad_block_service_helper.h" #include "brave/components/brave_shields/browser/ad_block_subscription_service_manager.h" #include "brave/components/brave_shields/browser/ad_block_subscription_service_manager_observer.h" -#include "brave/components/brave_shields/common/brave_shield_constants.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/singleton_tabs.h" #include "components/grit/brave_components_resources.h" #include "content/public/browser/web_ui_message_handler.h" -#include "net/base/filename_util.h" namespace { @@ -258,14 +256,9 @@ void AdblockDOMHandler::HandleViewSubscriptionSource( return; } - // TODO(bridiver) - the ui shouldn't have to figure this out - const auto cached_list_path = - g_brave_browser_process->ad_block_service() - ->subscription_service_manager() - ->GetSubscriptionPath(list_url) - .AppendASCII(brave_shields::kCustomSubscriptionListText); - - const GURL file_url = net::FilePathToFileURL(cached_list_path); + const GURL file_url = g_brave_browser_process->ad_block_service() + ->subscription_service_manager() + ->GetListTextFileUrl(list_url); auto* browser = chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); diff --git a/components/brave_shields/browser/ad_block_subscription_service_manager.cc b/components/brave_shields/browser/ad_block_subscription_service_manager.cc index 2345a3f645e..c1b4b7c4434 100644 --- a/components/brave_shields/browser/ad_block_subscription_service_manager.cc +++ b/components/brave_shields/browser/ad_block_subscription_service_manager.cc @@ -21,11 +21,13 @@ #include "brave/components/brave_shields/browser/ad_block_service_helper.h" #include "brave/components/brave_shields/browser/ad_block_subscription_service.h" #include "brave/components/brave_shields/browser/ad_block_subscription_service_manager_observer.h" +#include "brave/components/brave_shields/common/brave_shield_constants.h" #include "brave/components/brave_shields/common/pref_names.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "content/public/browser/browser_task_traits.h" #include "crypto/sha2.h" +#include "net/base/filename_util.h" namespace brave_shields { @@ -85,6 +87,16 @@ base::FilePath AdBlockSubscriptionServiceManager::GetSubscriptionPath( return subscription_path_.AppendASCII(pathsafe_id); } +GURL AdBlockSubscriptionServiceManager::GetListTextFileUrl( + const SubscriptionIdentifier id) const { + base::FilePath cached_list_path = GetSubscriptionPath(id).AppendASCII( + brave_shields::kCustomSubscriptionListText); + + const GURL file_url = net::FilePathToFileURL(cached_list_path); + + return file_url; +} + void AdBlockSubscriptionServiceManager::CreateSubscription( const GURL& list_url) { FilterListSubscriptionInfo info; diff --git a/components/brave_shields/browser/ad_block_subscription_service_manager.h b/components/brave_shields/browser/ad_block_subscription_service_manager.h index 0fd0e5010df..fa70207baa6 100644 --- a/components/brave_shields/browser/ad_block_subscription_service_manager.h +++ b/components/brave_shields/browser/ad_block_subscription_service_manager.h @@ -50,8 +50,14 @@ class AdBlockSubscriptionServiceManager { const base::FilePath& user_data_dir); ~AdBlockSubscriptionServiceManager(); + // Returns the directory used to store cached list data for the given + // subscription. base::FilePath GetSubscriptionPath(const SubscriptionIdentifier id) const; + // Returns a `file://` URL that points directly to the cached list text file + // used for the given subscription. + GURL GetListTextFileUrl(const SubscriptionIdentifier id) const; + std::vector GetSubscriptions() const; void EnableSubscription(const SubscriptionIdentifier& id, bool enabled); void DeleteSubscription(const SubscriptionIdentifier& id);