Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/chromeos/policy/user_network_configuration_updater.cc

Issue 580283005: Revert of Make ONCCertificateImporter async. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nss_util_deadcode
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/chromeos/net/onc_utils.h" 12 #include "chrome/browser/chromeos/net/onc_utils.h"
13 #include "chrome/browser/net/nss_context.h" 13 #include "chrome/browser/net/nss_context.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chromeos/network/managed_network_configuration_handler.h" 15 #include "chromeos/network/managed_network_configuration_handler.h"
16 #include "chromeos/network/onc/onc_certificate_importer_impl.h" 16 #include "chromeos/network/onc/onc_certificate_importer_impl.h"
17 #include "components/user_manager/user.h" 17 #include "components/user_manager/user.h"
18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
20 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
21 #include "policy/policy_constants.h" 20 #include "policy/policy_constants.h"
22 21
23 namespace policy { 22 namespace policy {
24 23
25 UserNetworkConfigurationUpdater::~UserNetworkConfigurationUpdater() {} 24 UserNetworkConfigurationUpdater::~UserNetworkConfigurationUpdater() {}
26 25
27 // static 26 // static
28 scoped_ptr<UserNetworkConfigurationUpdater> 27 scoped_ptr<UserNetworkConfigurationUpdater>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void UserNetworkConfigurationUpdater::SetCertificateImporterForTest( 77 void UserNetworkConfigurationUpdater::SetCertificateImporterForTest(
79 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { 78 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) {
80 SetCertificateImporter(certificate_importer.Pass()); 79 SetCertificateImporter(certificate_importer.Pass());
81 } 80 }
82 81
83 void UserNetworkConfigurationUpdater::GetWebTrustedCertificates( 82 void UserNetworkConfigurationUpdater::GetWebTrustedCertificates(
84 net::CertificateList* certs) const { 83 net::CertificateList* certs) const {
85 *certs = web_trust_certs_; 84 *certs = web_trust_certs_;
86 } 85 }
87 86
88 void UserNetworkConfigurationUpdater::OnCertificatesImported(
89 bool /* unused success */,
90 const net::CertificateList& onc_trusted_certificates) {
91 web_trust_certs_.clear();
92 if (allow_trusted_certificates_from_policy_)
93 web_trust_certs_ = onc_trusted_certificates;
94 NotifyTrustAnchorsChanged();
95 }
96
97 void UserNetworkConfigurationUpdater::ImportCertificates( 87 void UserNetworkConfigurationUpdater::ImportCertificates(
98 const base::ListValue& certificates_onc) { 88 const base::ListValue& certificates_onc) {
99 // If certificate importer is not yet set, cache the certificate onc. It will 89 // If certificate importer is not yet set, cache the certificate onc. It will
100 // be imported when the certificate importer gets set. 90 // be imported when the certificate importer gets set.
101 if (!certificate_importer_) { 91 if (!certificate_importer_) {
102 pending_certificates_onc_.reset(certificates_onc.DeepCopy()); 92 pending_certificates_onc_.reset(certificates_onc.DeepCopy());
103 return; 93 return;
104 } 94 }
105 95
96 web_trust_certs_.clear();
106 certificate_importer_->ImportCertificates( 97 certificate_importer_->ImportCertificates(
107 certificates_onc, 98 certificates_onc,
108 onc_source_, 99 onc_source_,
109 base::Bind(&UserNetworkConfigurationUpdater::OnCertificatesImported, 100 allow_trusted_certificates_from_policy_ ? &web_trust_certs_ : NULL);
110 base::Unretained(this))); 101
102 NotifyTrustAnchorsChanged();
111 } 103 }
112 104
113 void UserNetworkConfigurationUpdater::ApplyNetworkPolicy( 105 void UserNetworkConfigurationUpdater::ApplyNetworkPolicy(
114 base::ListValue* network_configs_onc, 106 base::ListValue* network_configs_onc,
115 base::DictionaryValue* global_network_config) { 107 base::DictionaryValue* global_network_config) {
116 DCHECK(user_); 108 DCHECK(user_);
117 chromeos::onc::ExpandStringPlaceholdersInNetworksForUser(user_, 109 chromeos::onc::ExpandStringPlaceholdersInNetworksForUser(user_,
118 network_configs_onc); 110 network_configs_onc);
119 network_config_handler_->SetPolicy(onc_source_, 111 network_config_handler_->SetPolicy(onc_source_,
120 user_->username_hash(), 112 user_->username_hash(),
(...skipping 12 matching lines...) Expand all
133 profile, 125 profile,
134 base::Bind( 126 base::Bind(
135 &UserNetworkConfigurationUpdater::CreateAndSetCertificateImporter, 127 &UserNetworkConfigurationUpdater::CreateAndSetCertificateImporter,
136 weak_factory_.GetWeakPtr())); 128 weak_factory_.GetWeakPtr()));
137 } 129 }
138 130
139 void UserNetworkConfigurationUpdater::CreateAndSetCertificateImporter( 131 void UserNetworkConfigurationUpdater::CreateAndSetCertificateImporter(
140 net::NSSCertDatabase* database) { 132 net::NSSCertDatabase* database) {
141 DCHECK(database); 133 DCHECK(database);
142 SetCertificateImporter(scoped_ptr<chromeos::onc::CertificateImporter>( 134 SetCertificateImporter(scoped_ptr<chromeos::onc::CertificateImporter>(
143 new chromeos::onc::CertificateImporterImpl( 135 new chromeos::onc::CertificateImporterImpl(database)));
144 content::BrowserThread::GetMessageLoopProxyForThread(
145 content::BrowserThread::IO),
146 database)));
147 } 136 }
148 137
149 void UserNetworkConfigurationUpdater::SetCertificateImporter( 138 void UserNetworkConfigurationUpdater::SetCertificateImporter(
150 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { 139 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) {
151 certificate_importer_ = certificate_importer.Pass(); 140 certificate_importer_ = certificate_importer.Pass();
152 141
153 if (pending_certificates_onc_) 142 if (pending_certificates_onc_)
154 ImportCertificates(*pending_certificates_onc_); 143 ImportCertificates(*pending_certificates_onc_);
155 pending_certificates_onc_.reset(); 144 pending_certificates_onc_.reset();
156 } 145 }
157 146
158 void UserNetworkConfigurationUpdater::NotifyTrustAnchorsChanged() { 147 void UserNetworkConfigurationUpdater::NotifyTrustAnchorsChanged() {
159 FOR_EACH_OBSERVER(WebTrustedCertsObserver, 148 FOR_EACH_OBSERVER(WebTrustedCertsObserver,
160 observer_list_, 149 observer_list_,
161 OnTrustAnchorsChanged(web_trust_certs_)); 150 OnTrustAnchorsChanged(web_trust_certs_));
162 } 151 }
163 152
164 } // namespace policy 153 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698