OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/user_network_configuration_updater_fact ory.h" | 5 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_fact ory.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h" | 8 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h" |
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
10 #include "chrome/browser/net/cert_database_service_factory.h" | |
10 #include "chrome/browser/policy/profile_policy_connector.h" | 11 #include "chrome/browser/policy/profile_policy_connector.h" |
11 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 12 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
12 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chromeos/network/network_handler.h" | 16 #include "chromeos/network/network_handler.h" |
17 #include "components/cert_database/public/cert_database_service.h" | |
16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
17 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
18 #include "components/user_manager/user.h" | 20 #include "components/user_manager/user.h" |
19 #include "components/user_manager/user_manager.h" | 21 #include "components/user_manager/user_manager.h" |
20 #include "components/user_manager/user_type.h" | 22 #include "components/user_manager/user_type.h" |
21 | 23 |
22 namespace policy { | 24 namespace policy { |
23 | 25 |
24 // static | 26 // static |
25 UserNetworkConfigurationUpdater* | 27 UserNetworkConfigurationUpdater* |
26 UserNetworkConfigurationUpdaterFactory::GetForProfile(Profile* profile) { | 28 UserNetworkConfigurationUpdaterFactory::GetForProfile(Profile* profile) { |
27 return static_cast<UserNetworkConfigurationUpdater*>( | 29 return static_cast<UserNetworkConfigurationUpdater*>( |
28 GetInstance()->GetServiceForBrowserContext(profile, true)); | 30 GetInstance()->GetServiceForBrowserContext(profile, true)); |
29 } | 31 } |
30 | 32 |
31 // static | 33 // static |
32 UserNetworkConfigurationUpdaterFactory* | 34 UserNetworkConfigurationUpdaterFactory* |
33 UserNetworkConfigurationUpdaterFactory::GetInstance() { | 35 UserNetworkConfigurationUpdaterFactory::GetInstance() { |
34 return Singleton<UserNetworkConfigurationUpdaterFactory>::get(); | 36 return Singleton<UserNetworkConfigurationUpdaterFactory>::get(); |
35 } | 37 } |
36 | 38 |
37 UserNetworkConfigurationUpdaterFactory::UserNetworkConfigurationUpdaterFactory() | 39 UserNetworkConfigurationUpdaterFactory::UserNetworkConfigurationUpdaterFactory() |
38 : BrowserContextKeyedServiceFactory( | 40 : BrowserContextKeyedServiceFactory( |
39 "UserNetworkConfigurationUpdater", | 41 "UserNetworkConfigurationUpdater", |
40 BrowserContextDependencyManager::GetInstance()) { | 42 BrowserContextDependencyManager::GetInstance()) { |
41 DependsOn(ProfilePolicyConnectorFactory::GetInstance()); | 43 DependsOn(ProfilePolicyConnectorFactory::GetInstance()); |
44 DependsOn(CertDatabaseServiceFactory::GetInstance()); | |
42 } | 45 } |
43 | 46 |
44 UserNetworkConfigurationUpdaterFactory:: | 47 UserNetworkConfigurationUpdaterFactory:: |
45 ~UserNetworkConfigurationUpdaterFactory() {} | 48 ~UserNetworkConfigurationUpdaterFactory() {} |
46 | 49 |
47 content::BrowserContext* | 50 content::BrowserContext* |
48 UserNetworkConfigurationUpdaterFactory::GetBrowserContextToUse( | 51 UserNetworkConfigurationUpdaterFactory::GetBrowserContextToUse( |
49 content::BrowserContext* context) const { | 52 content::BrowserContext* context) const { |
50 return chrome::GetBrowserContextRedirectedInIncognito(context); | 53 return chrome::GetBrowserContextRedirectedInIncognito(context); |
51 } | 54 } |
(...skipping 21 matching lines...) Expand all Loading... | |
73 // also http://crbug.com/310685 . | 76 // also http://crbug.com/310685 . |
74 if (user != user_manager::UserManager::Get()->GetPrimaryUser()) | 77 if (user != user_manager::UserManager::Get()->GetPrimaryUser()) |
75 return NULL; | 78 return NULL; |
76 | 79 |
77 const bool allow_trusted_certs_from_policy = | 80 const bool allow_trusted_certs_from_policy = |
78 user->GetType() == user_manager::USER_TYPE_REGULAR; | 81 user->GetType() == user_manager::USER_TYPE_REGULAR; |
79 | 82 |
80 ProfilePolicyConnector* profile_connector = | 83 ProfilePolicyConnector* profile_connector = |
81 ProfilePolicyConnectorFactory::GetForProfile(profile); | 84 ProfilePolicyConnectorFactory::GetForProfile(profile); |
82 | 85 |
83 return UserNetworkConfigurationUpdater::CreateForUserPolicy( | 86 CertDatabaseService* cert_service = |
84 profile, | 87 CertDatabaseServiceFactory::GetForBrowserContext(context); |
85 allow_trusted_certs_from_policy, | 88 |
86 *user, | 89 UserNetworkConfigurationUpdater* updater = |
87 profile_connector->policy_service(), | 90 UserNetworkConfigurationUpdater::CreateForUserPolicy( |
88 chromeos::NetworkHandler::Get()->managed_network_configuration_handler()) | 91 profile, |
89 .release(); | 92 allow_trusted_certs_from_policy, |
93 *user, | |
94 profile_connector->policy_service(), | |
95 chromeos::NetworkHandler::Get() | |
96 ->managed_network_configuration_handler()).release(); | |
97 | |
98 cert_service->GetNSSCertDatabase(base::Bind( | |
99 &UserNetworkConfigurationUpdater::CreateAndSetCertificateImporter, | |
100 base::Unretained(updater))); | |
mattm
2014/09/05 07:35:28
Is Unretained safe here? Are ownership/lifetime i
pneubeck (no reviews)
2014/09/05 08:04:56
Yes, this one isn't thought through yet.
I'll add
pneubeck (no reviews)
2014/09/12 16:20:23
This is fixed now.
| |
101 | |
102 return updater; | |
90 } | 103 } |
91 | 104 |
92 } // namespace policy | 105 } // namespace policy |
OLD | NEW |