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

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

Issue 14192017: Extract certificate policy application from NetworkLibrary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 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 (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 "chrome/browser/chromeos/policy/network_configuration_updater.h" 5 #include "chrome/browser/chromeos/policy/network_configuration_updater.h"
6 #include "chromeos/network/onc/onc_constants.h"
7 #include "content/public/browser/browser_thread.h"
8 #include "net/cert/cert_trust_anchor_provider.h"
9
10 using content::BrowserThread;
6 11
7 namespace policy { 12 namespace policy {
8 13
9 NetworkConfigurationUpdater::NetworkConfigurationUpdater() { 14 namespace {
15
16 // A simple implementation of net::CertTrustAnchorProvider that returns a list
17 // of certificates that can be set by the owner of this object.
18 class CrosTrustAnchorProvider : public net::CertTrustAnchorProvider {
19 public:
20 CrosTrustAnchorProvider()
21 : trust_anchors_(new net::CertificateList) {
22 }
23
24 virtual ~CrosTrustAnchorProvider() {
25 }
26
27 // CertTrustAnchorProvider overrides.
28 virtual const net::CertificateList& GetAdditionalTrustAnchors() OVERRIDE {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
30 return *trust_anchors_;
31 }
32
33 void SetTrustAnchors(scoped_ptr<net::CertificateList> trust_anchors) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
35 trust_anchors_ = trust_anchors.Pass();
36 }
37
38 private:
39 scoped_ptr<net::CertificateList> trust_anchors_;
40
41 DISALLOW_COPY_AND_ASSIGN(CrosTrustAnchorProvider);
42 };
43
44 } // namespace
45
46 NetworkConfigurationUpdater::NetworkConfigurationUpdater()
47 : allow_trusted_certificates_from_policy_(false),
48 cert_trust_provider_(new CrosTrustAnchorProvider()) {
10 } 49 }
11 50
12 NetworkConfigurationUpdater::~NetworkConfigurationUpdater() { 51 NetworkConfigurationUpdater::~NetworkConfigurationUpdater() {
52 bool posted = BrowserThread::DeleteSoon(
53 BrowserThread::IO, FROM_HERE, cert_trust_provider_);
54 if (!posted)
55 delete cert_trust_provider_;
56 }
57
58 net::CertTrustAnchorProvider*
59 NetworkConfigurationUpdater::GetCertTrustAnchorProvider() {
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
61 return cert_trust_provider_;
62 }
63
64 void NetworkConfigurationUpdater::SetTrustAnchors(
65 scoped_ptr<net::CertificateList> web_trust_certs) {
66 if (allow_trusted_certificates_from_policy_) {
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698