Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: extensions/browser/content_hash_fetcher.h

Issue 288273004: A bunch of remaining parts of extension content verification (Reland) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser test Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/computed_hashes.cc ('k') | extensions/browser/content_hash_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_ 5 #ifndef EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_
6 #define EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_ 6 #define EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_
7 7
8 #include "base/memory/weak_ptr.h"
8 #include "base/scoped_observer.h" 9 #include "base/scoped_observer.h"
9 #include "extensions/browser/content_verifier_delegate.h" 10 #include "extensions/browser/content_verifier_delegate.h"
10 #include "extensions/browser/extension_registry_observer.h" 11 #include "extensions/browser/extension_registry_observer.h"
11 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
12 13
13 namespace content { 14 namespace content {
14 class BrowserContext; 15 class BrowserContext;
15 } 16 }
16 17
17 namespace extensions { 18 namespace extensions {
18 19
19 class ExtensionRegistry; 20 class ExtensionRegistry;
21 class ContentHashFetcherJob;
20 22
21 // This class is responsible for getting signed expected hashes for use in 23 // This class is responsible for getting signed expected hashes for use in
22 // extension content verification. As extensions are loaded it will fetch and 24 // extension content verification. As extensions are loaded it will fetch and
23 // parse/validate/cache this data as needed, including calculating expected 25 // parse/validate/cache this data as needed, including calculating expected
24 // hashes for each block of each file within an extension. (These unsigned leaf 26 // hashes for each block of each file within an extension. (These unsigned leaf
25 // node block level hashes will always be checked at time of use use to make 27 // node block level hashes will always be checked at time of use use to make
26 // sure they match the signed treehash root hash). 28 // sure they match the signed treehash root hash).
27 class ContentHashFetcher : public ExtensionRegistryObserver { 29 class ContentHashFetcher : public ExtensionRegistryObserver {
28 public: 30 public:
29 // The consumer of this class needs to ensure that context and delegate 31 // The consumer of this class needs to ensure that context and delegate
(...skipping 11 matching lines...) Expand all
41 43
42 // ExtensionRegistryObserver interface 44 // ExtensionRegistryObserver interface
43 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, 45 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
44 const Extension* extension) OVERRIDE; 46 const Extension* extension) OVERRIDE;
45 virtual void OnExtensionUnloaded( 47 virtual void OnExtensionUnloaded(
46 content::BrowserContext* browser_context, 48 content::BrowserContext* browser_context,
47 const Extension* extension, 49 const Extension* extension,
48 UnloadedExtensionInfo::Reason reason) OVERRIDE; 50 UnloadedExtensionInfo::Reason reason) OVERRIDE;
49 51
50 private: 52 private:
53 // Callback for when a job getting content hashes has completed.
54 void JobFinished(ContentHashFetcherJob* job);
55
51 content::BrowserContext* context_; 56 content::BrowserContext* context_;
52 ContentVerifierDelegate* delegate_; 57 ContentVerifierDelegate* delegate_;
53 58
59 // We keep around pointers to in-progress jobs, both so we can avoid
60 // scheduling duplicate work if fetching is already in progress, and so that
61 // we can cancel in-progress work at shutdown time.
62 typedef std::pair<ExtensionId, std::string> IdAndVersion;
63 typedef std::map<IdAndVersion, scoped_refptr<ContentHashFetcherJob> > JobMap;
64 JobMap jobs_;
65
54 // For observing the ExtensionRegistry. 66 // For observing the ExtensionRegistry.
55 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> observer_; 67 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> observer_;
56 68
69 // Used for binding callbacks passed to jobs.
70 base::WeakPtrFactory<ContentHashFetcher> weak_ptr_factory_;
71
57 DISALLOW_COPY_AND_ASSIGN(ContentHashFetcher); 72 DISALLOW_COPY_AND_ASSIGN(ContentHashFetcher);
58 }; 73 };
59 74
60 } // namespace extensions 75 } // namespace extensions
61 76
62 #endif // EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_ 77 #endif // EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_
OLDNEW
« no previous file with comments | « extensions/browser/computed_hashes.cc ('k') | extensions/browser/content_hash_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698