Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_ | |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/files/file_path.h" | |
| 13 #include "base/gtest_prod_util.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/values.h" | |
| 17 #include "components/component_updater/default_component_installer.h" | |
| 18 #include "net/cert/sth_observer.h" | |
| 19 | |
| 20 namespace base { | |
| 21 class FilePath; | |
| 22 class Value; | |
| 23 } // namespace base | |
| 24 | |
| 25 namespace component_updater { | |
| 26 | |
| 27 class ComponentUpdateService; | |
| 28 | |
| 29 // Component for receiving Signed Tree Heads updates for Certificate | |
| 30 // Transparency logs recognized in Chrome. | |
| 31 // The STHs are in JSON format. | |
| 32 // To identify the log each STH belongs to, the name of the file is | |
| 33 // hex-encoded Log ID of the log that produced this STH. | |
| 34 // | |
| 35 // Unlike other components, once STHs are observed they are not placed | |
| 36 // in some global object. Instead, a proxy class provided in the C'tor | |
| 37 // sends notifications for each of the new STHs. | |
| 38 class STHSetComponentInstallerTraits : public ComponentInstallerTraits { | |
| 39 public: | |
| 40 // The |sth_distributor| will be notified each time a new STH is observed. | |
| 41 STHSetComponentInstallerTraits( | |
|
Sorin Jianu
2016/04/04 22:06:12
explicit
| |
| 42 scoped_ptr<net::ct::STHObserver> sth_observer); | |
| 43 ~STHSetComponentInstallerTraits() override; | |
| 44 | |
| 45 private: | |
| 46 friend class STHSetComponentInstallerTest; | |
| 47 | |
| 48 // The following methods override ComponentInstallerTraits. | |
| 49 bool CanAutoUpdate() const override; | |
| 50 bool OnCustomInstall(const base::DictionaryValue& manifest, | |
| 51 const base::FilePath& install_dir) override; | |
| 52 bool VerifyInstallation(const base::DictionaryValue& manifest, | |
| 53 const base::FilePath& install_dir) const override; | |
| 54 void ComponentReady(const base::Version& version, | |
| 55 const base::FilePath& install_dir, | |
| 56 scoped_ptr<base::DictionaryValue> manifest) override; | |
| 57 base::FilePath GetBaseDirectory() const override; | |
| 58 void GetHash(std::vector<uint8_t>* hash) const override; | |
| 59 std::string GetName() const override; | |
| 60 | |
| 61 static base::FilePath GetInstalledPath(const base::FilePath& base); | |
| 62 | |
| 63 // Reads and parses the on-disk json. | |
| 64 void LoadSTHsFromDisk(const base::FilePath& sths_file_path, | |
| 65 const base::Version& version); | |
| 66 | |
| 67 // Handle successful parsing of JSON by distributing the new STH. | |
| 68 void OnJsonParseSuccess(std::string log_id, | |
| 69 scoped_ptr<base::Value> parsed_json); | |
| 70 | |
| 71 // STH parsing failed - do nothing. | |
| 72 void OnJsonParseError(std::string log_id, const std::string& error); | |
| 73 | |
| 74 scoped_ptr<net::ct::STHObserver> sth_observer_; | |
| 75 | |
| 76 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, CanLoadAllSTHs); | |
| 77 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, VerifyInstallation); | |
| 78 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, LoadSTHsFromDisk); | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(STHSetComponentInstallerTraits); | |
| 81 }; | |
| 82 | |
| 83 void RegisterSTHSetComponent( | |
| 84 ComponentUpdateService* cus, | |
| 85 const base::FilePath& user_data_dir, | |
| 86 scoped_ptr<net::ct::STHObserver> sth_observer); | |
| 87 | |
| 88 } // namespace component_updater | |
| 89 | |
| 90 #endif // CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_ | |
| OLD | NEW |