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