Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / browser / updater / update_service.h
blob4d19204e1e32cd6f046384462eeed92c4d970b99
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_
6 #define EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "extensions/browser/updater/extension_downloader_delegate.h"
16 namespace content {
17 class BrowserContext;
20 namespace extensions {
22 class ExtensionDownloader;
23 class UpdateServiceFactory;
24 class UpdateServiceTest;
26 // This service manages the download, update, and installation of extensions.
27 // It is currently only used by app_shell, but should eventually replace
28 // ExtensionUpdater in Chrome.
29 // TODO(rockot): Replace ExtensionUpdater with this service.
30 class UpdateService : public KeyedService, public ExtensionDownloaderDelegate {
31 public:
32 static UpdateService* Get(content::BrowserContext* context);
34 // TODO(rockot): Remove this. It's a placeholder for a real service interface.
35 // Downloads and (TODO) installs a CRX within the current browser context.
36 void DownloadAndInstall(const std::string& id,
37 const base::Callback<void(bool)>& callback);
39 private:
40 friend class UpdateServiceFactory;
41 friend class UpdateServiceTest;
43 explicit UpdateService(content::BrowserContext* context);
44 ~UpdateService() override;
46 // ExtensionDownloaderDelegate:
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;
62 content::BrowserContext* browser_context_;
63 scoped_ptr<ExtensionDownloader> downloader_;
64 base::Callback<void(bool)> download_callback_;
66 DISALLOW_COPY_AND_ASSIGN(UpdateService);
69 } // namespace extensions
71 #endif // EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_