Chromium Code Reviews| 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 EXTENSIONS_BROWSER_UPDATER_UPDATE_INSTALL_SHIM_H_ | |
| 6 #define EXTENSIONS_BROWSER_UPDATER_UPDATE_INSTALL_SHIM_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/files/file_path.h" | |
| 12 #include "components/update_client/update_client.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class DictionaryValue; | |
| 16 } | |
| 17 | |
| 18 namespace extensions { | |
| 19 | |
| 20 // A callback to implement the install of a new version of the extension. | |
| 21 // Takes ownership of the directory at |temp_dir|. | |
| 22 typedef base::Callback<void(const std::string& /* extension_id */, | |
|
Ken Rockot(use gerrit already)
2015/09/25 16:19:19
nit: new code should use type aliases instead of t
asargent_no_longer_on_chrome
2015/09/29 22:59:21
Thanks for the reminder. Done.
| |
| 23 const base::FilePath& /* temp_dir */)> | |
| 24 UpdateInstallShimCallback; | |
| 25 | |
| 26 // This class is used as a shim between the components::update_client and | |
| 27 // extensions code, to help the generic update_client code prepare and then | |
| 28 // install an updated version of an extension. Because the update_client code | |
| 29 // doesn't have the notion of extension ids, we use instances of this class to | |
| 30 // map an install request back to the original update check for a given | |
| 31 // extension. | |
| 32 class UpdateInstallShim : public update_client::CrxInstaller { | |
| 33 public: | |
| 34 // This method takes the id and root directory for an extension we're doing | |
| 35 // an update check for, as well as a callback to call if we get a new version | |
| 36 // of it to install. | |
| 37 UpdateInstallShim(std::string extension_id, | |
| 38 const base::FilePath& extension_root, | |
| 39 const UpdateInstallShimCallback& callback); | |
| 40 | |
| 41 // Called when an update attempt failed. | |
| 42 void OnUpdateError(int error) override; | |
| 43 | |
| 44 // This is called when a new version of an extension is unpacked at | |
| 45 // |unpack_path| and is ready for install. | |
| 46 bool Install(const base::DictionaryValue& manifest, | |
| 47 const base::FilePath& unpack_path) override; | |
| 48 | |
| 49 // This is called by the generic differential update code in the | |
| 50 // update_client to provide the path to an existing file in the current | |
| 51 // version of the extension, so that it can be copied (or serve as the input | |
| 52 // to diff-patching) with output going to the directory with the new version | |
| 53 // being staged on disk for install. | |
| 54 bool GetInstalledFile(const std::string& file, | |
| 55 base::FilePath* installed_file) override; | |
| 56 | |
| 57 // This method is not relevant to extension updating. | |
| 58 bool Uninstall() override; | |
| 59 | |
| 60 private: | |
| 61 friend class base::RefCountedThreadSafe<UpdateInstallShim>; | |
| 62 ~UpdateInstallShim() override; | |
| 63 | |
| 64 // Takes ownership of the directory at path |temp_dir|. | |
| 65 void RunCallbackOnUIThread(const base::FilePath& temp_dir); | |
| 66 | |
| 67 std::string extension_id_; | |
| 68 base::FilePath extension_root_; | |
| 69 UpdateInstallShimCallback callback_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(UpdateInstallShim); | |
| 72 }; | |
| 73 | |
| 74 } // namespace extensions | |
| 75 | |
| 76 #endif // EXTENSIONS_BROWSER_UPDATER_UPDATE_INSTALL_SHIM_H_ | |
| OLD | NEW |