// Copyright 2018 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_HASH_H_ #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_CONTENT_HASH_H_ #include <set> #include "base/files/file_path.h" #include "base/functional/callback_helpers.h" #include "base/version.h" #include "extensions/browser/computed_hashes.h" #include "extensions/browser/content_verifier/content_verifier_delegate.h" #include "extensions/browser/content_verifier/content_verifier_key.h" #include "extensions/browser/verified_contents.h" #include "extensions/common/constants.h" #include "extensions/common/extension_id.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" #include "url/gurl.h" namespace extensions { // Represents content verification hashes for an extension. // // Instances can be created using Create() factory method on sequences with // blocking IO access. If hash retrieval succeeds then ContentHash::succeeded() // will return true and // a. ContentHash::verified_contents() will return structured representation of // verified_contents.json // b. ContentHash::computed_hashes() will return structured representation of // computed_hashes.json. // // If verified_contents.json was missing on disk (e.g. because of disk // corruption or such), this class will fetch the file from network. After // fetching the class will parse/validate this data as needed, including // calculating expected hashes for each block of each file within an extension. // (These unsigned leaf node block level hashes will always be checked at time // of use use to make sure they match the signed treehash root hash). // // computed_hashes.json is computed over the files in an extension's directory. // If computed_hashes.json was required to be written to disk and // it was successful, ContentHash::hash_mismatch_unix_paths() will return all // FilePaths from the extension directory that had content verification // mismatch. // // Clients of this class can cancel the disk write operation of // computed_hashes.json while it is ongoing. This is because it can potentially // take long time. This cancellation can be performed through |is_cancelled|. class ContentHash : public base::RefCountedThreadSafe<ContentHash> { … }; } // namespace extensions #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_CONTENT_HASH_H_