Index: components/certificate_transparency/ct_policy_manager.h |
diff --git a/components/certificate_transparency/ct_policy_manager.h b/components/certificate_transparency/ct_policy_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..25a681801087886c94c71156b1c727e109890fca |
--- /dev/null |
+++ b/components/certificate_transparency/ct_policy_manager.h |
@@ -0,0 +1,67 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_CT_POLICY_MANAGER_H_ |
+#define COMPONENTS_CERTIFICATE_TRANSPARENCY_CT_POLICY_MANAGER_H_ |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
+#include "components/prefs/pref_change_registrar.h" |
+#include "net/http/transport_security_state.h" |
+ |
+namespace base { |
+class SequencedTaskRunner; |
mmenke
2016/06/27 22:11:57
Should this be included explicitly? Seems like CT
Ryan Sleevi
2016/06/27 22:49:19
It doesn't need to be (only at call-site; you can
|
+} // base |
+ |
+namespace user_prefs { |
+class PrefRegistrySyncable; |
+} // user_prefs |
+ |
+namespace certificate_transparency { |
+ |
+class CTPolicyManager { |
mmenke
2016/06/27 22:11:57
Should document this class, and its lifetime and t
Ryan Sleevi
2016/06/27 22:49:19
Yeah; it's created on UI, shut down on UI, deleted
|
+ public: |
+ // Registers the preferences related to Certificate Transparency policy |
+ // in the given pref registry. |
+ static void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry); |
+ |
+ explicit CTPolicyManager( |
mmenke
2016/06/27 22:11:57
nit: Explicit not needed.
|
+ PrefService* pref_service, |
+ scoped_refptr<base::SequencedTaskRunner> network_task_runner); |
+ ~CTPolicyManager(); |
+ |
+ void Shutdown(); |
mmenke
2016/06/27 22:11:56
As used in ProfileIOData, its delegate on the UITh
Ryan Sleevi
2016/06/27 22:49:19
I'm perhaps not sure I understood your comment.
I
mmenke
2016/06/28 12:38:00
Right, I just wanted enough usage comments here th
|
+ |
+ // Gets the RequireCTDelegate() that responds based on the policies set |
+ // via the pref service. This object MUST only be used on the network |
+ // task runner provided, and MUST NOT be used after this object has |
+ // been destructed. |
+ net::TransportSecurityState::RequireCTDelegate* GetDelegate(); |
+ |
+ private: |
+ class CTDelegate; |
+ |
+ // Schedules an update of the CTPolicyDelegate. As it's possible that |
+ // multiple preferences may be updated at the same time, this exists to |
+ // schedule only a single update. |
+ void ScheduleUpdate(); |
+ |
+ // Performs the actual update of the CTPolicyDelegate once preference |
+ // changes have quiesced. |
+ void Update(); |
+ |
+ PrefChangeRegistrar pref_change_registrar_; |
+ std::unique_ptr<CTDelegate> delegate_; |
+ |
+ base::WeakPtrFactory<CTPolicyManager> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CTPolicyManager); |
+}; |
+ |
+} // namespace certificate_transparency |
+ |
+#endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_CT_POLICY_MANAGER_H_ |