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

Unified Diff: chrome/browser/chromeos/policy/network_policy_service.cc

Issue 24153012: Fix cyclic dependency between ProfilePolicyConnector and PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed another bug for OTRProfile. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/network_policy_service.cc
diff --git a/chrome/browser/chromeos/policy/network_policy_service.cc b/chrome/browser/chromeos/policy/network_policy_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..68454e88c050c4429f32882956a22b5442db2ce0
--- /dev/null
+++ b/chrome/browser/chromeos/policy/network_policy_service.cc
@@ -0,0 +1,71 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/policy/network_policy_service.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/logging.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/chromeos/policy/user_network_configuration_updater.h"
+#include "chrome/common/pref_names.h"
+#include "chromeos/network/network_handler.h"
+#include "chromeos/network/onc/onc_certificate_importer_impl.h"
+
+namespace policy {
+
+NetworkPolicyService::~NetworkPolicyService() {}
+
+NetworkPolicyService::NetworkPolicyService(bool allow_trusted_certs_from_policy,
+ const chromeos::User& user,
+ PrefService* user_prefs,
+ PolicyService* policy_service)
+ : user_prefs_(user_prefs) {
+ DCHECK(user_prefs_);
+ network_configuration_updater_ =
+ UserNetworkConfigurationUpdater::CreateForUserPolicy(
+ allow_trusted_certs_from_policy,
+ user,
+ scoped_ptr<chromeos::onc::CertificateImporter>(
+ new chromeos::onc::CertificateImporterImpl),
+ policy_service,
+ chromeos::NetworkHandler::Get()
+ ->managed_network_configuration_handler());
+}
+
+void NetworkPolicyService::AddPolicyCertVerifier(
+ PolicyCertVerifier* cert_verifier) {
+ network_configuration_updater_->AddPolicyCertVerifier(cert_verifier);
+}
+
+void NetworkPolicyService::RemovePolicyCertVerifier(
+ PolicyCertVerifier* cert_verifier) {
+ network_configuration_updater_->RemovePolicyCertVerifier(cert_verifier);
+}
+
+base::Closure NetworkPolicyService::GetPolicyCertTrustedCallback() {
+ return base::Bind(&NetworkPolicyService::SetUsedPolicyCertificatesOnce,
+ base::Unretained(this));
+}
+
+void NetworkPolicyService::GetWebTrustedCertificates(
+ net::CertificateList* certs) const {
+ certs->clear();
+ network_configuration_updater_->GetWebTrustedCertificates(certs);
+}
+
+bool NetworkPolicyService::UsedPolicyCertificates() const {
+ return user_prefs_->GetBoolean(prefs::kUsedPolicyCertificatesOnce);
+}
+
+void NetworkPolicyService::Shutdown() {
+ network_configuration_updater_.reset();
+ user_prefs_ = NULL;
+}
+
+void NetworkPolicyService::SetUsedPolicyCertificatesOnce() {
+ user_prefs_->SetBoolean(prefs::kUsedPolicyCertificatesOnce, true);
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698