1 // 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.
5 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_DELEGATE_H_
6 #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_DELEGATE_H_
17 namespace extensions
{
21 // A pointer to the bytes of a public key, and the number of bytes.
22 struct ContentVerifierKey
{
26 ContentVerifierKey(const uint8
* data
, int size
) {
32 // This is an interface for clients that want to use a ContentVerifier.
33 class ContentVerifierDelegate
{
35 virtual ~ContentVerifierDelegate() {}
37 // This should return true if the given extension should have its content
39 virtual bool ShouldBeVerified(const Extension
& extension
) = 0;
41 // Should return the public key to use for validating signatures via the two
42 // out parameters. NOTE: the pointer returned *must* remain valid for the
43 // lifetime of this object.
44 virtual const ContentVerifierKey
& PublicKey() = 0;
46 // This should return a URL that can be used to fetch the
47 // verified_contents.json containing signatures for the given extension
49 virtual GURL
GetSignatureFetchUrl(const std::string
& extension_id
,
50 const base::Version
& version
) = 0;
52 // This should return the set of file paths for images used within the
53 // browser process. (These may get transcoded during the install process).
54 virtual std::set
<base::FilePath
> GetBrowserImagePaths(
55 const extensions::Extension
* extension
) = 0;
57 // Called when the content verifier detects that a read of a file inside
58 // an extension did not match its expected hash.
59 virtual void VerifyFailed(const std::string
& extension_id
) = 0;
62 } // namespace extensions
64 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_DELEGATE_H_