Chromium Code Reviews| Index: extensions/browser/updater/update_install_shim.h |
| diff --git a/extensions/browser/updater/update_install_shim.h b/extensions/browser/updater/update_install_shim.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..586e94e2167a60a30f7bd80d8d5321d62ba7f7cf |
| --- /dev/null |
| +++ b/extensions/browser/updater/update_install_shim.h |
| @@ -0,0 +1,76 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef EXTENSIONS_BROWSER_UPDATER_UPDATE_INSTALL_SHIM_H_ |
| +#define EXTENSIONS_BROWSER_UPDATER_UPDATE_INSTALL_SHIM_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/files/file_path.h" |
| +#include "components/update_client/update_client.h" |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +} |
| + |
| +namespace extensions { |
| + |
| +// A callback to implement the install of a new version of the extension. |
| +// Takes ownership of the directory at |temp_dir|. |
| +using UpdateInstallShimCallback = |
| + base::Callback<void(const std::string& extension_id, |
| + const base::FilePath& temp_dir)>; |
| + |
| +// This class is used as a shim between the components::update_client and |
| +// extensions code, to help the generic update_client code prepare and then |
| +// install an updated version of an extension. Because the update_client code |
| +// doesn't have the notion of extension ids, we use instances of this class to |
|
Sorin Jianu
2015/10/02 00:05:10
Let's discuss more about this. What is update clie
asargent_no_longer_on_chrome
2015/10/06 21:31:17
The CrxInstaller::Install and CrxInstaller::GetIns
Sorin Jianu
2015/10/08 22:57:54
Correct, we would have to change the interface to
asargent_no_longer_on_chrome
2015/10/14 17:04:31
This seems like a bigger change, so in the interes
Sorin Jianu
2015/10/14 20:37:09
Indeed, I meant to say, we would do the change fro
|
| +// map an install request back to the original update check for a given |
| +// extension. |
| +class UpdateInstallShim : public update_client::CrxInstaller { |
| + public: |
| + // This method takes the id and root directory for an extension we're doing |
| + // an update check for, as well as a callback to call if we get a new version |
| + // of it to install. |
| + UpdateInstallShim(std::string extension_id, |
| + const base::FilePath& extension_root, |
| + const UpdateInstallShimCallback& callback); |
| + |
| + // Called when an update attempt failed. |
| + void OnUpdateError(int error) override; |
| + |
| + // This is called when a new version of an extension is unpacked at |
| + // |unpack_path| and is ready for install. |
| + bool Install(const base::DictionaryValue& manifest, |
| + const base::FilePath& unpack_path) override; |
| + |
| + // This is called by the generic differential update code in the |
| + // update_client to provide the path to an existing file in the current |
| + // version of the extension, so that it can be copied (or serve as the input |
| + // to diff-patching) with output going to the directory with the new version |
| + // being staged on disk for install. |
| + bool GetInstalledFile(const std::string& file, |
| + base::FilePath* installed_file) override; |
| + |
| + // This method is not relevant to extension updating. |
| + bool Uninstall() override; |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<UpdateInstallShim>; |
| + ~UpdateInstallShim() override; |
| + |
| + // Takes ownership of the directory at path |temp_dir|. |
| + void RunCallbackOnUIThread(const base::FilePath& temp_dir); |
| + |
| + std::string extension_id_; |
| + base::FilePath extension_root_; |
| + UpdateInstallShimCallback callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UpdateInstallShim); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_BROWSER_UPDATER_UPDATE_INSTALL_SHIM_H_ |