Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 NET_BASE_FORCE_TLS_STATE_H_ | 5 #ifndef NET_BASE_FORCE_TLS_STATE_H_ |
| 6 #define NET_BASE_FORCE_TLS_STATE_H_ | 6 #define NET_BASE_FORCE_TLS_STATE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/lock.h" | 12 #include "base/lock.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 // ForceTLSState | 18 // ForceTLSState |
| 19 // | 19 // |
| 20 // Tracks which hosts have enabled ForceTLS. After a host enables ForceTLS, | 20 // Tracks which hosts have enabled ForceTLS. After a host enables ForceTLS, |
| 21 // then we refuse to talk to the host over HTTP, treat all certificate errors as | 21 // then we refuse to talk to the host over HTTP, treat all certificate errors as |
| 22 // fatal, and refuses to load any mixed content. | 22 // fatal, and refuses to load any mixed content. |
|
wtc
2009/06/01 17:59:19
Nit: refuses => refuse
abarth-chromium
2009/06/02 02:24:05
Fixed.
| |
| 23 // | 23 // |
| 24 class ForceTLSState { | 24 class ForceTLSState { |
| 25 public: | 25 public: |
| 26 ForceTLSState(); | 26 ForceTLSState(); |
| 27 | 27 |
| 28 // Called when we see an X-Force-TLS header that we should process. Modifies | 28 // Called when we see an X-Force-TLS header that we should process. Modifies |
| 29 // our state as instructed by the header. | 29 // our state as instructed by the header. |
| 30 void DidReceiveHeader(const GURL& url, const std::string& value); | 30 void DidReceiveHeader(const GURL& url, const std::string& value); |
| 31 | 31 |
| 32 // Enable ForceTLS for |host|. | 32 // Enable ForceTLS for |host|. |
| 33 void EnableHost(const std::string& host); | 33 void EnableHost(const std::string& host); |
| 34 | 34 |
| 35 // Returns whether |host| has had ForceTLS enabled. | 35 // Returns whether |host| has had ForceTLS enabled. |
| 36 bool IsEnabledForHost(const std::string& host); | 36 bool IsEnabledForHost(const std::string& host); |
| 37 | 37 |
| 38 // Returns |true| if value parses as a valid X-Force-TLS header value. | |
|
wtc
2009/06/01 17:59:19
Nit: the first "value" should be quoted with ||.
abarth-chromium
2009/06/02 02:24:05
Fixed.
| |
| 39 // The value of max-age and and includeSubDomains are returned in |max_age| | |
|
wtc
2009/06/01 17:59:19
Nit: value => values
Could you include the defini
abarth-chromium
2009/06/02 02:24:05
Fixed.
| |
| 40 // and |include_subdomains|, respectively. The out parameters are not | |
| 41 // modified if the function returns |false|. | |
| 42 static bool ParseHeader(const std::string& value, | |
| 43 int* max_age, | |
| 44 bool* include_subdomains); | |
| 45 | |
| 38 private: | 46 private: |
| 39 // The set of hosts that have enabled ForceTLS. | 47 // The set of hosts that have enabled ForceTLS. |
| 40 std::set<std::string> enabled_hosts_; | 48 std::set<std::string> enabled_hosts_; |
| 41 | 49 |
| 42 // Protect access to our data members with this lock. | 50 // Protect access to our data members with this lock. |
| 43 Lock lock_; | 51 Lock lock_; |
| 44 | 52 |
| 45 DISALLOW_COPY_AND_ASSIGN(ForceTLSState); | 53 DISALLOW_COPY_AND_ASSIGN(ForceTLSState); |
| 46 }; | 54 }; |
| 47 | 55 |
| 48 } // namespace net | 56 } // namespace net |
| 49 | 57 |
| 50 #endif // NET_BASE_FORCE_TLS_STATE_H_ | 58 #endif // NET_BASE_FORCE_TLS_STATE_H_ |
| OLD | NEW |