pnacl_component_installer.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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 "base/files/file_path.h"
9#include "base/memory/scoped_ptr.h"
10#include "base/version.h"
11#include "chrome/browser/component_updater/component_updater_service.h"
12#include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h"
13
14class CommandLine;
15
16namespace base {
17class DictionaryValue;
18}
19
20// Component installer responsible for Portable Native Client files.
21// Files can be installed to a shared location, or be installed to
22// a per-user location.
23class PnaclComponentInstaller : public ComponentInstaller {
24 public:
25  PnaclComponentInstaller();
26
27  virtual ~PnaclComponentInstaller();
28
29  virtual void OnUpdateError(int error) OVERRIDE;
30
31  virtual bool Install(const base::DictionaryValue& manifest,
32                       const base::FilePath& unpack_path) OVERRIDE;
33
34  // Register a PNaCl component for the first time.
35  void RegisterPnaclComponent(ComponentUpdateService* cus,
36                              const CommandLine& command_line);
37
38  // Check the PNaCl version again and re-register with the component
39  // updater service.
40  void ReRegisterPnacl();
41
42  bool per_user() const { return per_user_; }
43
44  // If per_user, function to call when profile is changed.
45  void OnProfileChange();
46
47  // Determine the base directory for storing each version of PNaCl.
48  base::FilePath GetPnaclBaseDirectory();
49
50  base::Version current_version() const { return current_version_; }
51
52  void set_current_version(const base::Version& v) { current_version_ = v; }
53
54  ComponentUpdateService* cus() const { return cus_; }
55
56 private:
57  bool per_user_;
58  scoped_ptr<PnaclProfileObserver> profile_observer_;
59  base::FilePath current_profile_path_;
60  base::Version current_version_;
61  ComponentUpdateService* cus_;
62  DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
63};
64
65// Returns true if this browser is compatible with the given Pnacl component
66// manifest, with the version specified in the manifest in |version_out|.
67bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest,
68                                 base::Version* version_out);
69
70#endif  // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
71