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