-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vadym Struts <[email protected]>
- Loading branch information
1 parent
c630105
commit ea63de7
Showing
26 changed files
with
571 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
browser/webcompat_reporter/webcompat_reporter_service_delegate.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/webcompat_reporter/webcompat_reporter_service_delegate.h" | ||
|
||
#include "brave/common/brave_channel_info.h" | ||
#include "brave/components/brave_shields/content/browser/ad_block_service.h" | ||
#include "brave/components/brave_shields/core/browser/ad_block_component_service_manager.h" | ||
#include "brave/components/brave_shields/core/browser/filter_list_catalog_entry.h" | ||
|
||
namespace webcompat_reporter { | ||
|
||
WebcompatReporterServiceDelegateImpl::WebcompatReporterServiceDelegateImpl( | ||
brave_shields::AdBlockService* adblock_service) | ||
: adblock_service_(adblock_service) {} | ||
|
||
WebcompatReporterServiceDelegateImpl::~WebcompatReporterServiceDelegateImpl() = | ||
default; | ||
|
||
std::optional<std::vector<std::string>> | ||
WebcompatReporterServiceDelegateImpl::GetAdblockFilterListNames() const { | ||
if (!adblock_service_) { | ||
return std::nullopt; | ||
} | ||
|
||
std::vector<std::string> ad_block_list_names; | ||
brave_shields::AdBlockComponentServiceManager* service_manager = | ||
adblock_service_->component_service_manager(); | ||
CHECK(service_manager); | ||
for (const brave_shields::FilterListCatalogEntry& entry : | ||
service_manager->GetFilterListCatalog()) { | ||
if (service_manager->IsFilterListEnabled(entry.uuid)) { | ||
ad_block_list_names.push_back(entry.title); | ||
} | ||
} | ||
|
||
if (ad_block_list_names.empty()) { | ||
return std::nullopt; | ||
} | ||
|
||
return ad_block_list_names; | ||
} | ||
|
||
std::string WebcompatReporterServiceDelegateImpl::GetChannelName() const { | ||
return brave::GetChannelName(); | ||
} | ||
} // namespace webcompat_reporter |
41 changes: 41 additions & 0 deletions
41
browser/webcompat_reporter/webcompat_reporter_service_delegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_WEBCOMPAT_REPORTER_WEBCOMPAT_REPORTER_SERVICE_DELEGATE_H_ | ||
#define BRAVE_BROWSER_WEBCOMPAT_REPORTER_WEBCOMPAT_REPORTER_SERVICE_DELEGATE_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "brave/components/webcompat_reporter/browser/webcompat_reporter_service.h" | ||
|
||
namespace brave_shields { | ||
class AdBlockService; | ||
} // namespace brave_shields | ||
|
||
namespace webcompat_reporter { | ||
|
||
class WebcompatReporterServiceDelegateImpl | ||
: public WebcompatReporterService::WebCompatServiceDelegate { | ||
public: | ||
explicit WebcompatReporterServiceDelegateImpl( | ||
brave_shields::AdBlockService* adblock_service); | ||
WebcompatReporterServiceDelegateImpl( | ||
const WebcompatReporterServiceDelegateImpl&) = delete; | ||
WebcompatReporterServiceDelegateImpl& operator=( | ||
const WebcompatReporterServiceDelegateImpl&) = delete; | ||
~WebcompatReporterServiceDelegateImpl() override; | ||
|
||
std::optional<std::vector<std::string>> GetAdblockFilterListNames() | ||
const override; | ||
std::string GetChannelName() const override; | ||
|
||
private: | ||
raw_ptr<brave_shields::AdBlockService> adblock_service_; | ||
}; | ||
|
||
} // namespace webcompat_reporter | ||
|
||
#endif // BRAVE_BROWSER_WEBCOMPAT_REPORTER_WEBCOMPAT_REPORTER_SERVICE_DELEGATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.