Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 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 "base/command_line.h" | |
| 6 #include "chrome/browser/policy/configuration_policy_pref_store.h" | |
| 7 #include "chrome/browser/policy/device_management_policy_provider.h" | |
| 8 #include "chrome/browser/policy/device_management_service.h" | |
| 9 #include "chrome/browser/policy/profile_policy_context.h" | |
| 10 #include "chrome/browser/profile.h" | |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 | |
| 13 namespace policy { | |
| 14 | |
| 15 ProfilePolicyContext::ProfilePolicyContext(Profile* profile) | |
| 16 : profile_(profile) { | |
| 17 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 18 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | |
| 19 device_management_service_.reset(new DeviceManagementService( | |
| 20 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); | |
| 21 device_management_policy_provider_.reset( | |
| 22 new policy::DeviceManagementPolicyProvider( | |
| 23 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), | |
| 24 device_management_service_->CreateBackend(), | |
| 25 profile_->GetTokenService(), | |
| 26 profile_->GetPath())); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 ProfilePolicyContext::~ProfilePolicyContext() { | |
| 31 device_management_policy_provider_.reset(); | |
| 32 device_management_service_.reset(); | |
| 33 } | |
| 34 | |
| 35 void ProfilePolicyContext::Initialize() { | |
| 36 if (device_management_service_.get()) | |
| 37 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
| |
| 38 } | |
| 39 | |
| 40 void ProfilePolicyContext::Shutdown() { | |
| 41 if (device_management_service_.get()) | |
| 42 device_management_service_->Shutdown(); | |
| 43 if (device_management_policy_provider_.get()) | |
| 44 device_management_policy_provider_->Shutdown(); | |
| 45 } | |
| 46 | |
| 47 DeviceManagementPolicyProvider* | |
| 48 ProfilePolicyContext::GetDeviceManagementPolicyProvider() { | |
| 49 return device_management_policy_provider_.get(); | |
| 50 } | |
| 51 | |
| 52 } // namespace policy | |
| OLD | NEW |