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

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

Issue 24153012: Fix cyclic dependency between ProfilePolicyConnector and PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 7 years, 1 month 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/policy_cert_service_factory.cc
diff --git a/chrome/browser/chromeos/policy/policy_cert_service_factory.cc b/chrome/browser/chromeos/policy/policy_cert_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f0e3d8eda24247260125d3881f3c2560af11083f
--- /dev/null
+++ b/chrome/browser/chromeos/policy/policy_cert_service_factory.cc
@@ -0,0 +1,81 @@
+// 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/policy_cert_service_factory.h"
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/chromeos/policy/policy_cert_service.h"
+#include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
+#include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+#include "components/user_prefs/pref_registry_syncable.h"
+
+namespace policy {
+
+// static
+PolicyCertService* PolicyCertServiceFactory::GetForProfile(Profile* profile) {
+ return static_cast<PolicyCertService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, false));
+}
+
+// static
+scoped_ptr<PolicyCertVerifier> PolicyCertServiceFactory::CreateForProfile(
+ Profile* profile) {
+ DCHECK(!GetInstance()->GetServiceForBrowserContext(profile, false));
+ PolicyCertService* service = static_cast<PolicyCertService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+ if (!service)
+ return scoped_ptr<PolicyCertVerifier>();
+ return service->CreatePolicyCertVerifier();
+}
+
+// static
+PolicyCertServiceFactory* PolicyCertServiceFactory::GetInstance() {
+ return Singleton<PolicyCertServiceFactory>::get();
+}
+
+PolicyCertServiceFactory::PolicyCertServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "PolicyCertService",
+ BrowserContextDependencyManager::GetInstance()) {
+ DependsOn(UserNetworkConfigurationUpdaterFactory::GetInstance());
+}
+
+PolicyCertServiceFactory::~PolicyCertServiceFactory() {}
+
+BrowserContextKeyedService* PolicyCertServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ Profile* profile = static_cast<Profile*>(context);
+ UserNetworkConfigurationUpdater* net_conf_updater =
+ UserNetworkConfigurationUpdaterFactory::GetForProfile(profile);
+ if (!net_conf_updater)
+ return NULL;
+
+ // In case of usage of additional trust anchors from an incognito profile, the
+ // prefs of the original profile have to be marked.
+ return new PolicyCertService(net_conf_updater,
+ profile->GetOriginalProfile()->GetPrefs());
+}
+
+content::BrowserContext* PolicyCertServiceFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextOwnInstanceInIncognito(context);
+}
+
+void PolicyCertServiceFactory::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(
+ prefs::kUsedPolicyCertificatesOnce,
+ false,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+}
+
+bool PolicyCertServiceFactory::ServiceIsNULLWhileTesting() const {
+ return true;
+}
+
+} // namespace policy
« no previous file with comments | « chrome/browser/chromeos/policy/policy_cert_service_factory.h ('k') | chrome/browser/chromeos/policy/policy_cert_verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698