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. 4 5 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_DELEGATE_H_ 6 #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_DELEGATE_H_ 7 8 #include <set> 9 10 #include "url/gurl.h" 11 12 namespace base { 13 class FilePath; 14 class Version; 15 } 16 17 namespace extensions { 18 19 class Extension; 20 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; 25 26 ContentVerifierKey() : data(NULL), size(0) {} 27 28 ContentVerifierKey(const uint8* data, int size) { 29 this->data = data; 30 this->size = size; 31 } 32 }; 33 34 // This is an interface for clients that want to use a ContentVerifier. 35 class ContentVerifierDelegate { 36 public: 37 virtual ~ContentVerifierDelegate() {} 38 39 // This should return true if the given extension should have its content 40 // verified. 41 virtual bool ShouldBeVerified(const Extension& extension) = 0; 42 43 // Should return the public key to use for validating signatures via the two 44 // out parameters. NOTE: the pointer returned *must* remain valid for the 45 // lifetime of this object. 46 virtual const ContentVerifierKey& PublicKey() = 0; 47 48 // This should return a URL that can be used to fetch the 49 // verified_contents.json containing signatures for the given extension 50 // id/version pair. 51 virtual GURL GetSignatureFetchUrl(const std::string& extension_id, 52 const base::Version& version) = 0; 53 54 // This should return the set of file paths for images used within the 55 // browser process. (These may get transcoded during the install process). 56 virtual std::set<base::FilePath> GetBrowserImagePaths( 57 const extensions::Extension* extension) = 0; 58 59 // Called when the content verifier detects that a read of a file inside 60 // an extension did not match its expected hash. 61 virtual void VerifyFailed(const std::string& extension_id) = 0; 62 }; 63 64 } // namespace extensions 65 66 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_DELEGATE_H_ 67