OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
| 6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/version.h" |
| 13 |
| 14 namespace base { |
| 15 class DictionaryValue; |
| 16 class FilePath; |
| 17 } |
| 18 |
| 19 namespace update_client { |
| 20 |
| 21 // Component specific installers must derive from this class and implement |
| 22 // OnUpdateError() and Install(). A valid instance of this class must be |
| 23 // given to ComponentUpdateService::RegisterComponent(). |
| 24 class ComponentInstaller { |
| 25 public: |
| 26 // Called by the component updater on the main thread when there was a |
| 27 // problem unpacking or verifying the component. |error| is a non-zero |
| 28 // value which is only meaningful to the component updater. |
| 29 virtual void OnUpdateError(int error) = 0; |
| 30 |
| 31 // Called by the component updater when a component has been unpacked |
| 32 // and is ready to be installed. |manifest| contains the CRX manifest |
| 33 // json dictionary and |unpack_path| contains the temporary directory |
| 34 // with all the unpacked CRX files. This method may be called from |
| 35 // a thread other than the main thread. |
| 36 virtual bool Install(const base::DictionaryValue& manifest, |
| 37 const base::FilePath& unpack_path) = 0; |
| 38 |
| 39 // Set |installed_file| to the full path to the installed |file|. |file| is |
| 40 // the filename of the file in this component's CRX. Returns false if this is |
| 41 // not possible (the file has been removed or modified, or its current |
| 42 // location is unknown). Otherwise, returns true. |
| 43 virtual bool GetInstalledFile(const std::string& file, |
| 44 base::FilePath* installed_file) = 0; |
| 45 |
| 46 virtual ~ComponentInstaller() {} |
| 47 }; |
| 48 |
| 49 // Describes a particular component that can be installed or updated. This |
| 50 // structure is required to register a component with the component updater. |
| 51 // |pk_hash| is the SHA256 hash of the component's public key. If the component |
| 52 // is to be installed then version should be "0" or "0.0", else it should be |
| 53 // the current version. |fingerprint|, and |name| are optional. |
| 54 // |allow_background_download| specifies that the component can be background |
| 55 // downloaded in some cases. The default for this value is |true| and the value |
| 56 // can be overriden at the registration time. This is a temporary change until |
| 57 // the issue 340448 is resolved. |
| 58 struct CrxComponent { |
| 59 std::vector<uint8_t> pk_hash; |
| 60 ComponentInstaller* installer; |
| 61 Version version; |
| 62 std::string fingerprint; |
| 63 std::string name; |
| 64 bool allow_background_download; |
| 65 CrxComponent(); |
| 66 ~CrxComponent(); |
| 67 }; |
| 68 |
| 69 } // namespace update_client |
| 70 |
| 71 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
OLD | NEW |