This source file includes following definitions.
- GetForProfile
- GetInstance
- UserNetworkConfigurationUpdaterFactory
- GetBrowserContextToUse
- ServiceIsCreatedWithBrowserContext
- ServiceIsNULLWhileTesting
- BuildServiceInstanceFor
#include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
#include "base/memory/singleton.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/policy/user_network_configuration_updater.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chromeos/network/network_handler.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
namespace policy {
UserNetworkConfigurationUpdater*
UserNetworkConfigurationUpdaterFactory::GetForProfile(Profile* profile) {
return static_cast<UserNetworkConfigurationUpdater*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
UserNetworkConfigurationUpdaterFactory*
UserNetworkConfigurationUpdaterFactory::GetInstance() {
return Singleton<UserNetworkConfigurationUpdaterFactory>::get();
}
UserNetworkConfigurationUpdaterFactory::UserNetworkConfigurationUpdaterFactory()
: BrowserContextKeyedServiceFactory(
"UserNetworkConfigurationUpdater",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(ProfilePolicyConnectorFactory::GetInstance());
}
UserNetworkConfigurationUpdaterFactory::
~UserNetworkConfigurationUpdaterFactory() {}
content::BrowserContext*
UserNetworkConfigurationUpdaterFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
bool
UserNetworkConfigurationUpdaterFactory::ServiceIsCreatedWithBrowserContext()
const {
return true;
}
bool UserNetworkConfigurationUpdaterFactory::ServiceIsNULLWhileTesting() const {
return true;
}
KeyedService* UserNetworkConfigurationUpdaterFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);
if (chromeos::ProfileHelper::IsSigninProfile(profile))
return NULL;
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
chromeos::User* user = user_manager->GetUserByProfile(profile);
DCHECK(user);
if (user != user_manager->GetPrimaryUser())
return NULL;
const bool allow_trusted_certs_from_policy =
user->GetType() == chromeos::User::USER_TYPE_REGULAR;
ProfilePolicyConnector* profile_connector =
ProfilePolicyConnectorFactory::GetForProfile(profile);
return UserNetworkConfigurationUpdater::CreateForUserPolicy(
profile,
allow_trusted_certs_from_policy,
*user,
profile_connector->policy_service(),
chromeos::NetworkHandler::Get()->managed_network_configuration_handler())
.release();
}
}