Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | |
| 5 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 6 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" |
| 7 #include "chrome/common/chrome_switches.h" | |
| 8 #include "chromeos/network/onc/onc_constants.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 #include "net/cert/cert_trust_anchor_provider.h" | |
| 11 | |
| 12 using content::BrowserThread; | |
| 6 | 13 |
| 7 namespace policy { | 14 namespace policy { |
| 8 | 15 |
| 9 NetworkConfigurationUpdater::NetworkConfigurationUpdater() { | 16 namespace { |
| 17 | |
| 18 // A simple implementation of net::CertTrustAnchorProvider that returns a list | |
| 19 // of certificates that can be set by the owner of this object. | |
| 20 class CrosTrustAnchorProvider : public net::CertTrustAnchorProvider { | |
|
Joao da Silva
2013/04/22 10:38:09
Just a comment: once we have the ProfilePolicyConn
pneubeck (no reviews)
2013/04/23 18:05:25
Done.
| |
| 21 public: | |
| 22 CrosTrustAnchorProvider() {} | |
| 23 virtual ~CrosTrustAnchorProvider() {} | |
| 24 | |
| 25 // CertTrustAnchorProvider overrides. | |
| 26 virtual const net::CertificateList& GetAdditionalTrustAnchors() OVERRIDE { | |
| 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 28 return trust_anchors_; | |
| 29 } | |
| 30 | |
| 31 void SetTrustAnchors(scoped_ptr<net::CertificateList> trust_anchors) { | |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 33 trust_anchors_.swap(*trust_anchors); | |
|
stevenjb
2013/04/22 16:53:41
Mixing scoped_ptr and direct pointer operations (s
pneubeck (no reviews)
2013/04/23 18:05:25
@Joao, you added that code. Any comment?
Joao da Silva
2013/04/24 09:21:14
trust_anchors_ as a scoped_ptr SGTM.
| |
| 34 } | |
| 35 | |
| 36 private: | |
| 37 net::CertificateList trust_anchors_; | |
| 38 | |
| 39 DISALLOW_COPY_AND_ASSIGN(CrosTrustAnchorProvider); | |
| 40 }; | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 NetworkConfigurationUpdater::NetworkConfigurationUpdater() | |
| 45 : allow_trusted_certificates_from_policy_(false), | |
| 46 cert_trust_provider_(new CrosTrustAnchorProvider()) { | |
| 10 } | 47 } |
| 11 | 48 |
| 12 NetworkConfigurationUpdater::~NetworkConfigurationUpdater() { | 49 NetworkConfigurationUpdater::~NetworkConfigurationUpdater() { |
| 50 bool posted = BrowserThread::DeleteSoon( | |
| 51 BrowserThread::IO, FROM_HERE, cert_trust_provider_); | |
| 52 if (!posted) | |
| 53 delete cert_trust_provider_; | |
| 54 } | |
| 55 | |
| 56 net::CertTrustAnchorProvider* | |
| 57 NetworkConfigurationUpdater::GetCertTrustAnchorProvider() { | |
| 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 59 return cert_trust_provider_; | |
| 60 } | |
| 61 | |
| 62 void NetworkConfigurationUpdater::SetTrustAnchors( | |
| 63 scoped_ptr<net::CertificateList> web_trust_certs) { | |
| 64 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 65 if (allow_trusted_certificates_from_policy_ && | |
| 66 command_line->HasSwitch(switches::kEnableWebTrustCerts)) { | |
| 67 BrowserThread::PostTask( | |
| 68 BrowserThread::IO, FROM_HERE, | |
| 69 base::Bind(&CrosTrustAnchorProvider::SetTrustAnchors, | |
| 70 base::Unretained(static_cast<CrosTrustAnchorProvider*>( | |
| 71 cert_trust_provider_)), | |
| 72 base::Passed(&web_trust_certs))); | |
| 73 } | |
| 13 } | 74 } |
| 14 | 75 |
| 15 } // namespace policy | 76 } // namespace policy |
| OLD | NEW |