Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / component_updater / pnacl / pnacl_component_installer.h
blob822b0b5f96efa1074ae4cbd9a94c620379c4c9ab
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_
8 #include <list>
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"
18 class CommandLine;
20 namespace base {
21 class DictionaryValue;
24 namespace pnacl {
25 // Returns true if PNaCl actually needs an on-demand component update.
26 // E.g., if PNaCl is not yet installed and the user is loading a PNaCl app,
27 // or the current version is behind chrome's version, and is ABI incompatible
28 // with chrome. If not necessary, returns false.
29 // May conservatively return false before PNaCl is registered, but
30 // should return the right answer after it is registered.
31 bool NeedsOnDemandUpdate();
34 namespace component_updater {
36 // Component installer responsible for Portable Native Client files.
37 // Files can be installed to a shared location, or be installed to
38 // a per-user location.
39 class PnaclComponentInstaller : public ComponentInstaller {
40 public:
41 PnaclComponentInstaller();
43 virtual ~PnaclComponentInstaller();
45 virtual void OnUpdateError(int error) OVERRIDE;
47 virtual bool Install(const base::DictionaryValue& manifest,
48 const base::FilePath& unpack_path) OVERRIDE;
50 virtual bool GetInstalledFile(const std::string& file,
51 base::FilePath* installed_file) OVERRIDE;
53 // Register a PNaCl component for the first time.
54 void RegisterPnaclComponent(ComponentUpdateService* cus,
55 const CommandLine& command_line);
57 // Check the PNaCl version again and re-register with the component
58 // updater service.
59 void ReRegisterPnacl();
61 CrxComponent GetCrxComponent();
63 // Return true if PNaCl installs are separated by user.
64 bool per_user() const { return per_user_; }
66 // If per_user, function to call when profile is changed.
67 void OnProfileChange();
69 // Return true if PNaCl updates are disabled.
70 bool updates_disabled() const { return updates_disabled_; }
72 // Determine the base directory for storing each version of PNaCl.
73 base::FilePath GetPnaclBaseDirectory();
75 base::Version current_version() const { return current_version_; }
77 void set_current_version(const base::Version& current_version) {
78 current_version_ = current_version;
81 std::string current_fingerprint() const { return current_fingerprint_; }
83 void set_current_fingerprint(const std::string& current_fingerprint) {
84 current_fingerprint_ = current_fingerprint;
87 ComponentUpdateService* cus() const { return cus_; }
89 private:
90 bool per_user_;
91 bool updates_disabled_;
92 scoped_ptr<PnaclProfileObserver> profile_observer_;
93 base::FilePath current_profile_path_;
94 base::Version current_version_;
95 std::string current_fingerprint_;
96 ComponentUpdateService* cus_;
97 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
100 } // namespace component_updater
102 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_