chromium/chrome/browser/extensions/api/browsing_data/browsing_data_api.h

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

// Defines the Chrome Extensions BrowsingData API functions, which entail
// clearing browsing data, and clearing the browser's cache (which, let's be
// honest, are the same thing), as specified in the extension API JSON.

#ifndef CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_

#include <memory>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#include "components/signin/core/browser/account_reconcilor.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/browsing_data_remover.h"
#include "extensions/browser/extension_function.h"

class PrefService;

namespace extension_browsing_data_api_constants {

// Parameter name keys.
inline constexpr char kDataRemovalPermittedKey[] =;
inline constexpr char kDataToRemoveKey[] =;
inline constexpr char kOptionsKey[] =;

// Type keys.
inline constexpr char kCacheKey[] =;
inline constexpr char kCookiesKey[] =;
inline constexpr char kDownloadsKey[] =;
inline constexpr char kFileSystemsKey[] =;
inline constexpr char kFormDataKey[] =;
inline constexpr char kHistoryKey[] =;
inline constexpr char kIndexedDBKey[] =;
inline constexpr char kLocalStorageKey[] =;
inline constexpr char kPasswordsKey[] =;
inline constexpr char kPluginDataKeyDeprecated[] =;
inline constexpr char kServiceWorkersKey[] =;
inline constexpr char kCacheStorageKey[] =;
inline constexpr char kWebSQLKey[] =;

// Option keys.
inline constexpr char kExtensionsKey[] =;
inline constexpr char kOriginTypesKey[] =;
inline constexpr char kProtectedWebKey[] =;
inline constexpr char kSinceKey[] =;
inline constexpr char kOriginsKey[] =;
inline constexpr char kExcludeOriginsKey[] =;
inline constexpr char kUnprotectedWebKey[] =;

// Errors!
// The placeholder will be filled by the name of the affected data type (e.g.,
// "history").
inline constexpr char kBadDataTypeDetails[] =;
inline constexpr char kDeleteProhibitedError[] =;
inline constexpr char kNonFilterableError[] =;
inline constexpr char kIncompatibleFilterError[] =;
inline constexpr char kInvalidOriginError[] =;

}  // namespace extension_browsing_data_api_constants

class BrowsingDataSettingsFunction : public ExtensionFunction {};

// This serves as a base class from which the browsing data API removal
// functions will inherit. Each needs to be an observer of BrowsingDataRemover
// events, and each will handle those events in the same way (by calling the
// passed-in callback function).
//
// Each child class must implement GetRemovalMask(), which returns the bitmask
// of data types to remove.
class BrowsingDataRemoverFunction
    : public ExtensionFunction,
      public content::BrowsingDataRemover::Observer {};

class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveCacheFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveCookiesFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveDownloadsFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveFileSystemsFunction
    : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveFormDataFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveHistoryFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveIndexedDBFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveLocalStorageFunction
    : public BrowsingDataRemoverFunction {};

class BrowsingDataRemovePluginDataFunction
    : public BrowsingDataRemoverFunction {};

class BrowsingDataRemovePasswordsFunction : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveServiceWorkersFunction
    : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveCacheStorageFunction
    : public BrowsingDataRemoverFunction {};

class BrowsingDataRemoveWebSQLFunction : public BrowsingDataRemoverFunction {};

#endif  // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_