1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_CONTENT_VERIFIER_IO_DATA_H_
#define EXTENSIONS_BROWSER_CONTENT_VERIFIER_CONTENT_VERIFIER_IO_DATA_H_
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include "base/version.h"
#include "extensions/browser/content_verifier/content_verifier_delegate.h"
#include "extensions/browser/content_verifier/content_verifier_utils.h"
#include "extensions/common/extension_id.h"
namespace extensions {
using CanonicalRelativePath = content_verifier_utils::CanonicalRelativePath;
// A helper class for keeping track of data for the ContentVerifier that should
// only be accessed on the IO thread.
class ContentVerifierIOData {
public:
struct ExtensionData {
// The following are all canonical paths within an extension to different
// types of resources.
// Images used in the browser process (such as icons in the toolbar).
std::set<CanonicalRelativePath> canonical_browser_image_paths;
// The extension background page, if any.
std::optional<CanonicalRelativePath> canonical_background_page_path;
// The extension background scripts, if any.
std::set<CanonicalRelativePath> canonical_background_scripts_paths;
// The extension service worker script, if any.
std::optional<CanonicalRelativePath> canonical_service_worker_script_path;
// Content scripts.
std::set<CanonicalRelativePath> canonical_content_scripts_paths;
// Set of indexed ruleset paths used by the Declarative Net Request API.
std::set<CanonicalRelativePath> canonical_indexed_ruleset_paths;
// The version of the extension.
base::Version version;
// The manifest version of the extension.
int manifest_version = 0;
ContentVerifierDelegate::VerifierSourceType source_type;
ExtensionData();
ExtensionData(ExtensionData&&);
ExtensionData& operator=(ExtensionData&&);
ExtensionData(const ExtensionData&) = delete;
ExtensionData& operator=(const ExtensionData&) = delete;
~ExtensionData();
};
ContentVerifierIOData();
ContentVerifierIOData(const ContentVerifierIOData&) = delete;
ContentVerifierIOData& operator=(const ContentVerifierIOData&) = delete;
~ContentVerifierIOData();
void AddData(const ExtensionId& extension_id, ExtensionData data);
void RemoveData(const ExtensionId& extension_id);
void Clear();
// This should be called on the IO thread, and the return value should not
// be retained or used on other threads.
const ExtensionData* GetData(const ExtensionId& extension_id);
private:
std::map<ExtensionId, ExtensionData> data_map_;
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_CONTENT_VERIFIER_IO_DATA_H_
|