1 // Copyright (c) 2011 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 CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/version.h"
16 #include "chrome/browser/component_updater/component_updater_service.h"
19 class DictionaryValue;
23 // Returns true if PNaCl actually needs an on-demand component update.
24 // E.g., if PNaCl is not yet installed and the user is loading a PNaCl app,
25 // or the current version is behind chrome's version, and is ABI incompatible
26 // with chrome. If not necessary, returns false.
27 // May conservatively return false before PNaCl is registered, but
28 // should return the right answer after it is registered.
29 bool NeedsOnDemandUpdate();
32 namespace component_updater {
34 // Component installer responsible for Portable Native Client files.
35 // Files can be installed to a shared location, or be installed to
36 // a per-user location.
37 class PnaclComponentInstaller : public ComponentInstaller {
39 PnaclComponentInstaller();
41 virtual ~PnaclComponentInstaller();
43 virtual void OnUpdateError(int error) OVERRIDE;
45 virtual bool Install(const base::DictionaryValue& manifest,
46 const base::FilePath& unpack_path) OVERRIDE;
48 virtual bool GetInstalledFile(const std::string& file,
49 base::FilePath* installed_file) OVERRIDE;
51 // Register a PNaCl component for the first time.
52 void RegisterPnaclComponent(ComponentUpdateService* cus);
54 CrxComponent GetCrxComponent();
56 // Determine the base directory for storing each version of PNaCl.
57 base::FilePath GetPnaclBaseDirectory();
59 base::Version current_version() const { return current_version_; }
61 void set_current_version(const base::Version& current_version) {
62 current_version_ = current_version;
65 std::string current_fingerprint() const { return current_fingerprint_; }
67 void set_current_fingerprint(const std::string& current_fingerprint) {
68 current_fingerprint_ = current_fingerprint;
71 ComponentUpdateService* cus() const { return cus_; }
74 base::Version current_version_;
75 std::string current_fingerprint_;
76 ComponentUpdateService* cus_;
77 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
80 } // namespace component_updater
82 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_