pnacl_component_installer.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
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.
4
5#ifndef CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
6#define CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
7
8#include <list>
9#include <string>
10
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 "components/component_updater/component_updater_service.h"
17
18namespace base {
19class DictionaryValue;
20}
21
22namespace pnacl {
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.
29bool NeedsOnDemandUpdate();
30}
31
32namespace component_updater {
33
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.
37class PnaclComponentInstaller : public ComponentInstaller {
38 public:
39  PnaclComponentInstaller();
40
41  virtual ~PnaclComponentInstaller();
42
43  virtual void OnUpdateError(int error) OVERRIDE;
44
45  virtual bool Install(const base::DictionaryValue& manifest,
46                       const base::FilePath& unpack_path) OVERRIDE;
47
48  virtual bool GetInstalledFile(const std::string& file,
49                                base::FilePath* installed_file) OVERRIDE;
50
51  // Register a PNaCl component for the first time.
52  void RegisterPnaclComponent(ComponentUpdateService* cus);
53
54  CrxComponent GetCrxComponent();
55
56  // Determine the base directory for storing each version of PNaCl.
57  base::FilePath GetPnaclBaseDirectory();
58
59  base::Version current_version() const { return current_version_; }
60
61  void set_current_version(const base::Version& current_version) {
62    current_version_ = current_version;
63  }
64
65  std::string current_fingerprint() const { return current_fingerprint_; }
66
67  void set_current_fingerprint(const std::string& current_fingerprint) {
68    current_fingerprint_ = current_fingerprint;
69  }
70
71  ComponentUpdateService* cus() const { return cus_; }
72
73 private:
74  base::Version current_version_;
75  std::string current_fingerprint_;
76  ComponentUpdateService* cus_;
77  DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
78};
79
80}  // namespace component_updater
81
82#endif  // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
83