chromium/components/permissions/permission_actions_history.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/permissions/permission_actions_history.h"

#include <optional>
#include <string_view>
#include <vector>

#include "base/containers/adapters.h"
#include "base/json/values_util.h"
#include "base/ranges/algorithm.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/pref_names.h"
#include "components/permissions/request_type.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"

namespace permissions {
namespace {

// Inner structure of |prefs::kPermissionActions| containing a history of past
// permission actions. It is a dictionary of JSON lists keyed on the result of
// PermissionUtil::GetPermissionString (lower-cased for backwards compatibility)
// and has the following format:
//
//   "profile.content_settings.permission_actions": {
//      "notifications": [
//       { "time": "1333333333337", "action": 1, "prompt_disposition": 2 },
//       { "time": "1567957177000", "action": 3, "prompt_disposition": 4 },
//     ],
//     "geolocation": [...],
//     ...
//   }
// The "prompt_disposition" key was added in M96. Any older entry will be
// missing that key. The value is backed by the PermissionPromptDisposition
// enum.
constexpr char kPermissionActionEntryActionKey[] =;
constexpr char kPermissionActionEntryTimestampKey[] =;
constexpr char kPermissionActionEntryPromptDispositionKey[] =;

// Entries in permission actions expire after they become this old.
constexpr base::TimeDelta kPermissionActionMaxAge =;

}  // namespace

std::vector<PermissionActionsHistory::Entry>
PermissionActionsHistory::GetHistory(const base::Time& begin,
                                     EntryFilter entry_filter) {}

std::vector<PermissionActionsHistory::Entry>
PermissionActionsHistory::GetHistory(const base::Time& begin,
                                     RequestType type,
                                     EntryFilter entry_filter) {}

void PermissionActionsHistory::RecordAction(
    PermissionAction action,
    RequestType type,
    PermissionPromptDisposition prompt_disposition) {}

void PermissionActionsHistory::ClearHistory(const base::Time& delete_begin,
                                            const base::Time& delete_end) {}

PermissionActionsHistory::PermissionActionsHistory(PrefService* pref_service)
    :{}

std::vector<PermissionActionsHistory::Entry>
PermissionActionsHistory::GetHistoryInternal(const base::Time& begin,
                                             const std::string& key,
                                             EntryFilter entry_filter) {}

PrefService* PermissionActionsHistory::GetPrefServiceForTesting() {}

// static
void PermissionActionsHistory::FillInActionCounts(
    PredictionRequestFeatures::ActionCounts* counts,
    const std::vector<PermissionActionsHistory::Entry>& actions) {}

// static
void PermissionActionsHistory::RegisterProfilePrefs(
    user_prefs::PrefRegistrySyncable* registry) {}

}  // namespace permissions