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.
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_
12 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h"
15 #include "components/component_updater/default_component_installer.h"
18 class ComponentCldDataHarness;
21 namespace component_updater {
23 class ComponentUpdateService;
25 // Visible for testing. No need to instantiate this class directly.
26 class CldComponentInstallerTraits : public ComponentInstallerTraits {
28 CldComponentInstallerTraits();
29 virtual ~CldComponentInstallerTraits() {}
32 friend class CldComponentInstallerTest; // For access within SetUp()
33 friend class test::ComponentCldDataHarness; // For browser tests only
34 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, ComponentReady);
35 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetBaseDirectory);
36 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetHash);
37 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetInstalledPath);
38 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetName);
39 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, OnCustomInstall);
40 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, SetLatestCldDataFile);
41 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, VerifyInstallation);
43 // The following methods override ComponentInstallerTraits.
44 virtual bool CanAutoUpdate() const OVERRIDE;
45 virtual bool OnCustomInstall(const base::DictionaryValue& manifest,
46 const base::FilePath& install_dir) OVERRIDE;
47 virtual bool VerifyInstallation(
48 const base::FilePath& install_dir) const OVERRIDE;
49 virtual void ComponentReady(
50 const base::Version& version,
51 const base::FilePath& path,
52 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE;
53 virtual base::FilePath GetBaseDirectory() const OVERRIDE;
54 virtual void GetHash(std::vector<uint8_t>* hash) const OVERRIDE;
55 virtual std::string GetName() const OVERRIDE;
57 static base::FilePath GetInstalledPath(const base::FilePath& base);
59 // Sets the path to the CLD data file. Called internally once a valid CLD
60 // data file has been observed. The implementation of this method is
61 // responsible for configuring the CLD data source.
62 // This method is threadsafe.
63 static void SetLatestCldDataFile(const base::FilePath& path);
65 // Returns the file path that was most recently set in SetLatestCldDataFile.
66 static base::FilePath GetLatestCldDataFile();
68 DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits);
71 // Call once during startup to make the component update service aware of
73 void RegisterCldComponent(ComponentUpdateService* cus);
75 } // namespace component_updater
77 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_