| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // The ExternalCache manages a cache for external extensions. | 37 // The ExternalCache manages a cache for external extensions. |
| 38 class ExternalCache : public content::NotificationObserver, | 38 class ExternalCache : public content::NotificationObserver, |
| 39 public extensions::ExtensionDownloaderDelegate { | 39 public extensions::ExtensionDownloaderDelegate { |
| 40 public: | 40 public: |
| 41 class Delegate { | 41 class Delegate { |
| 42 public: | 42 public: |
| 43 virtual ~Delegate() {} | 43 virtual ~Delegate() {} |
| 44 // Caller owns |prefs|. | 44 // Caller owns |prefs|. |
| 45 virtual void OnExtensionListsUpdated( | 45 virtual void OnExtensionListsUpdated( |
| 46 const base::DictionaryValue* prefs) = 0; | 46 const base::DictionaryValue* prefs) = 0; |
| 47 // Called after extension with |id| is loaded in cache. |
| 48 virtual void OnExtensionLoadedInCache(const std::string& id) {} |
| 49 // Called when extension with |id| is failed with downloading for |error|. |
| 50 virtual void OnExtensionDownloadFailed( |
| 51 const std::string& id, |
| 52 extensions::ExtensionDownloaderDelegate::Error error) {} |
| 47 | 53 |
| 48 // Cache needs to provide already installed extensions otherwise they | 54 // Cache needs to provide already installed extensions otherwise they |
| 49 // will be removed. Cache calls this function to get version of installed | 55 // will be removed. Cache calls this function to get version of installed |
| 50 // extension or empty string if not installed. | 56 // extension or empty string if not installed. |
| 51 virtual std::string GetInstalledExtensionVersion(const std::string& id); | 57 virtual std::string GetInstalledExtensionVersion(const std::string& id); |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 // The |request_context| is used for update checks. All file I/O is done via | 60 // The |request_context| is used for update checks. All file I/O is done via |
| 55 // the |backend_task_runner|. If |always_check_updates| is |false|, update | 61 // the |backend_task_runner|. If |always_check_updates| is |false|, update |
| 56 // checks are performed for extensions that have an |external_update_url| | 62 // checks are performed for extensions that have an |external_update_url| |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 109 |
| 104 // Replace the list of extensions to cache with |prefs| and perform update | 110 // Replace the list of extensions to cache with |prefs| and perform update |
| 105 // checks for these. | 111 // checks for these. |
| 106 void UpdateExtensionsList(scoped_ptr<base::DictionaryValue> prefs); | 112 void UpdateExtensionsList(scoped_ptr<base::DictionaryValue> prefs); |
| 107 | 113 |
| 108 // If a user of one of the ExternalCache's extensions detects that | 114 // If a user of one of the ExternalCache's extensions detects that |
| 109 // the extension is damaged then this method can be used to remove it from | 115 // the extension is damaged then this method can be used to remove it from |
| 110 // the cache and retry to download it after a restart. | 116 // the cache and retry to download it after a restart. |
| 111 void OnDamagedFileDetected(const base::FilePath& path); | 117 void OnDamagedFileDetected(const base::FilePath& path); |
| 112 | 118 |
| 119 // Removes extensions listed in |ids| from external cache, corresponding crx |
| 120 // files will be removed from disk too. |
| 121 void RemoveExtensions(const std::vector<std::string>& ids); |
| 122 |
| 113 private: | 123 private: |
| 114 // Notifies the that the cache has been updated, providing | 124 // Notifies the that the cache has been updated, providing |
| 115 // extensions loader with an updated list of extensions. | 125 // extensions loader with an updated list of extensions. |
| 116 void UpdateExtensionLoader(); | 126 void UpdateExtensionLoader(); |
| 117 | 127 |
| 118 // Checks the cache contents and initiate download if needed. | 128 // Checks the cache contents and initiate download if needed. |
| 119 void CheckCache(); | 129 void CheckCache(); |
| 120 | 130 |
| 121 // Invoked on the UI thread when a new entry has been installed in the cache. | 131 // Invoked on the UI thread when a new entry has been installed in the cache. |
| 122 void OnPutExtension(const std::string& id, | 132 void OnPutExtension(const std::string& id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 165 |
| 156 // Weak factory for callbacks. | 166 // Weak factory for callbacks. |
| 157 base::WeakPtrFactory<ExternalCache> weak_ptr_factory_; | 167 base::WeakPtrFactory<ExternalCache> weak_ptr_factory_; |
| 158 | 168 |
| 159 DISALLOW_COPY_AND_ASSIGN(ExternalCache); | 169 DISALLOW_COPY_AND_ASSIGN(ExternalCache); |
| 160 }; | 170 }; |
| 161 | 171 |
| 162 } // namespace chromeos | 172 } // namespace chromeos |
| 163 | 173 |
| 164 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ | 174 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ |
| OLD | NEW |