app_list: Fix possible out of bounds index.
[chromium-blink-merge.git] / extensions / browser / content_verifier_delegate.h
bloba6b909f43f40958718f872efcfaee2e0e13decbd
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_
8 #include <set>
10 #include "url/gurl.h"
12 namespace base {
13 class FilePath;
14 class Version;
17 namespace extensions {
19 class Extension;
21 // A pointer to the bytes of a public key, and the number of bytes.
22 struct ContentVerifierKey {
23 const uint8* data;
24 int size;
26 ContentVerifierKey(const uint8* data, int size) {
27 this->data = data;
28 this->size = size;
32 // This is an interface for clients that want to use a ContentVerifier.
33 class ContentVerifierDelegate {
34 public:
35 virtual ~ContentVerifierDelegate() {}
37 // This should return true if the given extension should have its content
38 // verified.
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
48 // id/version pair.
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_