Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / extensions / updater / extension_cache_impl.h
blobf2ed0fecc22e1868a8c57bbd8abe8c89e5ac9947
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 CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_IMPL_H_
6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_IMPL_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/callback_forward.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "extensions/browser/updater/extension_cache.h"
20 template <typename T> struct DefaultSingletonTraits;
22 namespace extensions {
24 class ExtensionCacheDelegate;
25 class LocalExtensionCache;
27 // Singleton call that caches extensions .crx files to share them between
28 // multiple users and profiles on the machine.
29 class ExtensionCacheImpl : public ExtensionCache,
30 public content::NotificationObserver {
31 public:
32 explicit ExtensionCacheImpl(scoped_ptr<ExtensionCacheDelegate> delegate);
33 ~ExtensionCacheImpl() override;
35 // Implementation of ExtensionCache.
36 void Start(const base::Closure& callback) override;
37 void Shutdown(const base::Closure& callback) override;
38 void AllowCaching(const std::string& id) override;
39 bool GetExtension(const std::string& id,
40 const std::string& expected_hash,
41 base::FilePath* file_path,
42 std::string* version) override;
43 void PutExtension(const std::string& id,
44 const std::string& expected_hash,
45 const base::FilePath& file_path,
46 const std::string& version,
47 const PutExtensionCallback& callback) override;
49 // Implementation of content::NotificationObserver:
50 void Observe(int type,
51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) override;
54 private:
55 // Callback that is called when local cache is ready.
56 void OnCacheInitialized();
58 // Check if this extension is allowed to be cached.
59 bool CachingAllowed(const std::string& id);
61 // Cache implementation that uses local cache dir.
62 scoped_ptr<LocalExtensionCache> cache_;
64 // Set of extensions that can be cached.
65 std::set<std::string> allowed_extensions_;
67 // List of callbacks that should be called when the cache is ready.
68 std::vector<base::Closure> init_callbacks_;
70 // Observes failures to install CRX files.
71 content::NotificationRegistrar notification_registrar_;
73 // Weak factory for callbacks.
74 base::WeakPtrFactory<ExtensionCacheImpl> weak_ptr_factory_;
76 DISALLOW_COPY_AND_ASSIGN(ExtensionCacheImpl);
79 } // namespace extensions
81 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_IMPL_H_