#include "chrome/browser/ui/safety_hub/notification_permission_review_service.h"
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "base/values.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/safety_hub/safety_hub_service.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/permissions/notifications_engagement_service.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
constexpr char kExcludedKey[] = …;
constexpr char kDisplayedKey[] = …;
constexpr int kDays = …;
int ExtractNotificationCount(ContentSettingPatternSource item,
std::string date) { … }
int GetDailyAverageNotificationCount(ContentSettingPatternSource item) { … }
std::set<std::pair<ContentSettingsPattern, ContentSettingsPattern>>
GetIgnoredPatternPairs(scoped_refptr<HostContentSettingsMap> hcsm) { … }
std::map<std::pair<ContentSettingsPattern, ContentSettingsPattern>, int>
GetNotificationCountMapPerPatternPair(
scoped_refptr<HostContentSettingsMap> hcsm) { … }
}
NotificationPermissions::NotificationPermissions(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
int notification_count)
: … { … }
NotificationPermissions::~NotificationPermissions() = default;
NotificationPermissionsReviewService::NotificationPermissionsResult::
NotificationPermissionsResult() = default;
NotificationPermissionsReviewService::NotificationPermissionsResult::
~NotificationPermissionsResult() = default;
NotificationPermissionsReviewService::NotificationPermissionsResult::
NotificationPermissionsResult(const NotificationPermissionsResult&) =
default;
void NotificationPermissionsReviewService::NotificationPermissionsResult::
AddNotificationPermission(
const NotificationPermissions& notification_permission) { … }
base::Value::List NotificationPermissionsReviewService::
NotificationPermissionsResult::GetSortedListValueForUI() { … }
std::vector<NotificationPermissions> NotificationPermissionsReviewService::
NotificationPermissionsResult::GetSortedNotificationPermissions() { … }
std::set<ContentSettingsPattern> NotificationPermissionsReviewService::
NotificationPermissionsResult::GetOrigins() const { … }
std::unique_ptr<SafetyHubService::Result>
NotificationPermissionsReviewService::NotificationPermissionsResult::Clone()
const { … }
base::Value::Dict NotificationPermissionsReviewService::
NotificationPermissionsResult::ToDictValue() const { … }
bool NotificationPermissionsReviewService::NotificationPermissionsResult::
IsTriggerForMenuNotification() const { … }
bool NotificationPermissionsReviewService::NotificationPermissionsResult::
WarrantsNewMenuNotification(
const base::Value::Dict& previous_result_dict) const { … }
std::u16string NotificationPermissionsReviewService::
NotificationPermissionsResult::GetNotificationString() const { … }
int NotificationPermissionsReviewService::NotificationPermissionsResult::
GetNotificationCommandId() const { … }
NotificationPermissionsReviewService::NotificationPermissionsReviewService(
HostContentSettingsMap* hcsm,
site_engagement::SiteEngagementService* engagement_service)
: … { … }
NotificationPermissionsReviewService::~NotificationPermissionsReviewService() =
default;
void NotificationPermissionsReviewService::OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) { … }
void NotificationPermissionsReviewService::Shutdown() { … }
void NotificationPermissionsReviewService::
AddPatternToNotificationPermissionReviewBlocklist(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern) { … }
void NotificationPermissionsReviewService::
RemovePatternFromNotificationPermissionReviewBlocklist(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern) { … }
std::unique_ptr<SafetyHubService::Result>
NotificationPermissionsReviewService::UpdateOnUIThread(
std::unique_ptr<SafetyHubService::Result> interim_result) { … }
std::unique_ptr<NotificationPermissionsReviewService::Result>
NotificationPermissionsReviewService::GetNotificationPermissions() { … }
base::Value::List NotificationPermissionsReviewService::
PopulateNotificationPermissionReviewData() { … }
void NotificationPermissionsReviewService::SetNotificationPermissionsForOrigin(
std::string origin,
ContentSetting setting) { … }
base::TimeDelta
NotificationPermissionsReviewService::GetRepeatedUpdateInterval() { … }
base::OnceCallback<std::unique_ptr<SafetyHubService::Result>()>
NotificationPermissionsReviewService::GetBackgroundTask() { … }
std::unique_ptr<SafetyHubService::Result>
NotificationPermissionsReviewService::UpdateOnBackgroundThread() { … }
std::unique_ptr<SafetyHubService::Result>
NotificationPermissionsReviewService::InitializeLatestResultImpl() { … }
base::WeakPtr<SafetyHubService>
NotificationPermissionsReviewService::GetAsWeakRef() { … }
bool NotificationPermissionsReviewService::
ShouldAddToNotificationPermissionReviewList(GURL url,
int notification_count) { … }