OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> |
| 6 #include <string> |
| 7 |
5 #include "base/command_line.h" | 8 #include "base/command_line.h" |
6 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 9 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
7 #include "chrome/browser/policy/device_management_policy_provider.h" | 10 #include "chrome/browser/policy/device_management_policy_provider.h" |
8 #include "chrome/browser/policy/device_management_service.h" | 11 #include "chrome/browser/policy/device_management_service.h" |
9 #include "chrome/browser/policy/profile_policy_context.h" | 12 #include "chrome/browser/policy/profile_policy_context.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/notification_details.h" | 16 #include "chrome/common/notification_details.h" |
14 #include "chrome/common/notification_source.h" | 17 #include "chrome/common/notification_source.h" |
15 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
16 | 19 |
17 namespace { | 20 namespace { |
18 | 21 |
19 // Refresh rate sanity interval bounds. | 22 // Refresh rate sanity interval bounds. |
20 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes | 23 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes |
21 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day | 24 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day |
22 | 25 |
23 } | 26 } // namespace |
24 | 27 |
25 namespace policy { | 28 namespace policy { |
26 | 29 |
27 ProfilePolicyContext::ProfilePolicyContext(Profile* profile) | 30 ProfilePolicyContext::ProfilePolicyContext(Profile* profile) |
28 : profile_(profile) { | 31 : profile_(profile) { |
29 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 32 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
30 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 33 if (command_line->HasSwitch(switches::kCloudPolicyUrl)) { |
| 34 device_management_service_.reset(new DeviceManagementService( |
| 35 command_line->GetSwitchValueASCII(switches::kCloudPolicyUrl))); |
| 36 device_management_policy_provider_.reset( |
| 37 new policy::DeviceManagementPolicyProvider( |
| 38 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
| 39 device_management_service_->CreateBackend(), |
| 40 profile_, |
| 41 true)); |
| 42 } else if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
31 device_management_service_.reset(new DeviceManagementService( | 43 device_management_service_.reset(new DeviceManagementService( |
32 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); | 44 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); |
33 device_management_policy_provider_.reset( | 45 device_management_policy_provider_.reset( |
34 new policy::DeviceManagementPolicyProvider( | 46 new policy::DeviceManagementPolicyProvider( |
35 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), | 47 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
36 device_management_service_->CreateBackend(), | 48 device_management_service_->CreateBackend(), |
37 profile_)); | 49 profile_, |
| 50 false)); |
38 } | 51 } |
39 } | 52 } |
40 | 53 |
41 ProfilePolicyContext::~ProfilePolicyContext() { | 54 ProfilePolicyContext::~ProfilePolicyContext() { |
42 device_management_policy_provider_.reset(); | 55 device_management_policy_provider_.reset(); |
43 device_management_service_.reset(); | 56 device_management_service_.reset(); |
44 } | 57 } |
45 | 58 |
46 void ProfilePolicyContext::Initialize() { | 59 void ProfilePolicyContext::Initialize() { |
47 if (device_management_service_.get()) | 60 if (device_management_service_.get()) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (type == NotificationType::PREF_CHANGED && | 97 if (type == NotificationType::PREF_CHANGED && |
85 prefs::kPolicyRefreshRate == *(Details<std::string>(details).ptr()) && | 98 prefs::kPolicyRefreshRate == *(Details<std::string>(details).ptr()) && |
86 profile_->GetPrefs() == Source<PrefService>(source).ptr()) { | 99 profile_->GetPrefs() == Source<PrefService>(source).ptr()) { |
87 UpdatePolicyRefreshRate(); | 100 UpdatePolicyRefreshRate(); |
88 } else { | 101 } else { |
89 NOTREACHED(); | 102 NOTREACHED(); |
90 } | 103 } |
91 } | 104 } |
92 | 105 |
93 } // namespace policy | 106 } // namespace policy |
OLD | NEW |