OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ |
7 | 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
8 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/gtest_prod_util.h" |
| 13 #include "chrome/browser/component_updater/default_component_installer.h" |
9 | 14 |
10 namespace component_updater { | 15 namespace component_updater { |
11 | 16 |
12 class ComponentUpdateService; | 17 class ComponentUpdateService; |
13 | 18 |
| 19 // Visible for testing. No need to instantiate this class directly. |
| 20 class CldComponentInstallerTraits : public ComponentInstallerTraits { |
| 21 public: |
| 22 CldComponentInstallerTraits(); |
| 23 virtual ~CldComponentInstallerTraits() {} |
| 24 |
| 25 private: |
| 26 friend class CldComponentInstallerTest; // For access within SetUp() |
| 27 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, ComponentReady); |
| 28 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetBaseDirectory); |
| 29 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetHash); |
| 30 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetInstalledPath); |
| 31 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetName); |
| 32 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, OnCustomInstall); |
| 33 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, SetLatestCldDataFile); |
| 34 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, VerifyInstallation); |
| 35 |
| 36 // The following methods override ComponentInstallerTraits. |
| 37 virtual bool CanAutoUpdate() const OVERRIDE; |
| 38 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, |
| 39 const base::FilePath& install_dir) OVERRIDE; |
| 40 virtual bool VerifyInstallation( |
| 41 const base::FilePath& install_dir) const OVERRIDE; |
| 42 virtual void ComponentReady( |
| 43 const base::Version& version, |
| 44 const base::FilePath& path, |
| 45 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; |
| 46 virtual base::FilePath GetBaseDirectory() const OVERRIDE; |
| 47 virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE; |
| 48 virtual std::string GetName() const OVERRIDE; |
| 49 |
| 50 base::FilePath GetInstalledPath(const base::FilePath& base) const; |
| 51 void SetLatestCldDataFile(const base::FilePath& path); |
| 52 DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits); |
| 53 }; |
| 54 |
| 55 // Call once during startup to make the component update service aware of |
| 56 // the CLD component. |
14 void RegisterCldComponent(ComponentUpdateService* cus); | 57 void RegisterCldComponent(ComponentUpdateService* cus); |
15 | 58 |
16 // Places the path to the latest CLD data file into the specified path object. | 59 // Returns the path to the latest CLD data file into the specified path object, |
17 // Returns true if and only if the file has been observed to exist at least | 60 // or an empty path if the CLD data file has not been observed yet. |
18 // once and was valid when it was observed; if the function returns false, the | 61 // This function is threadsafe. |
19 // path parameter is not modified. This function is threadsafe. | 62 base::FilePath GetLatestCldDataFile(); |
20 bool GetLatestCldDataFile(base::FilePath* path); | |
21 | 63 |
22 } // namespace component_updater | 64 } // namespace component_updater |
23 | 65 |
24 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ | 66 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ |
OLD | NEW |