blob: c24b4fb8d6173f2099e2fdd6aed435e4ef07df0a [file] [log] [blame]
[email protected]6a5898e2014-07-22 23:33:541// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_
6#define EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_
7
8#include <map>
dchengf5d241082016-04-21 03:43:119#include <memory>
[email protected]6a5898e2014-07-22 23:33:5410#include <set>
11#include <string>
12
13#include "base/files/file_path.h"
[email protected]6a5898e2014-07-22 23:33:5414#include "base/memory/ref_counted.h"
[email protected]6a5898e2014-07-22 23:33:5415#include "base/version.h"
Istiaque Ahmed0f709d222020-02-26 22:25:5716#include "extensions/browser/content_verifier/content_verifier_utils.h"
Oleg Davydov39d15482019-11-05 20:19:0617#include "extensions/browser/content_verifier_delegate.h"
[email protected]6a5898e2014-07-22 23:33:5418
19namespace extensions {
20
Istiaque Ahmed0f709d222020-02-26 22:25:5721using CanonicalRelativePath = content_verifier_utils::CanonicalRelativePath;
22
[email protected]6a5898e2014-07-22 23:33:5423// A helper class for keeping track of data for the ContentVerifier that should
24// only be accessed on the IO thread.
Istiaque Ahmede83ff28f2019-07-02 22:48:4725class ContentVerifierIOData {
[email protected]6a5898e2014-07-22 23:33:5426 public:
27 struct ExtensionData {
Istiaque Ahmed0f709d222020-02-26 22:25:5728 // Set of canonical file paths used as images within the browser process.
29 std::unique_ptr<std::set<CanonicalRelativePath>>
30 canonical_browser_image_paths;
31 // Set of canonical file paths used as background scripts, pages or
32 // content scripts.
33 std::unique_ptr<std::set<CanonicalRelativePath>>
34 canonical_background_or_content_paths;
Karandeep Bhatia28cf935c2020-03-19 05:14:4235
36 // Set of indexed ruleset paths used by the Declarative Net Request API.
37 std::unique_ptr<std::set<CanonicalRelativePath>>
38 canonical_indexed_ruleset_paths;
39
[email protected]6a5898e2014-07-22 23:33:5440 base::Version version;
Oleg Davydov39d15482019-11-05 20:19:0641 ContentVerifierDelegate::VerifierSourceType source_type;
[email protected]6a5898e2014-07-22 23:33:5442
Istiaque Ahmed0f709d222020-02-26 22:25:5743 ExtensionData(std::unique_ptr<std::set<CanonicalRelativePath>>
44 canonical_browser_image_paths,
45 std::unique_ptr<std::set<CanonicalRelativePath>>
46 canonical_background_or_content_paths,
Karandeep Bhatia28cf935c2020-03-19 05:14:4247 std::unique_ptr<std::set<CanonicalRelativePath>>
48 canonical_indexed_ruleset_paths,
Istiaque Ahmed0f709d222020-02-26 22:25:5749 const base::Version& version,
50 ContentVerifierDelegate::VerifierSourceType source_type);
[email protected]6a5898e2014-07-22 23:33:5451 ~ExtensionData();
52 };
53
54 ContentVerifierIOData();
Istiaque Ahmede83ff28f2019-07-02 22:48:4755 ~ContentVerifierIOData();
[email protected]6a5898e2014-07-22 23:33:5456
dchengf5d241082016-04-21 03:43:1157 void AddData(const std::string& extension_id,
58 std::unique_ptr<ExtensionData> data);
[email protected]6a5898e2014-07-22 23:33:5459 void RemoveData(const std::string& extension_id);
60 void Clear();
61
62 // This should be called on the IO thread, and the return value should not
63 // be retained or used on other threads.
64 const ExtensionData* GetData(const std::string& extension_id);
65
Istiaque Ahmede83ff28f2019-07-02 22:48:4766 private:
lazyboyf33109d2016-08-31 00:37:0867 std::map<std::string, std::unique_ptr<ExtensionData>> data_map_;
Istiaque Ahmede83ff28f2019-07-02 22:48:4768
69 DISALLOW_COPY_AND_ASSIGN(ContentVerifierIOData);
[email protected]6a5898e2014-07-22 23:33:5470};
71
72} // namespace extensions
73
74#endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_