Chromium Code Reviews| Index: chrome/browser/policy/profile_policy_context.cc |
| diff --git a/chrome/browser/policy/profile_policy_context.cc b/chrome/browser/policy/profile_policy_context.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..23b6758c34109c532120709a6566f27640b5a571 |
| --- /dev/null |
| +++ b/chrome/browser/policy/profile_policy_context.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2010 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 "base/command_line.h" |
| +#include "chrome/browser/policy/configuration_policy_pref_store.h" |
| +#include "chrome/browser/policy/device_management_policy_provider.h" |
| +#include "chrome/browser/policy/device_management_service.h" |
| +#include "chrome/browser/policy/profile_policy_context.h" |
| +#include "chrome/browser/profile.h" |
| +#include "chrome/common/chrome_switches.h" |
| + |
| +namespace policy { |
| + |
| +ProfilePolicyContext::ProfilePolicyContext(Profile* profile) |
| + : profile_(profile) { |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| + device_management_service_.reset(new DeviceManagementService( |
| + command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); |
| + device_management_policy_provider_.reset( |
| + new policy::DeviceManagementPolicyProvider( |
| + ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
| + device_management_service_->CreateBackend(), |
| + profile_->GetTokenService(), |
| + profile_->GetPath())); |
| + } |
| +} |
| + |
| +ProfilePolicyContext::~ProfilePolicyContext() { |
| + device_management_policy_provider_.reset(); |
| + device_management_service_.reset(); |
| +} |
| + |
| +void ProfilePolicyContext::Initialize() { |
| + if (device_management_service_.get()) |
| + device_management_service_->Initialize(profile_->GetRequestContext()); |
|
Nico
2010/11/22 12:40:16
can you DCHECK that the prefs aren't initialized a
Mattias Nissler (ping if slow)
2010/11/22 14:08:07
They are already initialized at this point, and th
|
| +} |
| + |
| +void ProfilePolicyContext::Shutdown() { |
| + if (device_management_service_.get()) |
| + device_management_service_->Shutdown(); |
| + if (device_management_policy_provider_.get()) |
| + device_management_policy_provider_->Shutdown(); |
| +} |
| + |
| +DeviceManagementPolicyProvider* |
| +ProfilePolicyContext::GetDeviceManagementPolicyProvider() { |
| + return device_management_policy_provider_.get(); |
| +} |
| + |
| +} // namespace policy |