chromium/extensions/browser/api/declarative_net_request/action_tracker.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/declarative_net_request/action_tracker.h"

#include <list>
#include <map>
#include <tuple>
#include <utility>

#include "base/time/clock.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "extensions/browser/api/declarative_net_request/request_action.h"
#include "extensions/browser/api/declarative_net_request/rules_monitor_service.h"
#include "extensions/browser/api/declarative_net_request/ruleset_manager.h"
#include "extensions/browser/api/declarative_net_request/utils.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/web_request/web_request_info.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permissions_data.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"

namespace extensions::declarative_net_request {

namespace {

dnr_api;

bool IsMainFrameNavigationRequest(const WebRequestInfo& request_info) {}

// Returns whether a TrackedRule should be recorded on a rule match for the
// extension with the specified |extension_id|.
bool ShouldRecordMatchedRule(content::BrowserContext* browser_context,
                             const ExtensionId& extension_id,
                             int tab_id) {}

const base::Clock* g_test_clock =;

base::Time GetNow() {}

bool g_check_tab_id_on_rule_match =;

// Returns the tab ID to use for tracking a matched rule. Any ID corresponding
// to a tab that no longer exists will be mapped to the unknown tab ID. This is
// similar to when a tab is destroyed, its matched rules are re-mapped to the
// unknown tab ID.
int GetTabIdForMatchedRule(content::BrowserContext* browser_context,
                           int request_tab_id) {}

}  // namespace

// static
constexpr base::TimeDelta ActionTracker::kNonActiveTabRuleLifespan;

ActionTracker::ActionTracker(content::BrowserContext* browser_context)
    :{}

ActionTracker::~ActionTracker() {}

void ActionTracker::SetClockForTests(const base::Clock* clock) {}

void ActionTracker::SetTimerForTest(
    std::unique_ptr<base::RetainingOneShotTimer> injected_trim_rules_timer) {}

void ActionTracker::SetCheckTabIdOnRuleMatchForTest(bool check_tab_id) {}

void ActionTracker::OnRuleMatched(const RequestAction& request_action,
                                  const WebRequestInfo& request_info) {}

void ActionTracker::OnActionCountAsBadgeTextPreferenceEnabled(
    const ExtensionId& extension_id) const {}

void ActionTracker::ClearExtensionData(const ExtensionId& extension_id) {}

void ActionTracker::ClearTabData(int tab_id) {}

void ActionTracker::ClearPendingNavigation(int64_t navigation_id) {}

void ActionTracker::ResetTrackedInfoForTab(int tab_id, int64_t navigation_id) {}

std::vector<dnr_api::MatchedRuleInfo> ActionTracker::GetMatchedRules(
    const Extension& extension,
    const std::optional<int>& tab_id,
    const base::Time& min_time_stamp) {}

int ActionTracker::GetMatchedRuleCountForTest(const ExtensionId& extension_id,
                                              int tab_id,
                                              bool trim_non_active_rules) {}

int ActionTracker::GetPendingRuleCountForTest(const ExtensionId& extension_id,
                                              int64_t navigation_id) {}

void ActionTracker::IncrementActionCountForTab(const ExtensionId& extension_id,
                                               int tab_id,
                                               int increment) {}

template <typename T>
ActionTracker::TrackedInfoContextKey<T>::TrackedInfoContextKey(
    ExtensionId extension_id,
    T secondary_id)
    :{}

template <typename T>
ActionTracker::TrackedInfoContextKey<T>::TrackedInfoContextKey(
    ActionTracker::TrackedInfoContextKey<T>&&) = default;

template <typename T>
ActionTracker::TrackedInfoContextKey<T>&
ActionTracker::TrackedInfoContextKey<T>::operator=(
    ActionTracker::TrackedInfoContextKey<T>&&) = default;

template <typename T>
bool ActionTracker::TrackedInfoContextKey<T>::operator<(
    const TrackedInfoContextKey<T>& other) const {}

ActionTracker::TrackedRule::TrackedRule(int rule_id, RulesetID ruleset_id)
    :{}

ActionTracker::TrackedInfo::TrackedInfo() = default;
ActionTracker::TrackedInfo::~TrackedInfo() = default;
ActionTracker::TrackedInfo::TrackedInfo(ActionTracker::TrackedInfo&&) = default;
ActionTracker::TrackedInfo& ActionTracker::TrackedInfo::operator=(
    ActionTracker::TrackedInfo&&) = default;

void ActionTracker::DispatchOnRuleMatchedDebugIfNeeded(
    const RequestAction& request_action,
    dnr_api::RequestDetails request_details) {}

void ActionTracker::TransferRulesOnTabInvalid(int tab_id) {}

void ActionTracker::TrimRulesFromNonActiveTabs() {}

void ActionTracker::StartTrimRulesTask() {}

dnr_api::MatchedRuleInfo ActionTracker::CreateMatchedRuleInfo(
    const Extension& extension,
    const ActionTracker::TrackedRule& tracked_rule,
    int tab_id) const {}

}  // namespace extensions::declarative_net_request