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