pnacl_component_installer.h revision 0f1bc08d4cfcc34181b0b5cbf065c40f687bf740
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
10#include "base/callback.h"
11#include "base/compiler_specific.h"
12#include "base/files/file_path.h"
13#include "base/memory/scoped_ptr.h"
14#include "base/version.h"
15#include "chrome/browser/component_updater/component_updater_service.h"
16#include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h"
17
18class CommandLine;
19
20namespace base {
21class DictionaryValue;
22}
23
24// Component installer responsible for Portable Native Client files.
25// Files can be installed to a shared location, or be installed to
26// a per-user location.
27class PnaclComponentInstaller : public ComponentInstaller {
28 public:
29  PnaclComponentInstaller();
30
31  virtual ~PnaclComponentInstaller();
32
33  virtual void OnUpdateError(int error) OVERRIDE;
34
35  virtual bool Install(const base::DictionaryValue& manifest,
36                       const base::FilePath& unpack_path) OVERRIDE;
37
38  virtual bool GetInstalledFile(const std::string& file,
39                                base::FilePath* installed_file) OVERRIDE;
40
41  // Register a PNaCl component for the first time.
42  void RegisterPnaclComponent(ComponentUpdateService* cus,
43                              const CommandLine& command_line);
44
45  // Check the PNaCl version again and re-register with the component
46  // updater service.
47  void ReRegisterPnacl();
48
49  CrxComponent GetCrxComponent();
50
51  // Return true if PNaCl installs are separated by user.
52  bool per_user() const { return per_user_; }
53
54  // If per_user, function to call when profile is changed.
55  void OnProfileChange();
56
57  // Return true if PNaCl updates are disabled.
58  bool updates_disabled() const { return updates_disabled_; }
59
60  // Determine the base directory for storing each version of PNaCl.
61  base::FilePath GetPnaclBaseDirectory();
62
63  base::Version current_version() const { return current_version_; }
64
65  void set_current_version(const base::Version& current_version) {
66    current_version_ = current_version;
67  }
68
69  std::string current_fingerprint() const { return current_fingerprint_; }
70
71  void set_current_fingerprint(const std::string& current_fingerprint) {
72    current_fingerprint_ = current_fingerprint;
73  }
74
75  ComponentUpdateService* cus() const { return cus_; }
76
77 private:
78  bool per_user_;
79  bool updates_disabled_;
80  scoped_ptr<PnaclProfileObserver> profile_observer_;
81  base::FilePath current_profile_path_;
82  base::Version current_version_;
83  std::string current_fingerprint_;
84  ComponentUpdateService* cus_;
85  DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
86};
87
88#endif  // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
89