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

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

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flattened components/cert_database folders. Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chromeos/network/network_handler.h" 15 #include "chromeos/network/network_handler.h"
16 #include "chromeos/network/onc/onc_certificate_importer_impl.h"
17 #include "components/cert_database/cert_database_service.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" 18 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
17 #include "components/user_manager/user.h" 20 #include "components/user_manager/user.h"
18 #include "components/user_manager/user_manager.h" 21 #include "components/user_manager/user_manager.h"
19 #include "components/user_manager/user_type.h" 22 #include "components/user_manager/user_type.h"
23 #include "content/public/browser/browser_thread.h"
20 24
21 namespace policy { 25 namespace policy {
22 26
23 // static 27 // static
24 UserNetworkConfigurationUpdater* 28 UserNetworkConfigurationUpdater*
25 UserNetworkConfigurationUpdaterFactory::GetForProfile(Profile* profile) { 29 UserNetworkConfigurationUpdaterFactory::GetForProfile(Profile* profile) {
26 return static_cast<UserNetworkConfigurationUpdater*>( 30 return static_cast<UserNetworkConfigurationUpdater*>(
27 GetInstance()->GetServiceForBrowserContext(profile, true)); 31 GetInstance()->GetServiceForBrowserContext(profile, true));
28 } 32 }
29 33
30 // static 34 // static
31 UserNetworkConfigurationUpdaterFactory* 35 UserNetworkConfigurationUpdaterFactory*
32 UserNetworkConfigurationUpdaterFactory::GetInstance() { 36 UserNetworkConfigurationUpdaterFactory::GetInstance() {
33 return Singleton<UserNetworkConfigurationUpdaterFactory>::get(); 37 return Singleton<UserNetworkConfigurationUpdaterFactory>::get();
34 } 38 }
35 39
36 UserNetworkConfigurationUpdaterFactory::UserNetworkConfigurationUpdaterFactory() 40 UserNetworkConfigurationUpdaterFactory::UserNetworkConfigurationUpdaterFactory()
37 : BrowserContextKeyedServiceFactory( 41 : BrowserContextKeyedServiceFactory(
38 "UserNetworkConfigurationUpdater", 42 "UserNetworkConfigurationUpdater",
39 BrowserContextDependencyManager::GetInstance()) { 43 BrowserContextDependencyManager::GetInstance()) {
40 DependsOn(ProfilePolicyConnectorFactory::GetInstance()); 44 DependsOn(ProfilePolicyConnectorFactory::GetInstance());
45 DependsOn(cert_database::CertDatabaseServiceFactory::GetInstance());
41 } 46 }
42 47
43 UserNetworkConfigurationUpdaterFactory:: 48 UserNetworkConfigurationUpdaterFactory::
44 ~UserNetworkConfigurationUpdaterFactory() {} 49 ~UserNetworkConfigurationUpdaterFactory() {}
45 50
46 content::BrowserContext* 51 content::BrowserContext*
47 UserNetworkConfigurationUpdaterFactory::GetBrowserContextToUse( 52 UserNetworkConfigurationUpdaterFactory::GetBrowserContextToUse(
48 content::BrowserContext* context) const { 53 content::BrowserContext* context) const {
49 return chrome::GetBrowserContextRedirectedInIncognito(context); 54 return chrome::GetBrowserContextRedirectedInIncognito(context);
50 } 55 }
(...skipping 21 matching lines...) Expand all
72 // also http://crbug.com/310685 . 77 // also http://crbug.com/310685 .
73 if (user != user_manager::UserManager::Get()->GetPrimaryUser()) 78 if (user != user_manager::UserManager::Get()->GetPrimaryUser())
74 return NULL; 79 return NULL;
75 80
76 const bool allow_trusted_certs_from_policy = 81 const bool allow_trusted_certs_from_policy =
77 user->GetType() == user_manager::USER_TYPE_REGULAR; 82 user->GetType() == user_manager::USER_TYPE_REGULAR;
78 83
79 ProfilePolicyConnector* profile_connector = 84 ProfilePolicyConnector* profile_connector =
80 ProfilePolicyConnectorFactory::GetForProfile(profile); 85 ProfilePolicyConnectorFactory::GetForProfile(profile);
81 86
87 cert_database::CertDatabaseService* cert_service =
88 cert_database::CertDatabaseServiceFactory::GetForBrowserContext(context);
89
90 if (!cert_service) {
91 LOG(ERROR) << "No CertDatabaseService available.";
92 return NULL;
93 }
94
95 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer(
96 new chromeos::onc::CertificateImporterImpl(
97 content::BrowserThread::GetMessageLoopProxyForThread(
98 content::BrowserThread::IO),
99 cert_service->GetIOPart()));
100
82 return UserNetworkConfigurationUpdater::CreateForUserPolicy( 101 return UserNetworkConfigurationUpdater::CreateForUserPolicy(
83 profile, 102 allow_trusted_certs_from_policy,
84 allow_trusted_certs_from_policy, 103 *user,
85 *user, 104 profile_connector->policy_service(),
86 profile_connector->policy_service(), 105 certificate_importer.Pass(),
87 chromeos::NetworkHandler::Get()->managed_network_configuration_handler()) 106 chromeos::NetworkHandler::Get()
88 .release(); 107 ->managed_network_configuration_handler()).release();
89 } 108 }
90 109
91 } // namespace policy 110 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698