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 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h" | 5 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/values.h" | 12 #include "base/values.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/net/onc_utils.h" | 14 #include "chrome/browser/chromeos/net/onc_utils.h" |
13 #include "chrome/browser/net/nss_context.h" | 15 #include "chrome/browser/net/nss_context.h" |
14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
15 #include "chromeos/network/managed_network_configuration_handler.h" | 17 #include "chromeos/network/managed_network_configuration_handler.h" |
16 #include "chromeos/network/onc/onc_certificate_importer_impl.h" | 18 #include "chromeos/network/onc/onc_certificate_importer_impl.h" |
(...skipping 15 matching lines...) Expand all Loading... |
32 const user_manager::User& user, | 34 const user_manager::User& user, |
33 PolicyService* policy_service, | 35 PolicyService* policy_service, |
34 chromeos::ManagedNetworkConfigurationHandler* network_config_handler) { | 36 chromeos::ManagedNetworkConfigurationHandler* network_config_handler) { |
35 scoped_ptr<UserNetworkConfigurationUpdater> updater( | 37 scoped_ptr<UserNetworkConfigurationUpdater> updater( |
36 new UserNetworkConfigurationUpdater(profile, | 38 new UserNetworkConfigurationUpdater(profile, |
37 allow_trusted_certs_from_policy, | 39 allow_trusted_certs_from_policy, |
38 user, | 40 user, |
39 policy_service, | 41 policy_service, |
40 network_config_handler)); | 42 network_config_handler)); |
41 updater->Init(); | 43 updater->Init(); |
42 return updater.Pass(); | 44 return updater; |
43 } | 45 } |
44 | 46 |
45 void UserNetworkConfigurationUpdater::AddTrustedCertsObserver( | 47 void UserNetworkConfigurationUpdater::AddTrustedCertsObserver( |
46 WebTrustedCertsObserver* observer) { | 48 WebTrustedCertsObserver* observer) { |
47 observer_list_.AddObserver(observer); | 49 observer_list_.AddObserver(observer); |
48 } | 50 } |
49 | 51 |
50 void UserNetworkConfigurationUpdater::RemoveTrustedCertsObserver( | 52 void UserNetworkConfigurationUpdater::RemoveTrustedCertsObserver( |
51 WebTrustedCertsObserver* observer) { | 53 WebTrustedCertsObserver* observer) { |
52 observer_list_.RemoveObserver(observer); | 54 observer_list_.RemoveObserver(observer); |
(...skipping 17 matching lines...) Expand all Loading... |
70 // call, which is not safe before the profile initialization is finalized. | 72 // call, which is not safe before the profile initialization is finalized. |
71 // Thus, listen for PROFILE_ADDED notification, on which |cert_importer_| | 73 // Thus, listen for PROFILE_ADDED notification, on which |cert_importer_| |
72 // creation should start. | 74 // creation should start. |
73 registrar_.Add(this, | 75 registrar_.Add(this, |
74 chrome::NOTIFICATION_PROFILE_ADDED, | 76 chrome::NOTIFICATION_PROFILE_ADDED, |
75 content::Source<Profile>(profile)); | 77 content::Source<Profile>(profile)); |
76 } | 78 } |
77 | 79 |
78 void UserNetworkConfigurationUpdater::SetCertificateImporterForTest( | 80 void UserNetworkConfigurationUpdater::SetCertificateImporterForTest( |
79 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { | 81 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { |
80 SetCertificateImporter(certificate_importer.Pass()); | 82 SetCertificateImporter(std::move(certificate_importer)); |
81 } | 83 } |
82 | 84 |
83 void UserNetworkConfigurationUpdater::GetWebTrustedCertificates( | 85 void UserNetworkConfigurationUpdater::GetWebTrustedCertificates( |
84 net::CertificateList* certs) const { | 86 net::CertificateList* certs) const { |
85 *certs = web_trust_certs_; | 87 *certs = web_trust_certs_; |
86 } | 88 } |
87 | 89 |
88 void UserNetworkConfigurationUpdater::OnCertificatesImported( | 90 void UserNetworkConfigurationUpdater::OnCertificatesImported( |
89 bool /* unused success */, | 91 bool /* unused success */, |
90 const net::CertificateList& onc_trusted_certificates) { | 92 const net::CertificateList& onc_trusted_certificates) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 DCHECK(database); | 143 DCHECK(database); |
142 SetCertificateImporter(scoped_ptr<chromeos::onc::CertificateImporter>( | 144 SetCertificateImporter(scoped_ptr<chromeos::onc::CertificateImporter>( |
143 new chromeos::onc::CertificateImporterImpl( | 145 new chromeos::onc::CertificateImporterImpl( |
144 content::BrowserThread::GetMessageLoopProxyForThread( | 146 content::BrowserThread::GetMessageLoopProxyForThread( |
145 content::BrowserThread::IO), | 147 content::BrowserThread::IO), |
146 database))); | 148 database))); |
147 } | 149 } |
148 | 150 |
149 void UserNetworkConfigurationUpdater::SetCertificateImporter( | 151 void UserNetworkConfigurationUpdater::SetCertificateImporter( |
150 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { | 152 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { |
151 certificate_importer_ = certificate_importer.Pass(); | 153 certificate_importer_ = std::move(certificate_importer); |
152 | 154 |
153 if (pending_certificates_onc_) | 155 if (pending_certificates_onc_) |
154 ImportCertificates(*pending_certificates_onc_); | 156 ImportCertificates(*pending_certificates_onc_); |
155 pending_certificates_onc_.reset(); | 157 pending_certificates_onc_.reset(); |
156 } | 158 } |
157 | 159 |
158 void UserNetworkConfigurationUpdater::NotifyTrustAnchorsChanged() { | 160 void UserNetworkConfigurationUpdater::NotifyTrustAnchorsChanged() { |
159 FOR_EACH_OBSERVER(WebTrustedCertsObserver, | 161 FOR_EACH_OBSERVER(WebTrustedCertsObserver, |
160 observer_list_, | 162 observer_list_, |
161 OnTrustAnchorsChanged(web_trust_certs_)); | 163 OnTrustAnchorsChanged(web_trust_certs_)); |
162 } | 164 } |
163 | 165 |
164 } // namespace policy | 166 } // namespace policy |
OLD | NEW |