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