cld_component_installer.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1// Copyright 2014 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_CLD_COMPONENT_INSTALLER_H_ 6#define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ 7 8#include <string> 9#include <vector> 10 11#include "base/files/file_path.h" 12#include "base/gtest_prod_util.h" 13#include "chrome/browser/component_updater/default_component_installer.h" 14 15namespace test { 16class ScopedCLDDynamicDataHarness; 17} // namespace test 18 19namespace component_updater { 20 21class ComponentUpdateService; 22 23// Visible for testing. No need to instantiate this class directly. 24class CldComponentInstallerTraits : public ComponentInstallerTraits { 25 public: 26 CldComponentInstallerTraits(); 27 virtual ~CldComponentInstallerTraits() {} 28 29 private: 30 friend class CldComponentInstallerTest; // For access within SetUp() 31 friend class test::ScopedCLDDynamicDataHarness; // For browser tests only 32 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, ComponentReady); 33 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetBaseDirectory); 34 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetHash); 35 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetInstalledPath); 36 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetName); 37 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, OnCustomInstall); 38 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, SetLatestCldDataFile); 39 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, VerifyInstallation); 40 41 // The following methods override ComponentInstallerTraits. 42 virtual bool CanAutoUpdate() const OVERRIDE; 43 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, 44 const base::FilePath& install_dir) OVERRIDE; 45 virtual bool VerifyInstallation( 46 const base::FilePath& install_dir) const OVERRIDE; 47 virtual void ComponentReady( 48 const base::Version& version, 49 const base::FilePath& path, 50 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; 51 virtual base::FilePath GetBaseDirectory() const OVERRIDE; 52 virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE; 53 virtual std::string GetName() const OVERRIDE; 54 55 static base::FilePath GetInstalledPath(const base::FilePath& base); 56 static void SetLatestCldDataFile(const base::FilePath& path); 57 DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits); 58}; 59 60// Call once during startup to make the component update service aware of 61// the CLD component. 62void RegisterCldComponent(ComponentUpdateService* cus); 63 64// Returns the path to the latest CLD data file into the specified path object, 65// or an empty path if the CLD data file has not been observed yet. 66// This function is threadsafe. 67base::FilePath GetLatestCldDataFile(); 68 69} // namespace component_updater 70 71#endif // CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ 72