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 EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_ | 5 #ifndef EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_ |
6 #define EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_ | 6 #define EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
14 #include "extensions/browser/updater/extension_downloader_delegate.h" | |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class BrowserContext; | 17 class BrowserContext; |
18 } | 18 } |
19 | 19 |
20 namespace update_client { | |
21 class UpdateClient; | |
22 } | |
23 | |
20 namespace extensions { | 24 namespace extensions { |
21 | 25 |
22 class ExtensionDownloader; | 26 class UpdateClientConfig; |
27 class UpdateDataProvider; | |
28 class UpdateService; | |
23 class UpdateServiceFactory; | 29 class UpdateServiceFactory; |
24 class UpdateServiceTest; | |
25 | 30 |
26 // This service manages the download, update, and installation of extensions. | 31 // This service manages the autoupdate of extensions. It should eventually |
27 // It is currently only used by app_shell, but should eventually replace | 32 // replace ExtensionUpdater in Chrome. |
Sorin Jianu
2015/10/02 00:05:10
I understand this is the new extension updater? Th
asargent_no_longer_on_chrome
2015/10/06 21:31:17
Right, in subsequent CL's I'll actually be using t
| |
28 // ExtensionUpdater in Chrome. | |
29 // TODO(rockot): Replace ExtensionUpdater with this service. | 33 // TODO(rockot): Replace ExtensionUpdater with this service. |
30 class UpdateService : public KeyedService, public ExtensionDownloaderDelegate { | 34 class UpdateService : public KeyedService { |
31 public: | 35 public: |
32 static UpdateService* Get(content::BrowserContext* context); | 36 static UpdateService* Get(content::BrowserContext* context); |
33 | 37 |
34 // TODO(rockot): Remove this. It's a placeholder for a real service interface. | 38 void Shutdown() override; |
35 // Downloads and (TODO) installs a CRX within the current browser context. | 39 |
36 void DownloadAndInstall(const std::string& id, | 40 // Starts an update check for each of |extension_ids|. If there are any |
37 const base::Callback<void(bool)>& callback); | 41 // updates available, they will be downloaded, checked for integrity, |
42 // unpacked, and then passed off to the ExtensionSystem::InstallUpdate method | |
43 // for install completion. | |
44 void StartUpdateCheck(std::vector<std::string> extension_ids); | |
38 | 45 |
39 private: | 46 private: |
40 friend class UpdateServiceFactory; | 47 friend class UpdateServiceFactory; |
41 friend class UpdateServiceTest; | |
42 | 48 |
43 explicit UpdateService(content::BrowserContext* context); | 49 UpdateService(content::BrowserContext* context, |
50 scoped_refptr<update_client::UpdateClient> update_client); | |
44 ~UpdateService() override; | 51 ~UpdateService() override; |
45 | 52 |
46 // ExtensionDownloaderDelegate: | 53 content::BrowserContext* context_; |
47 void OnExtensionDownloadFailed(const std::string& id, | |
48 Error error, | |
49 const PingResult& ping, | |
50 const std::set<int>& request_ids) override; | |
51 void OnExtensionDownloadFinished(const CRXFileInfo& file, | |
52 bool file_ownership_passed, | |
53 const GURL& download_url, | |
54 const std::string& version, | |
55 const PingResult& ping, | |
56 const std::set<int>& request_id, | |
57 const InstallCallback& callback) override; | |
58 bool IsExtensionPending(const std::string& id) override; | |
59 bool GetExtensionExistingVersion(const std::string& id, | |
60 std::string* version) override; | |
61 | 54 |
62 content::BrowserContext* browser_context_; | 55 scoped_refptr<update_client::UpdateClient> update_client_; |
63 scoped_ptr<ExtensionDownloader> downloader_; | 56 scoped_refptr<UpdateDataProvider> update_data_provider_; |
64 base::Callback<void(bool)> download_callback_; | |
65 | 57 |
66 DISALLOW_COPY_AND_ASSIGN(UpdateService); | 58 DISALLOW_COPY_AND_ASSIGN(UpdateService); |
67 }; | 59 }; |
68 | 60 |
69 } // namespace extensions | 61 } // namespace extensions |
70 | 62 |
71 #endif // EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_ | 63 #endif // EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_ |
OLD | NEW |