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

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

Issue 24153012: Fix cyclic dependency between ProfilePolicyConnector and PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use callback_list in PolicyCertVerifier. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/policy/network_policy_service_factory.h"
6
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/chromeos/policy/network_policy_service.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/policy/profile_policy_connector.h"
11 #include "chrome/browser/policy/profile_policy_connector_factory.h"
12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
15
16 namespace policy {
17
18 // static
19 NetworkPolicyService* NetworkPolicyServiceFactory::GetForProfile(
20 Profile* profile) {
21 return static_cast<NetworkPolicyService*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
23 }
24
25 // static
26 NetworkPolicyServiceFactory* NetworkPolicyServiceFactory::GetInstance() {
27 return Singleton<NetworkPolicyServiceFactory>::get();
28 }
29
30 NetworkPolicyServiceFactory::NetworkPolicyServiceFactory()
31 : BrowserContextKeyedServiceFactory(
32 "NetworkPolicyService",
33 BrowserContextDependencyManager::GetInstance()) {
34 DependsOn(ProfilePolicyConnectorFactory::GetInstance());
35 }
36
37 NetworkPolicyServiceFactory::~NetworkPolicyServiceFactory() {}
38
39 content::BrowserContext* NetworkPolicyServiceFactory::GetBrowserContextToUse(
40 content::BrowserContext* context) const {
41 return chrome::GetBrowserContextRedirectedInIncognito(context);
42 }
43
44 BrowserContextKeyedService*
45 NetworkPolicyServiceFactory::BuildServiceInstanceFor(
46 content::BrowserContext* context) const {
47 Profile* profile = static_cast<Profile*>(context);
48 if (chromeos::ProfileHelper::IsSigninProfile(profile))
49 return NULL;
50
51 bool is_primary_user =
52 chromeos::UserManager::Get()->GetLoggedInUsers().size() == 1;
53 if (!is_primary_user)
54 return NULL;
Joao da Silva 2013/10/16 12:44:58 Check instead UserManager::GetUserByProfile(profil
pneubeck (no reviews) 2013/10/22 18:47:41 Done.
55
56 ProfilePolicyConnector* connector =
57 ProfilePolicyConnectorFactory::GetForProfile(profile);
58 return new NetworkPolicyService(profile->GetPrefs(),
59 connector->policy_service());
60 }
61
62 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698