| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_EV_WHITELIST_COMPONENT_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_EV_WHITELIST_COMPONENT_INSTALLER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_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/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "components/component_updater/default_component_installer.h" | 16 #include "components/component_updater/default_component_installer.h" |
| 17 #include "net/cert/sth_distributor.h" |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class FilePath; | 20 class FilePath; |
| 21 class Value; |
| 19 } // namespace base | 22 } // namespace base |
| 20 | 23 |
| 21 namespace component_updater { | 24 namespace component_updater { |
| 22 | 25 |
| 23 class ComponentUpdateService; | 26 class ComponentUpdateService; |
| 24 | 27 |
| 25 class EVWhitelistComponentInstallerTraits : public ComponentInstallerTraits { | 28 class STHSetComponentInstallerTraits : public ComponentInstallerTraits { |
| 26 public: | 29 public: |
| 27 EVWhitelistComponentInstallerTraits() {} | 30 STHSetComponentInstallerTraits( |
| 28 ~EVWhitelistComponentInstallerTraits() override {} | 31 scoped_ptr<net::ct::STHDistributor> sth_distributor); |
| 32 ~STHSetComponentInstallerTraits() override; |
| 29 | 33 |
| 30 private: | 34 private: |
| 31 // The following methods override ComponentInstallerTraits. | 35 // The following methods override ComponentInstallerTraits. |
| 32 bool CanAutoUpdate() const override; | 36 bool CanAutoUpdate() const override; |
| 33 bool OnCustomInstall(const base::DictionaryValue& manifest, | 37 bool OnCustomInstall(const base::DictionaryValue& manifest, |
| 34 const base::FilePath& install_dir) override; | 38 const base::FilePath& install_dir) override; |
| 35 bool VerifyInstallation(const base::DictionaryValue& manifest, | 39 bool VerifyInstallation(const base::DictionaryValue& manifest, |
| 36 const base::FilePath& install_dir) const override; | 40 const base::FilePath& install_dir) const override; |
| 37 void ComponentReady(const base::Version& version, | 41 void ComponentReady(const base::Version& version, |
| 38 const base::FilePath& install_dir, | 42 const base::FilePath& install_dir, |
| 39 scoped_ptr<base::DictionaryValue> manifest) override; | 43 scoped_ptr<base::DictionaryValue> manifest) override; |
| 40 base::FilePath GetBaseDirectory() const override; | 44 base::FilePath GetBaseDirectory() const override; |
| 41 void GetHash(std::vector<uint8_t>* hash) const override; | 45 void GetHash(std::vector<uint8_t>* hash) const override; |
| 42 std::string GetName() const override; | 46 std::string GetName() const override; |
| 43 | 47 |
| 44 static base::FilePath GetInstalledPath(const base::FilePath& base); | 48 static base::FilePath GetInstalledPath(const base::FilePath& base); |
| 45 | 49 |
| 46 DISALLOW_COPY_AND_ASSIGN(EVWhitelistComponentInstallerTraits); | 50 // Reads and parses the on-disk json. |
| 51 void LoadSTHsFromDisk(const base::FilePath& sths_file_path, |
| 52 const base::Version& version); |
| 53 |
| 54 // Handle successful parsing of JSON by distributing the new STH. |
| 55 void OnJsonParseSuccess(scoped_ptr<base::Value> parsed_json); |
| 56 |
| 57 // STH parsing failed - do nothing. |
| 58 void OnJsonParseError(const std::string& error); |
| 59 |
| 60 scoped_ptr<net::ct::STHDistributor> sth_distributor_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(STHSetComponentInstallerTraits); |
| 47 }; | 63 }; |
| 48 | 64 |
| 49 // Call once during startup to make the component update service aware of | 65 void RegisterSTHSetComponent( |
| 50 // the EV whitelist. | 66 ComponentUpdateService* cus, |
| 51 void RegisterEVWhitelistComponent(ComponentUpdateService* cus, | 67 const base::FilePath& user_data_dir, |
| 52 const base::FilePath& user_data_dir); | 68 scoped_ptr<net::ct::STHDistributor> sth_distributor); |
| 53 | 69 |
| 54 } // namespace component_updater | 70 } // namespace component_updater |
| 55 | 71 |
| 56 #endif // CHROME_BROWSER_COMPONENT_UPDATER_EV_WHITELIST_COMPONENT_INSTALLER_H_ | 72 #endif // CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_ |
| OLD | NEW |