Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_SSL_CHROME_SSL_HOST_STATE_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_SSL_CHROME_SSL_HOST_STATE_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_SSL_CHROME_SSL_HOST_STATE_DELEGATE_H_ | 6 #define CHROME_BROWSER_SSL_CHROME_SSL_HOST_STATE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "content/public/browser/ssl_host_state_delegate.h" | 11 #include "content/public/browser/ssl_host_state_delegate.h" |
| 12 | 12 |
| 13 class Profile; | 13 class Profile; |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class Clock; | 16 class Clock; |
| 17 class DictionaryValue; | 17 class DictionaryValue; |
| 18 } // namespace base | 18 } // namespace base |
| 19 | 19 |
| 20 // Implementation of the tracking of user decisions on SSL errors for sites. | 20 // Implementation of the tracking of user decisions on SSL errors for sites. |
| 21 // Tracks if the user has allowed, denied, or not seen an exception for the | 21 // Tracks if the user has allowed, denied, or not seen an exception for the |
| 22 // specified site, SSL fingerprint, and error. If the user makes a decision, | 22 // specified site, SSL fingerprint, and error. If the user makes a decision, |
| 23 // stores the decision until either the session ends or for a length of time | 23 // stores the decision until either the session ends or for a length of time |
| 24 // (across session restarts), based on command line flags. | 24 // (across session restarts), based on command line flags. |
| 25 class ChromeSSLHostStateDelegate : public content::SSLHostStateDelegate { | 25 class ChromeSSLHostStateDelegate : public content::SSLHostStateDelegate { |
| 26 public: | 26 public: |
| 27 explicit ChromeSSLHostStateDelegate(Profile* profile); | 27 explicit ChromeSSLHostStateDelegate(Profile* profile); |
|
willchan no longer on Chromium
2014/08/20 22:17:21
Not for readability: in general you should prefer
jww
2014/08/22 00:54:17
In this case, we need some pretty beefy stuff from
| |
| 28 virtual ~ChromeSSLHostStateDelegate(); | 28 virtual ~ChromeSSLHostStateDelegate(); |
| 29 | 29 |
| 30 // SSLHostStateDelegate: | 30 // SSLHostStateDelegate: |
| 31 virtual void DenyCert(const std::string& host, | 31 virtual void DenyCert(const std::string& host, |
| 32 net::X509Certificate* cert, | 32 net::X509Certificate* cert, |
| 33 net::CertStatus error) OVERRIDE; | 33 net::CertStatus error) OVERRIDE; |
| 34 virtual void AllowCert(const std::string& host, | 34 virtual void AllowCert(const std::string& host, |
| 35 net::X509Certificate* cert, | 35 net::X509Certificate* cert, |
| 36 net::CertStatus error) OVERRIDE; | 36 net::CertStatus error) OVERRIDE; |
| 37 virtual void Clear() OVERRIDE; | 37 virtual void Clear() OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 48 // ChromeSSLHostStateDelegate implementation: | 48 // ChromeSSLHostStateDelegate implementation: |
| 49 // Revoke all user decisions for |host| in the given Profile. The | 49 // Revoke all user decisions for |host| in the given Profile. The |
| 50 // RevokeUserDecisionsHard version may close idle connections in the process. | 50 // RevokeUserDecisionsHard version may close idle connections in the process. |
| 51 // This version should be used *only* for rare events, such as a user | 51 // This version should be used *only* for rare events, such as a user |
| 52 // controlled button, as it may be very disruptive to the networking stack. | 52 // controlled button, as it may be very disruptive to the networking stack. |
| 53 virtual void RevokeUserDecisions(const std::string& host); | 53 virtual void RevokeUserDecisions(const std::string& host); |
| 54 virtual void RevokeUserDecisionsHard(const std::string& host); | 54 virtual void RevokeUserDecisionsHard(const std::string& host); |
| 55 | 55 |
| 56 // Returns true if any decisions has been recorded for |host| for the given | 56 // Returns true if any decisions has been recorded for |host| for the given |
| 57 // Profile, otherwise false. | 57 // Profile, otherwise false. |
| 58 virtual bool HasUserDecision(const std::string& host); | 58 virtual bool HasUserDecision(const std::string& host); |
|
willchan no longer on Chromium
2014/08/20 22:17:21
This member function reads like it should be const
jww
2014/08/22 00:54:17
Nope, done.
| |
| 59 | 59 |
| 60 // Called on the UI thread when the profile is about to be destroyed. | 60 // Called on the UI thread when the profile is about to be destroyed. |
| 61 void ShutdownOnUIThread() {} | 61 void ShutdownOnUIThread() {} |
|
willchan no longer on Chromium
2014/08/20 22:17:21
Nit: What's up with this? Empty function? Does any
jww
2014/08/22 00:54:17
That was leftover from an initial implementation a
| |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 // SetClock takes ownership of the passed in clock. | 64 // SetClock takes ownership of the passed in clock. |
| 65 void SetClock(scoped_ptr<base::Clock> clock); | 65 void SetClock(scoped_ptr<base::Clock> clock); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 FRIEND_TEST_ALL_PREFIXES(ForgetInstantlySSLHostStateDelegateTest, | 68 FRIEND_TEST_ALL_PREFIXES(ForgetInstantlySSLHostStateDelegateTest, |
| 69 MakeAndForgetException); | 69 MakeAndForgetException); |
| 70 FRIEND_TEST_ALL_PREFIXES(RememberSSLHostStateDelegateTest, AfterRestart); | 70 FRIEND_TEST_ALL_PREFIXES(RememberSSLHostStateDelegateTest, AfterRestart); |
| 71 FRIEND_TEST_ALL_PREFIXES(RememberSSLHostStateDelegateTest, | 71 FRIEND_TEST_ALL_PREFIXES(RememberSSLHostStateDelegateTest, |
| 72 QueryPolicyExpired); | 72 QueryPolicyExpired); |
| 73 | 73 |
| 74 // Used to specify whether new content setting entries should be created if | 74 // Used to specify whether new content setting entries should be created if |
| 75 // they don't already exist when querying the user's settings. | 75 // they don't already exist when querying the user's settings. |
| 76 enum CreateDictionaryEntriesDisposition { | 76 enum CreateDictionaryEntriesDisposition { |
| 77 CreateDictionaryEntries, | 77 CreateDictionaryEntries, |
|
willchan no longer on Chromium
2014/08/20 22:17:22
http://google-styleguide.googlecode.com/svn/trunk/
jww
2014/08/22 00:54:17
Done.
| |
| 78 DoNotCreateDictionaryEntries | 78 DoNotCreateDictionaryEntries |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // Specifies whether user SSL error decisions should be forgetten at the end | 81 // Specifies whether user SSL error decisions should be forgetten at the end |
| 82 // of this current session (the old style of remembering decisions), or | 82 // of this current session (the old style of remembering decisions), or |
| 83 // whether they should be remembered across session restarts for a specified | 83 // whether they should be remembered across session restarts for a specified |
| 84 // length of time, deteremined by | 84 // length of time, deteremined by |
| 85 // |default_ssl_cert_decision_expiration_delta_|. | 85 // |default_ssl_cert_decision_expiration_delta_|. |
| 86 enum RememberSSLExceptionDecisionsDisposition { | 86 enum RememberSSLExceptionDecisionsDisposition { |
| 87 ForgetSSLExceptionDecisionsAtSessionEnd, | 87 ForgetSSLExceptionDecisionsAtSessionEnd, |
| 88 RememberSSLExceptionDecisionsForDelta | 88 RememberSSLExceptionDecisionsForDelta |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // Modify the user's content settings to specify a judgement made for a | 91 // Modify the user's content settings to specify a judgement made for a |
| 92 // specific site and certificate, where |url| is the site in question, |cert| | 92 // specific site and certificate, where |url| is the site in question, |cert| |
| 93 // is the certificate with an error, |error| is the error in the certificate, | 93 // is the certificate with an error, |error| is the error in the certificate, |
| 94 // and |judgement| is the user decision to be recorded. | 94 // and |judgement| is the user decision to be recorded. |
| 95 void ChangeCertPolicy(const std::string& host, | 95 void ChangeCertPolicy(const std::string& host, |
| 96 net::X509Certificate* cert, | 96 net::X509Certificate* cert, |
|
willchan no longer on Chromium
2014/08/20 22:17:21
Is there a reason |cert| isn't a const reference?
jww
2014/08/22 00:54:17
Nope, those can all be const. And, in fact, the in
| |
| 97 net::CertStatus error, | 97 net::CertStatus error, |
| 98 net::CertPolicy::Judgment judgment); | 98 net::CertPolicy::Judgment judgment); |
| 99 | 99 |
| 100 // Query the content settings to retrieve a dictionary of certificate | 100 // Query the content settings to retrieve a dictionary of certificate |
| 101 // fingerprints and errors of certificates to user decisions, as set by | 101 // fingerprints and errors of certificates to user decisions, as set by |
| 102 // ChangeCertPolicy. Returns NULL on a failure. | 102 // ChangeCertPolicy. Returns NULL on a failure. |
| 103 // | 103 // |
| 104 // |dict| specifies the user's full exceptions dictionary for a specific site | 104 // |dict| specifies the user's full exceptions dictionary for a specific site |
| 105 // in their content settings. Must be retrieved directly from a website | 105 // in their content settings. Must be retrieved directly from a website |
| 106 // setting in the the profile's HostContentSettingsMap. | 106 // setting in the the profile's HostContentSettingsMap. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 122 base::TimeDelta default_ssl_cert_decision_expiration_delta_; | 122 base::TimeDelta default_ssl_cert_decision_expiration_delta_; |
| 123 Profile* profile_; | 123 Profile* profile_; |
| 124 | 124 |
| 125 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host | 125 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host |
| 126 // contains insecure content in that renderer process. | 126 // contains insecure content in that renderer process. |
| 127 typedef std::pair<std::string, int> BrokenHostEntry; | 127 typedef std::pair<std::string, int> BrokenHostEntry; |
| 128 | 128 |
| 129 // Hosts which have been contaminated with insecure content in the | 129 // Hosts which have been contaminated with insecure content in the |
| 130 // specified process. Note that insecure content can travel between | 130 // specified process. Note that insecure content can travel between |
| 131 // same-origin frames in one processs but cannot jump between processes. | 131 // same-origin frames in one processs but cannot jump between processes. |
| 132 std::set<BrokenHostEntry> ran_insecure_content_hosts_; | 132 std::set<BrokenHostEntry> ran_insecure_content_hosts_; |
|
willchan no longer on Chromium
2014/08/20 22:17:21
You should #include <set>.
http://google-stylegui
jww
2014/08/22 00:54:17
Done.
| |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(ChromeSSLHostStateDelegate); | 134 DISALLOW_COPY_AND_ASSIGN(ChromeSSLHostStateDelegate); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 #endif // CHROME_BROWSER_SSL_CHROME_SSL_HOST_STATE_DELEGATE_H_ | 137 #endif // CHROME_BROWSER_SSL_CHROME_SSL_HOST_STATE_DELEGATE_H_ |
| 138 | |
| OLD | NEW |