pnacl_component_installer.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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 24namespace 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. 31bool NeedsOnDemandUpdate(); 32} 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 const CommandLine& command_line); 54 55 // Check the PNaCl version again and re-register with the component 56 // updater service. 57 void ReRegisterPnacl(); 58 59 CrxComponent GetCrxComponent(); 60 61 // Return true if PNaCl installs are separated by user. 62 bool per_user() const { return per_user_; } 63 64 // If per_user, function to call when profile is changed. 65 void OnProfileChange(); 66 67 // Return true if PNaCl updates are disabled. 68 bool updates_disabled() const { return updates_disabled_; } 69 70 // Determine the base directory for storing each version of PNaCl. 71 base::FilePath GetPnaclBaseDirectory(); 72 73 base::Version current_version() const { return current_version_; } 74 75 void set_current_version(const base::Version& current_version) { 76 current_version_ = current_version; 77 } 78 79 std::string current_fingerprint() const { return current_fingerprint_; } 80 81 void set_current_fingerprint(const std::string& current_fingerprint) { 82 current_fingerprint_ = current_fingerprint; 83 } 84 85 ComponentUpdateService* cus() const { return cus_; } 86 87 private: 88 bool per_user_; 89 bool updates_disabled_; 90 scoped_ptr<PnaclProfileObserver> profile_observer_; 91 base::FilePath current_profile_path_; 92 base::Version current_version_; 93 std::string current_fingerprint_; 94 ComponentUpdateService* cus_; 95 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller); 96}; 97 98#endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ 99