| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 5 #ifndef COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| 6 #define COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 virtual bool SupportsGroupPolicyEnabledComponentUpdates() const = 0; | 51 virtual bool SupportsGroupPolicyEnabledComponentUpdates() const = 0; |
| 52 | 52 |
| 53 // Returns true if the network communication related to this component | 53 // Returns true if the network communication related to this component |
| 54 // must be encrypted. | 54 // must be encrypted. |
| 55 virtual bool RequiresNetworkEncryption() const = 0; | 55 virtual bool RequiresNetworkEncryption() const = 0; |
| 56 | 56 |
| 57 // OnCustomInstall is called during the installation process. Components that | 57 // OnCustomInstall is called during the installation process. Components that |
| 58 // require custom installation operations should implement them here. | 58 // require custom installation operations should implement them here. |
| 59 // Returns false if a custom operation failed, and true otherwise. | 59 // Returns false if a custom operation failed, and true otherwise. |
| 60 // Called only from a thread belonging to a blocking thread pool. | 60 // Called only from a thread belonging to a blocking thread pool. |
| 61 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, | 61 virtual update_client::CrxInstaller::Result OnCustomInstall( |
| 62 const base::FilePath& install_dir) = 0; | 62 const base::DictionaryValue& manifest, |
| 63 const base::FilePath& install_dir) = 0; |
| 63 | 64 |
| 64 // ComponentReady is called in two cases: | 65 // ComponentReady is called in two cases: |
| 65 // 1) After an installation is successfully completed. | 66 // 1) After an installation is successfully completed. |
| 66 // 2) During component registration if the component is already installed. | 67 // 2) During component registration if the component is already installed. |
| 67 // In both cases the install is verified before this is called. This method | 68 // In both cases the install is verified before this is called. This method |
| 68 // is guaranteed to be called before any observers of the component are | 69 // is guaranteed to be called before any observers of the component are |
| 69 // notified of a successful install, and is meant to support follow-on work | 70 // notified of a successful install, and is meant to support follow-on work |
| 70 // such as updating paths elsewhere in Chrome. Called on the UI thread. | 71 // such as updating paths elsewhere in Chrome. Called on the UI thread. |
| 71 // |version| is the version of the component. | 72 // |version| is the version of the component. |
| 72 // |install_dir| is the path to the install directory for this version. | 73 // |install_dir| is the path to the install directory for this version. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 DefaultComponentInstaller( | 109 DefaultComponentInstaller( |
| 109 std::unique_ptr<ComponentInstallerTraits> installer_traits); | 110 std::unique_ptr<ComponentInstallerTraits> installer_traits); |
| 110 | 111 |
| 111 // Registers the component for update checks and installs. | 112 // Registers the component for update checks and installs. |
| 112 // The passed |callback| will be called once the initial check for installed | 113 // The passed |callback| will be called once the initial check for installed |
| 113 // versions is done and the component has been registered. | 114 // versions is done and the component has been registered. |
| 114 void Register(ComponentUpdateService* cus, const base::Closure& callback); | 115 void Register(ComponentUpdateService* cus, const base::Closure& callback); |
| 115 | 116 |
| 116 // Overridden from ComponentInstaller: | 117 // Overridden from ComponentInstaller: |
| 117 void OnUpdateError(int error) override; | 118 void OnUpdateError(int error) override; |
| 118 bool Install(const base::DictionaryValue& manifest, | 119 update_client::CrxInstaller::Result Install( |
| 119 const base::FilePath& unpack_path) override; | 120 const base::DictionaryValue& manifest, |
| 121 const base::FilePath& unpack_path) override; |
| 120 bool GetInstalledFile(const std::string& file, | 122 bool GetInstalledFile(const std::string& file, |
| 121 base::FilePath* installed_file) override; | 123 base::FilePath* installed_file) override; |
| 122 // Only user-level component installations can be uninstalled. | 124 // Only user-level component installations can be uninstalled. |
| 123 bool Uninstall() override; | 125 bool Uninstall() override; |
| 124 | 126 |
| 125 private: | 127 private: |
| 126 ~DefaultComponentInstaller() override; | 128 ~DefaultComponentInstaller() override; |
| 127 | 129 |
| 128 // If there is a installation of the component set up alongside Chrome's | 130 // If there is a installation of the component set up alongside Chrome's |
| 129 // files (as opposed to in the user data directory), sets current_* to the | 131 // files (as opposed to in the user data directory), sets current_* to the |
| 130 // values associated with that installation and returns true; otherwise, | 132 // values associated with that installation and returns true; otherwise, |
| 131 // returns false. | 133 // returns false. |
| 132 bool FindPreinstallation(const base::FilePath& root); | 134 bool FindPreinstallation(const base::FilePath& root); |
| 133 bool InstallHelper(const base::DictionaryValue& manifest, | 135 update_client::CrxInstaller::Result InstallHelper( |
| 134 const base::FilePath& unpack_path, | 136 const base::DictionaryValue& manifest, |
| 135 const base::FilePath& install_path); | 137 const base::FilePath& unpack_path, |
| 138 const base::FilePath& install_path); |
| 136 void StartRegistration(ComponentUpdateService* cus); | 139 void StartRegistration(ComponentUpdateService* cus); |
| 137 void FinishRegistration(ComponentUpdateService* cus, | 140 void FinishRegistration(ComponentUpdateService* cus, |
| 138 const base::Closure& callback); | 141 const base::Closure& callback); |
| 139 void ComponentReady(std::unique_ptr<base::DictionaryValue> manifest); | 142 void ComponentReady(std::unique_ptr<base::DictionaryValue> manifest); |
| 140 void UninstallOnTaskRunner(); | 143 void UninstallOnTaskRunner(); |
| 141 | 144 |
| 142 base::FilePath current_install_dir_; | 145 base::FilePath current_install_dir_; |
| 143 base::Version current_version_; | 146 base::Version current_version_; |
| 144 std::string current_fingerprint_; | 147 std::string current_fingerprint_; |
| 145 std::unique_ptr<base::DictionaryValue> current_manifest_; | 148 std::unique_ptr<base::DictionaryValue> current_manifest_; |
| 146 std::unique_ptr<ComponentInstallerTraits> installer_traits_; | 149 std::unique_ptr<ComponentInstallerTraits> installer_traits_; |
| 147 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 150 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 148 | 151 |
| 149 // Used to post responses back to the main thread. Initialized on the main | 152 // Used to post responses back to the main thread. Initialized on the main |
| 150 // loop but accessed from the task runner. | 153 // loop but accessed from the task runner. |
| 151 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 154 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 152 | 155 |
| 153 base::ThreadChecker thread_checker_; | 156 base::ThreadChecker thread_checker_; |
| 154 | 157 |
| 155 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); | 158 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); |
| 156 }; | 159 }; |
| 157 | 160 |
| 158 } // namespace component_updater | 161 } // namespace component_updater |
| 159 | 162 |
| 160 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 163 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| OLD | NEW |