| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/version.h" | 13 #include "base/version.h" |
| 14 #include "chrome/browser/component_updater/component_updater_service.h" | 14 #include "chrome/browser/component_updater/component_updater_service.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class DictionaryValue; | 17 class DictionaryValue; |
| 18 class FilePath; | 18 class FilePath; |
| 19 } // namespace base | 19 } // namespace base |
| 20 | 20 |
| 21 // Components should use a DefaultComponentInstaller by defining a class that | 21 // Components should use a DefaultComponentInstaller by defining a class that |
| 22 // implements the members of ComponentInstallerTraits, and then registering a | 22 // implements the members of ComponentInstallerTraits, and then registering a |
| 23 // DefaultComponentInstaller that has been constructed with an instance of that | 23 // DefaultComponentInstaller that has been constructed with an instance of that |
| 24 // class. | 24 // class. |
| 25 class ComponentInstallerTraits { | 25 class ComponentInstallerTraits { |
| 26 public: | 26 public: |
| 27 virtual ~ComponentInstallerTraits() {} | 27 virtual ~ComponentInstallerTraits(); |
| 28 | 28 |
| 29 // Verifies that a working installation resides within the directory specified | 29 // Verifies that a working installation resides within the directory specified |
| 30 // by |dir|. |dir| is of the form <base directory>/<version>. | 30 // by |dir|. |dir| is of the form <base directory>/<version>. |
| 31 virtual bool VerifyInstallation(const base::FilePath& dir) const = 0; | 31 virtual bool VerifyInstallation(const base::FilePath& dir) const = 0; |
| 32 | 32 |
| 33 // Returns true if the component can be automatically updated. Called once | 33 // Returns true if the component can be automatically updated. Called once |
| 34 // during component registration from the UI thread. | 34 // during component registration from the UI thread. |
| 35 virtual bool CanAutoUpdate() const = 0; | 35 virtual bool CanAutoUpdate() const = 0; |
| 36 | 36 |
| 37 // OnCustomInstall is called during the installation process. Components that | 37 // OnCustomInstall is called during the installation process. Components that |
| 38 // require custom installation operations should implement them here. | 38 // require custom installation operations should implement them here. |
| 39 // Returns false if a custom operation failed, and true otherwise. | 39 // Returns false if a custom operation failed, and true otherwise. |
| 40 // Called only from the FILE thread. | 40 // Called only from the FILE thread. |
| 41 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, | 41 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, |
| 42 const base::FilePath& install_dir) = 0; | 42 const base::FilePath& install_dir) = 0; |
| 43 | 43 |
| 44 // ComponentReady is called in two cases: | 44 // ComponentReady is called in two cases: |
| 45 // 1) After an installation is successfully completed. | 45 // 1) After an installation is successfully completed. |
| 46 // 2) During component registration if the component is already installed. | 46 // 2) During component registration if the component is already installed. |
| 47 // In both cases the install is verified before this is called. This method | 47 // In both cases the install is verified before this is called. This method |
| 48 // is guaranteed to be called before any observers of the component are | 48 // is guaranteed to be called before any observers of the component are |
| 49 // notified of a successful install, and is meant to support follow-on work | 49 // notified of a successful install, and is meant to support follow-on work |
| 50 // such as updating paths elsewhere in Chrome. Called only from the FILE | 50 // such as updating paths elsewhere in Chrome. Called only from the FILE |
| 51 // thread. | 51 // thread. |
| 52 // |version| is the version of the component, while |path| is the path to the | 52 // |version| is the version of the component. |
| 53 // install directory. | 53 // |manifest| is the manifest for this version of the component. |
| 54 virtual void ComponentReady(const base::Version& version, | 54 // |install_dir| is the path to the install directory for this version. |
| 55 const base::FilePath& install_dir) = 0; | 55 virtual void ComponentReady( |
| 56 const base::Version& version, |
| 57 const base::FilePath& install_dir, |
| 58 scoped_ptr<base::DictionaryValue> manifest) = 0; |
| 56 | 59 |
| 57 // Returns the directory that the installer will place versioned installs of | 60 // Returns the directory that the installer will place versioned installs of |
| 58 // the component into. | 61 // the component into. |
| 59 virtual base::FilePath GetBaseDirectory() const = 0; | 62 virtual base::FilePath GetBaseDirectory() const = 0; |
| 60 | 63 |
| 61 // Returns the component's SHA2 hash as raw bytes. | 64 // Returns the component's SHA2 hash as raw bytes. |
| 62 virtual void GetHash(std::vector<uint8>* hash) const = 0; | 65 virtual void GetHash(std::vector<uint8>* hash) const = 0; |
| 63 | 66 |
| 64 // Returns the human-readable name of the component. | 67 // Returns the human-readable name of the component. |
| 65 virtual std::string GetName() const = 0; | 68 virtual std::string GetName() const = 0; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 private: | 91 private: |
| 89 base::FilePath GetInstallDirectory(); | 92 base::FilePath GetInstallDirectory(); |
| 90 bool InstallHelper(const base::DictionaryValue& manifest, | 93 bool InstallHelper(const base::DictionaryValue& manifest, |
| 91 const base::FilePath& unpack_path, | 94 const base::FilePath& unpack_path, |
| 92 const base::FilePath& install_path); | 95 const base::FilePath& install_path); |
| 93 void StartRegistration(ComponentUpdateService* cus); | 96 void StartRegistration(ComponentUpdateService* cus); |
| 94 void FinishRegistration(ComponentUpdateService* cus); | 97 void FinishRegistration(ComponentUpdateService* cus); |
| 95 | 98 |
| 96 base::Version current_version_; | 99 base::Version current_version_; |
| 97 std::string current_fingerprint_; | 100 std::string current_fingerprint_; |
| 101 scoped_ptr<base::DictionaryValue> current_manifest_; |
| 98 scoped_ptr<ComponentInstallerTraits> installer_traits_; | 102 scoped_ptr<ComponentInstallerTraits> installer_traits_; |
| 99 | 103 |
| 100 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); | 104 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 #endif // CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 107 #endif // CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| OLD | NEW |