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