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> | |
|
Ryan Sleevi
2016/04/06 18:32:51
STYLE: Newline between 8/9 - https://google.github
Eran Messeri
2016/04/07 11:38:03
Done.
| |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/files/file_path.h" | |
|
Ryan Sleevi
2016/04/06 18:32:51
Forward declarable
Eran Messeri
2016/04/07 11:38:03
Done.
| |
| 13 #include "base/gtest_prod_util.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/values.h" | |
|
Ryan Sleevi
2016/04/06 18:32:51
Don't include this if you're forward declaring on
Eran Messeri
2016/04/07 11:38:03
Done.
| |
| 17 #include "components/component_updater/default_component_installer.h" | |
| 18 #include "net/cert/sth_observer.h" | |
|
Ryan Sleevi
2016/04/06 18:32:51
Forward declarable
Eran Messeri
2016/04/07 11:38:03
Done.
| |
| 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 constructor | |
|
Ryan Sleevi
2016/04/06 18:32:51
I would suggest this last sentence is a bit too va
Eran Messeri
2016/04/07 11:38:03
Done.
| |
| 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 explicit STHSetComponentInstallerTraits( | |
| 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 RequiresNetworkEncryption() const override; | |
| 51 bool OnCustomInstall(const base::DictionaryValue& manifest, | |
| 52 const base::FilePath& install_dir) override; | |
| 53 bool VerifyInstallation(const base::DictionaryValue& manifest, | |
| 54 const base::FilePath& install_dir) const override; | |
| 55 void ComponentReady(const base::Version& version, | |
| 56 const base::FilePath& install_dir, | |
| 57 scoped_ptr<base::DictionaryValue> manifest) override; | |
| 58 base::FilePath GetBaseDirectory() const override; | |
| 59 void GetHash(std::vector<uint8_t>* hash) const override; | |
| 60 std::string GetName() const override; | |
| 61 | |
| 62 static base::FilePath GetInstalledPath(const base::FilePath& base); | |
| 63 | |
| 64 // Reads and parses the on-disk json. | |
| 65 void LoadSTHsFromDisk(const base::FilePath& sths_file_path, | |
| 66 const base::Version& version); | |
| 67 | |
| 68 // Handle successful parsing of JSON by distributing the new STH. | |
| 69 void OnJsonParseSuccess(std::string log_id, | |
| 70 scoped_ptr<base::Value> parsed_json); | |
| 71 | |
| 72 // STH parsing failed - do nothing. | |
| 73 void OnJsonParseError(std::string log_id, const std::string& error); | |
| 74 | |
| 75 scoped_ptr<net::ct::STHObserver> sth_observer_; | |
| 76 | |
| 77 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, CanLoadAllSTHs); | |
| 78 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, VerifyInstallation); | |
| 79 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, LoadSTHsFromDisk); | |
|
Ryan Sleevi
2016/04/06 18:32:51
Could you place this at the start of the "private"
Eran Messeri
2016/04/07 11:38:03
Done - moved that and removed the 'friend class ST
| |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(STHSetComponentInstallerTraits); | |
| 82 }; | |
| 83 | |
| 84 void RegisterSTHSetComponent(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 |