| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 16 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 | 20 |
| 21 class Profile; | 21 class Profile; |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const net::CertificateList& trust_anchors) = 0; | 60 const net::CertificateList& trust_anchors) = 0; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 ~UserNetworkConfigurationUpdater() override; | 63 ~UserNetworkConfigurationUpdater() override; |
| 64 | 64 |
| 65 // Creates an updater that applies the ONC user policy from |policy_service| | 65 // Creates an updater that applies the ONC user policy from |policy_service| |
| 66 // for user |user| once the policy service is completely initialized and on | 66 // for user |user| once the policy service is completely initialized and on |
| 67 // each policy change. Imported certificates, that request it, are only | 67 // each policy change. Imported certificates, that request it, are only |
| 68 // granted Web trust if |allow_trusted_certs_from_policy| is true. A reference | 68 // granted Web trust if |allow_trusted_certs_from_policy| is true. A reference |
| 69 // to |user| is stored. It must outlive the returned updater. | 69 // to |user| is stored. It must outlive the returned updater. |
| 70 static scoped_ptr<UserNetworkConfigurationUpdater> CreateForUserPolicy( | 70 static std::unique_ptr<UserNetworkConfigurationUpdater> CreateForUserPolicy( |
| 71 Profile* profile, | 71 Profile* profile, |
| 72 bool allow_trusted_certs_from_policy, | 72 bool allow_trusted_certs_from_policy, |
| 73 const user_manager::User& user, | 73 const user_manager::User& user, |
| 74 PolicyService* policy_service, | 74 PolicyService* policy_service, |
| 75 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); | 75 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); |
| 76 | 76 |
| 77 void AddTrustedCertsObserver(WebTrustedCertsObserver* observer); | 77 void AddTrustedCertsObserver(WebTrustedCertsObserver* observer); |
| 78 void RemoveTrustedCertsObserver(WebTrustedCertsObserver* observer); | 78 void RemoveTrustedCertsObserver(WebTrustedCertsObserver* observer); |
| 79 | 79 |
| 80 // Sets |certs| to the list of Web trusted server and CA certificates from the | 80 // Sets |certs| to the list of Web trusted server and CA certificates from the |
| 81 // last received policy. | 81 // last received policy. |
| 82 void GetWebTrustedCertificates(net::CertificateList* certs) const; | 82 void GetWebTrustedCertificates(net::CertificateList* certs) const; |
| 83 | 83 |
| 84 // Helper method to expose |SetCertificateImporter| for usage in tests. | 84 // Helper method to expose |SetCertificateImporter| for usage in tests. |
| 85 void SetCertificateImporterForTest( | 85 void SetCertificateImporterForTest( |
| 86 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer); | 86 std::unique_ptr<chromeos::onc::CertificateImporter> certificate_importer); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 class CrosTrustAnchorProvider; | 89 class CrosTrustAnchorProvider; |
| 90 | 90 |
| 91 UserNetworkConfigurationUpdater( | 91 UserNetworkConfigurationUpdater( |
| 92 Profile* profile, | 92 Profile* profile, |
| 93 bool allow_trusted_certs_from_policy, | 93 bool allow_trusted_certs_from_policy, |
| 94 const user_manager::User& user, | 94 const user_manager::User& user, |
| 95 PolicyService* policy_service, | 95 PolicyService* policy_service, |
| 96 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); | 96 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 112 const content::NotificationSource& source, | 112 const content::NotificationSource& source, |
| 113 const content::NotificationDetails& details) override; | 113 const content::NotificationDetails& details) override; |
| 114 | 114 |
| 115 // Creates onc::CertImporter with |database| and passes it to | 115 // Creates onc::CertImporter with |database| and passes it to |
| 116 // |SetCertificateImporter|. | 116 // |SetCertificateImporter|. |
| 117 void CreateAndSetCertificateImporter(net::NSSCertDatabase* database); | 117 void CreateAndSetCertificateImporter(net::NSSCertDatabase* database); |
| 118 | 118 |
| 119 // Sets the certificate importer that should be used to import certificate | 119 // Sets the certificate importer that should be used to import certificate |
| 120 // policies. If there is |pending_certificates_onc_|, it gets imported. | 120 // policies. If there is |pending_certificates_onc_|, it gets imported. |
| 121 void SetCertificateImporter( | 121 void SetCertificateImporter( |
| 122 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer); | 122 std::unique_ptr<chromeos::onc::CertificateImporter> certificate_importer); |
| 123 | 123 |
| 124 void NotifyTrustAnchorsChanged(); | 124 void NotifyTrustAnchorsChanged(); |
| 125 | 125 |
| 126 // Whether Web trust is allowed or not. | 126 // Whether Web trust is allowed or not. |
| 127 bool allow_trusted_certificates_from_policy_; | 127 bool allow_trusted_certificates_from_policy_; |
| 128 | 128 |
| 129 // The user for whom the user policy will be applied. | 129 // The user for whom the user policy will be applied. |
| 130 const user_manager::User* user_; | 130 const user_manager::User* user_; |
| 131 | 131 |
| 132 base::ObserverList<WebTrustedCertsObserver, true> observer_list_; | 132 base::ObserverList<WebTrustedCertsObserver, true> observer_list_; |
| 133 | 133 |
| 134 // Contains the certificates of the last import that requested web trust. Must | 134 // Contains the certificates of the last import that requested web trust. Must |
| 135 // be empty if Web trust from policy is not allowed. | 135 // be empty if Web trust from policy is not allowed. |
| 136 net::CertificateList web_trust_certs_; | 136 net::CertificateList web_trust_certs_; |
| 137 | 137 |
| 138 // If |ImportCertificates| is called before |SetCertificateImporter|, gets set | 138 // If |ImportCertificates| is called before |SetCertificateImporter|, gets set |
| 139 // to a copy of the policy for which the import was requested. | 139 // to a copy of the policy for which the import was requested. |
| 140 // The policy will be processed when the certificate importer is set. | 140 // The policy will be processed when the certificate importer is set. |
| 141 scoped_ptr<base::ListValue> pending_certificates_onc_; | 141 std::unique_ptr<base::ListValue> pending_certificates_onc_; |
| 142 | 142 |
| 143 // Certificate importer to be used for importing policy defined certificates. | 143 // Certificate importer to be used for importing policy defined certificates. |
| 144 // Set by |SetCertificateImporter|. | 144 // Set by |SetCertificateImporter|. |
| 145 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer_; | 145 std::unique_ptr<chromeos::onc::CertificateImporter> certificate_importer_; |
| 146 | 146 |
| 147 content::NotificationRegistrar registrar_; | 147 content::NotificationRegistrar registrar_; |
| 148 | 148 |
| 149 base::WeakPtrFactory<UserNetworkConfigurationUpdater> weak_factory_; | 149 base::WeakPtrFactory<UserNetworkConfigurationUpdater> weak_factory_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(UserNetworkConfigurationUpdater); | 151 DISALLOW_COPY_AND_ASSIGN(UserNetworkConfigurationUpdater); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 } // namespace policy | 154 } // namespace policy |
| 155 | 155 |
| 156 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ | 156 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_NETWORK_CONFIGURATION_UPDATER_H_ |
| OLD | NEW |