| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
| 6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/version.h" | 17 #include "base/version.h" |
| 18 #include "components/update_client/update_client_errors.h" |
| 18 | 19 |
| 19 // The UpdateClient class is a facade with a simple interface. The interface | 20 // The UpdateClient class is a facade with a simple interface. The interface |
| 20 // exposes a few APIs to install a CRX or update a group of CRXs. | 21 // exposes a few APIs to install a CRX or update a group of CRXs. |
| 21 // | 22 // |
| 22 // The difference between a CRX install and a CRX update is relatively minor. | 23 // The difference between a CRX install and a CRX update is relatively minor. |
| 23 // The terminology going forward will use the word "update" to cover both | 24 // The terminology going forward will use the word "update" to cover both |
| 24 // install and update scenarios, except where details regarding the install | 25 // install and update scenarios, except where details regarding the install |
| 25 // case are relevant. | 26 // case are relevant. |
| 26 // | 27 // |
| 27 // Handling an update consists of a series of actions such as sending an update | 28 // Handling an update consists of a series of actions such as sending an update |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 class Configurator; | 143 class Configurator; |
| 143 enum class Error; | 144 enum class Error; |
| 144 struct CrxUpdateItem; | 145 struct CrxUpdateItem; |
| 145 | 146 |
| 146 // Called when a non-blocking call in this module completes. | 147 // Called when a non-blocking call in this module completes. |
| 147 using Callback = base::Callback<void(Error error)>; | 148 using Callback = base::Callback<void(Error error)>; |
| 148 | 149 |
| 149 // Defines an interface for a generic CRX installer. | 150 // Defines an interface for a generic CRX installer. |
| 150 class CrxInstaller : public base::RefCountedThreadSafe<CrxInstaller> { | 151 class CrxInstaller : public base::RefCountedThreadSafe<CrxInstaller> { |
| 151 public: | 152 public: |
| 153 // Contains the result of the Install operation. |
| 154 struct Result { |
| 155 explicit Result(int error, int extended_error = 0) |
| 156 : error(error), extended_error(extended_error) {} |
| 157 explicit Result(InstallError error, int extended_error = 0) |
| 158 : error(static_cast<int>(error)), extended_error(extended_error) {} |
| 159 int error = 0; // 0 indicates that install has been successful. |
| 160 int extended_error = 0; |
| 161 }; |
| 162 |
| 152 // Called on the main thread when there was a problem unpacking or | 163 // Called on the main thread when there was a problem unpacking or |
| 153 // verifying the CRX. |error| is a non-zero value which is only meaningful | 164 // verifying the CRX. |error| is a non-zero value which is only meaningful |
| 154 // to the caller. | 165 // to the caller. |
| 155 virtual void OnUpdateError(int error) = 0; | 166 virtual void OnUpdateError(int error) = 0; |
| 156 | 167 |
| 157 // Called by the update service when a CRX has been unpacked | 168 // Called by the update service when a CRX has been unpacked |
| 158 // and it is ready to be installed. |manifest| contains the CRX manifest | 169 // and it is ready to be installed. |manifest| contains the CRX manifest |
| 159 // as a json dictionary.|unpack_path| contains the temporary directory | 170 // as a json dictionary.|unpack_path| contains the temporary directory |
| 160 // with all the unpacked CRX files. | 171 // with all the unpacked CRX files. |
| 161 // This method may be called from a thread other than the main thread. | 172 // This method may be called from a thread other than the main thread. |
| 162 virtual bool Install(const base::DictionaryValue& manifest, | 173 virtual Result Install(const base::DictionaryValue& manifest, |
| 163 const base::FilePath& unpack_path) = 0; | 174 const base::FilePath& unpack_path) = 0; |
| 164 | 175 |
| 165 // Sets |installed_file| to the full path to the installed |file|. |file| is | 176 // Sets |installed_file| to the full path to the installed |file|. |file| is |
| 166 // the filename of the file in this CRX. Returns false if this is | 177 // the filename of the file in this CRX. Returns false if this is |
| 167 // not possible (the file has been removed or modified, or its current | 178 // not possible (the file has been removed or modified, or its current |
| 168 // location is unknown). Otherwise, it returns true. | 179 // location is unknown). Otherwise, it returns true. |
| 169 virtual bool GetInstalledFile(const std::string& file, | 180 virtual bool GetInstalledFile(const std::string& file, |
| 170 base::FilePath* installed_file) = 0; | 181 base::FilePath* installed_file) = 0; |
| 171 | 182 |
| 172 // Called when a CRX has been unregistered and all versions should | 183 // Called when a CRX has been unregistered and all versions should |
| 173 // be uninstalled from disk. Returns true if uninstallation is supported, | 184 // be uninstalled from disk. Returns true if uninstallation is supported, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 scoped_refptr<UpdateClient> UpdateClientFactory( | 356 scoped_refptr<UpdateClient> UpdateClientFactory( |
| 346 const scoped_refptr<Configurator>& config); | 357 const scoped_refptr<Configurator>& config); |
| 347 | 358 |
| 348 // This must be called prior to the construction of any Configurator that | 359 // This must be called prior to the construction of any Configurator that |
| 349 // contains a PrefService. | 360 // contains a PrefService. |
| 350 void RegisterPrefs(PrefRegistrySimple* registry); | 361 void RegisterPrefs(PrefRegistrySimple* registry); |
| 351 | 362 |
| 352 } // namespace update_client | 363 } // namespace update_client |
| 353 | 364 |
| 354 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ | 365 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
| OLD | NEW |