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

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

Issue 325313004: Cleanup tests using SetSkipCertificateImporterCreationForTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
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/login/users/user.h" 12 #include "chrome/browser/chromeos/login/users/user.h"
13 #include "chrome/browser/chromeos/net/onc_utils.h" 13 #include "chrome/browser/chromeos/net/onc_utils.h"
14 #include "chrome/browser/net/nss_context.h" 14 #include "chrome/browser/net/nss_context.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chromeos/network/managed_network_configuration_handler.h" 16 #include "chromeos/network/managed_network_configuration_handler.h"
17 #include "chromeos/network/onc/onc_certificate_importer_impl.h" 17 #include "chromeos/network/onc/onc_certificate_importer_impl.h"
18 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
19 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
20 #include "policy/policy_constants.h" 20 #include "policy/policy_constants.h"
21 21
22 namespace { 22 namespace {
23 23
24 bool skip_certificate_importer_creation_for_test = false; 24 bool skip_certificate_importer_creation_for_test = false;
pneubeck (no reviews) 2014/07/15 20:33:35 as this is not modified anymore, the 'false' shoul
tbarzic 2014/07/16 05:58:10 Done.
25 25
26 } // namespace 26 } // namespace
27 27
28 namespace policy { 28 namespace policy {
29 29
30 UserNetworkConfigurationUpdater::~UserNetworkConfigurationUpdater() {} 30 UserNetworkConfigurationUpdater::~UserNetworkConfigurationUpdater() {}
31 31
32 // static 32 // static
33 scoped_ptr<UserNetworkConfigurationUpdater> 33 scoped_ptr<UserNetworkConfigurationUpdater>
34 UserNetworkConfigurationUpdater::CreateForUserPolicy( 34 UserNetworkConfigurationUpdater::CreateForUserPolicy(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 key::kOpenNetworkConfiguration, 67 key::kOpenNetworkConfiguration,
68 policy_service, 68 policy_service,
69 network_config_handler), 69 network_config_handler),
70 allow_trusted_certificates_from_policy_(allow_trusted_certs_from_policy), 70 allow_trusted_certificates_from_policy_(allow_trusted_certs_from_policy),
71 user_(&user), 71 user_(&user),
72 weak_factory_(this) { 72 weak_factory_(this) {
73 // The updater is created with |certificate_importer_| unset and is 73 // The updater is created with |certificate_importer_| unset and is
74 // responsible for creating it. This requires |GetNSSCertDatabaseForProfile| 74 // responsible for creating it. This requires |GetNSSCertDatabaseForProfile|
75 // call, which is not safe before the profile initialization is finalized. 75 // call, which is not safe before the profile initialization is finalized.
76 // Thus, listen for PROFILE_ADDED notification, on which |cert_importer_| 76 // Thus, listen for PROFILE_ADDED notification, on which |cert_importer_|
77 // creation should start. This behaviour can be disabled in tests. 77 // creation should start. This behaviour can be disabled in tests.
pneubeck (no reviews) 2014/07/15 20:33:35 last sentence should go away.
tbarzic 2014/07/16 05:58:10 Done.
78 if (!skip_certificate_importer_creation_for_test) { 78 if (!skip_certificate_importer_creation_for_test) {
79 registrar_.Add(this, 79 registrar_.Add(this,
80 chrome::NOTIFICATION_PROFILE_ADDED, 80 chrome::NOTIFICATION_PROFILE_ADDED,
81 content::Source<Profile>(profile)); 81 content::Source<Profile>(profile));
82 } 82 }
83 } 83 }
84 84
85 void UserNetworkConfigurationUpdater::SetCertificateImporterForTest( 85 void UserNetworkConfigurationUpdater::SetCertificateImporterForTest(
86 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) { 86 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) {
87 SetCertificateImporter(certificate_importer.Pass()); 87 SetCertificateImporter(certificate_importer.Pass());
88 } 88 }
89 89
90 // static
91 void UserNetworkConfigurationUpdater::
92 SetSkipCertificateImporterCreationForTest(bool skip) {
93 skip_certificate_importer_creation_for_test = skip;
94 }
95
96 void UserNetworkConfigurationUpdater::GetWebTrustedCertificates( 90 void UserNetworkConfigurationUpdater::GetWebTrustedCertificates(
97 net::CertificateList* certs) const { 91 net::CertificateList* certs) const {
98 *certs = web_trust_certs_; 92 *certs = web_trust_certs_;
99 } 93 }
100 94
101 void UserNetworkConfigurationUpdater::ImportCertificates( 95 void UserNetworkConfigurationUpdater::ImportCertificates(
102 const base::ListValue& certificates_onc) { 96 const base::ListValue& certificates_onc) {
103 // If certificate importer is not yet set, cache the certificate onc. It will 97 // If certificate importer is not yet set, cache the certificate onc. It will
104 // be imported when the certificate importer gets set. 98 // be imported when the certificate importer gets set.
105 if (!certificate_importer_) { 99 if (!certificate_importer_) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 pending_certificates_onc_.reset(); 155 pending_certificates_onc_.reset();
162 } 156 }
163 157
164 void UserNetworkConfigurationUpdater::NotifyTrustAnchorsChanged() { 158 void UserNetworkConfigurationUpdater::NotifyTrustAnchorsChanged() {
165 FOR_EACH_OBSERVER(WebTrustedCertsObserver, 159 FOR_EACH_OBSERVER(WebTrustedCertsObserver,
166 observer_list_, 160 observer_list_,
167 OnTrustAnchorsChanged(web_trust_certs_)); 161 OnTrustAnchorsChanged(web_trust_certs_));
168 } 162 }
169 163
170 } // namespace policy 164 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698