| 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 "chrome/browser/policy/browser_policy_connector.h" | 5 #include "chrome/browser/policy/browser_policy_connector.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 24 #include "chrome/browser/policy/configuration_policy_provider_win.h" | 24 #include "chrome/browser/policy/configuration_policy_provider_win.h" |
| 25 #elif defined(OS_MACOSX) | 25 #elif defined(OS_MACOSX) |
| 26 #include "chrome/browser/policy/configuration_policy_provider_mac.h" | 26 #include "chrome/browser/policy/configuration_policy_provider_mac.h" |
| 27 #elif defined(OS_POSIX) | 27 #elif defined(OS_POSIX) |
| 28 #include "chrome/browser/policy/config_dir_policy_provider.h" | 28 #include "chrome/browser/policy/config_dir_policy_provider.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
| 32 #include "chrome/browser/policy/device_policy_cache.h" |
| 32 #include "chrome/browser/policy/device_policy_identity_strategy.h" | 33 #include "chrome/browser/policy/device_policy_identity_strategy.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 namespace { | |
| 36 | |
| 37 const FilePath::CharType kDevicePolicyCacheFile[] = | |
| 38 FILE_PATH_LITERAL("Policy"); | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 42 namespace policy { | 36 namespace policy { |
| 43 | 37 |
| 44 BrowserPolicyConnector::BrowserPolicyConnector() { | 38 BrowserPolicyConnector::BrowserPolicyConnector() { |
| 45 managed_platform_provider_.reset(CreateManagedPlatformProvider()); | 39 managed_platform_provider_.reset(CreateManagedPlatformProvider()); |
| 46 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); | 40 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); |
| 47 registrar_.Add(this, NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, | 41 registrar_.Add(this, NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, |
| 48 NotificationService::AllSources()); | 42 NotificationService::AllSources()); |
| 49 | 43 |
| 50 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 51 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 45 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 52 if (command_line->HasSwitch(switches::kDevicePolicyCacheDir)) { | 46 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { |
| 53 FilePath cache_dir(command_line->GetSwitchValuePath( | 47 identity_strategy_.reset(new DevicePolicyIdentityStrategy()); |
| 54 switches::kDevicePolicyCacheDir)); | 48 cloud_policy_subsystem_.reset( |
| 55 | 49 new CloudPolicySubsystem(identity_strategy_.get(), |
| 56 if (!file_util::CreateDirectory(cache_dir)) { | 50 new DevicePolicyCache())); |
| 57 LOG(WARNING) << "Device policy cache directory " | |
| 58 << cache_dir.value() | |
| 59 << " is not accessible, skipping initialization."; | |
| 60 } else { | |
| 61 identity_strategy_.reset(new DevicePolicyIdentityStrategy()); | |
| 62 cloud_policy_subsystem_.reset( | |
| 63 new CloudPolicySubsystem(cache_dir.Append(kDevicePolicyCacheFile), | |
| 64 identity_strategy_.get())); | |
| 65 } | |
| 66 } | 51 } |
| 67 #endif | 52 #endif |
| 68 } | 53 } |
| 69 | 54 |
| 70 BrowserPolicyConnector::BrowserPolicyConnector( | 55 BrowserPolicyConnector::BrowserPolicyConnector( |
| 71 ConfigurationPolicyProvider* managed_platform_provider, | 56 ConfigurationPolicyProvider* managed_platform_provider, |
| 72 ConfigurationPolicyProvider* recommended_platform_provider) | 57 ConfigurationPolicyProvider* recommended_platform_provider) |
| 73 : managed_platform_provider_(managed_platform_provider), | 58 : managed_platform_provider_(managed_platform_provider), |
| 74 recommended_platform_provider_(recommended_platform_provider) {} | 59 recommended_platform_provider_(recommended_platform_provider) {} |
| 75 | 60 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 DCHECK(local_state); | 155 DCHECK(local_state); |
| 171 DCHECK(request_context); | 156 DCHECK(request_context); |
| 172 if (cloud_policy_subsystem_.get()) { | 157 if (cloud_policy_subsystem_.get()) { |
| 173 cloud_policy_subsystem_->Initialize(local_state, | 158 cloud_policy_subsystem_->Initialize(local_state, |
| 174 prefs::kPolicyDevicePolicyRefreshRate, | 159 prefs::kPolicyDevicePolicyRefreshRate, |
| 175 request_context); | 160 request_context); |
| 176 } | 161 } |
| 177 } | 162 } |
| 178 | 163 |
| 179 } // namespace | 164 } // namespace |
| OLD | NEW |