Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/component_updater/sth_set_component_installer.h

Issue 1853753003: Certificate Transparency: New component for obtaining fresh STHs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments by sorin & waffles Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
10 #include <string>
11 #include <vector>
12
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "components/component_updater/default_component_installer.h"
16
17 namespace base {
18 class FilePath;
19 class Value;
20 } // namespace base
21
22 namespace net {
23 namespace ct {
24 class STHObserver;
25 } // namespace ct
26 } // namespace net
27
28 namespace component_updater {
29
30 class ComponentUpdateService;
31
32 // Component for receiving Signed Tree Heads updates for Certificate
33 // Transparency logs recognized in Chrome.
34 // The STHs are in JSON format.
35 // To identify the log each STH belongs to, the name of the file is
36 // hex-encoded Log ID of the log that produced this STH.
37 //
38 // Notifications of each of the new STHs are sent to the net::ct::STHObserver,
39 // so that it can take appropriate steps, including possible persistence.
40 class STHSetComponentInstallerTraits : public ComponentInstallerTraits {
41 public:
42 // The |sth_distributor| will be notified each time a new STH is observed.
43 explicit STHSetComponentInstallerTraits(
44 scoped_ptr<net::ct::STHObserver> sth_observer);
45 ~STHSetComponentInstallerTraits() override;
46
47 private:
48 friend class STHSetComponentInstallerTest;
49 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, CanLoadAllSTHs);
50 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest,
51 DoesNotLoadInvalidJSON);
52 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest,
53 DoesNotLoadValidJSONFromFileNotHexEncoded);
Ryan Sleevi 2016/04/07 18:00:13 I will push back on this if any additional prefixe
Eran Messeri 2016/04/07 20:52:54 Actually all those FRIEND_TEST declarations are no
54
55 // The following methods override ComponentInstallerTraits.
Ryan Sleevi 2016/04/07 18:00:13 The (almost canonical) form we've taken, which mat
Eran Messeri 2016/04/07 20:52:54 Done.
56 bool CanAutoUpdate() const override;
57 bool RequiresNetworkEncryption() const override;
58 bool OnCustomInstall(const base::DictionaryValue& manifest,
59 const base::FilePath& install_dir) override;
60 bool VerifyInstallation(const base::DictionaryValue& manifest,
61 const base::FilePath& install_dir) const override;
62 void ComponentReady(const base::Version& version,
63 const base::FilePath& install_dir,
64 scoped_ptr<base::DictionaryValue> manifest) override;
65 base::FilePath GetBaseDirectory() const override;
66 void GetHash(std::vector<uint8_t>* hash) const override;
67 std::string GetName() const override;
68
69 static base::FilePath GetInstalledPath(const base::FilePath& base);
Ryan Sleevi 2016/04/07 18:00:13 A static private is almost always a wrong (excepti
Eran Messeri 2016/04/07 20:52:54 Done.
70
71 // Reads and parses the on-disk json.
72 void LoadSTHsFromDisk(const base::FilePath& sths_file_path,
73 const base::Version& version);
74
75 // Handle successful parsing of JSON by distributing the new STH.
76 void OnJsonParseSuccess(const std::string& log_id,
77 scoped_ptr<base::Value> parsed_json);
78
79 // STH parsing failed - do nothing.
80 void OnJsonParseError(const std::string& log_id, const std::string& error);
81
82 scoped_ptr<net::ct::STHObserver> sth_observer_;
83
84 DISALLOW_COPY_AND_ASSIGN(STHSetComponentInstallerTraits);
85 };
86
87 void RegisterSTHSetComponent(ComponentUpdateService* cus,
88 const base::FilePath& user_data_dir);
89
90 } // namespace component_updater
91
92 #endif // CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698