1 // Copyright 2016 The Chromium Authors 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 NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRANSPORT_SECURITY_STATE_ENTRY_H_ 6 #define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRANSPORT_SECURITY_STATE_ENTRY_H_ 7 8 #include <map> 9 #include <memory> 10 #include <string> 11 #include <vector> 12 #include "net/tools/huffman_trie/trie_entry.h" 13 14 namespace net::transport_security_state { 15 16 // Maps a name to an index. This is used to track the index of several values 17 // in the C++ code. The trie refers to the array index of the values. For 18 // example; the pinsets are outputted as a C++ array and the index for the 19 // pinset in that array is placed in the trie. 20 using NameIDMap = std::map<std::string, uint32_t>; 21 using NameIDPair = std::pair<std::string, uint32_t>; 22 23 struct TransportSecurityStateEntry { 24 TransportSecurityStateEntry(); 25 ~TransportSecurityStateEntry(); 26 27 std::string hostname; 28 29 bool include_subdomains = false; 30 bool force_https = false; 31 32 bool hpkp_include_subdomains = false; 33 std::string pinset; 34 }; 35 36 using TransportSecurityStateEntries = 37 std::vector<std::unique_ptr<TransportSecurityStateEntry>>; 38 39 class TransportSecurityStateTrieEntry : public huffman_trie::TrieEntry { 40 public: 41 TransportSecurityStateTrieEntry(const NameIDMap& pinsets_map, 42 TransportSecurityStateEntry* entry); 43 ~TransportSecurityStateTrieEntry() override; 44 45 // huffman_trie::TrieEntry: 46 std::string name() const override; 47 bool WriteEntry(huffman_trie::TrieBitBuffer* writer) const override; 48 49 private: 50 const NameIDMap& pinsets_map_; 51 TransportSecurityStateEntry* entry_; 52 }; 53 54 } // namespace net::transport_security_state 55 56 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRANSPORT_SECURITY_STATE_ENTRY_H_ 57