| 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 "chrome/browser/policy/configuration_policy_pref_store.h" | 5 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" | 24 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" |
| 25 #include "chrome/browser/search_engines/search_terms_data.h" | 25 #include "chrome/browser/search_engines/search_terms_data.h" |
| 26 #include "chrome/browser/search_engines/template_url.h" | 26 #include "chrome/browser/search_engines/template_url.h" |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/policy_constants.h" | 29 #include "chrome/common/policy_constants.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 | 31 |
| 32 namespace policy { | 32 namespace policy { |
| 33 | 33 |
| 34 // Manages the lifecycle of the shared platform-specific policy providers | 34 // Manages the lifecycle of the shared platform-specific policy providers for |
| 35 // for managed and recommended policy. Instantiated as a Singleton. | 35 // managed platform, device management and recommended policy. Instantiated as a |
| 36 // Singleton. |
| 36 class ConfigurationPolicyProviderKeeper { | 37 class ConfigurationPolicyProviderKeeper { |
| 37 public: | 38 public: |
| 38 ConfigurationPolicyProviderKeeper() | 39 ConfigurationPolicyProviderKeeper() |
| 39 : managed_provider_(CreateManagedProvider()), | 40 : managed_platform_provider_(CreateManagedPlatformProvider()), |
| 41 device_management_provider_(CreateDeviceManagementProvider()), |
| 40 recommended_provider_(CreateRecommendedProvider()) {} | 42 recommended_provider_(CreateRecommendedProvider()) {} |
| 41 virtual ~ConfigurationPolicyProviderKeeper() {} | 43 virtual ~ConfigurationPolicyProviderKeeper() {} |
| 42 | 44 |
| 43 ConfigurationPolicyProvider* managed_provider() const { | 45 ConfigurationPolicyProvider* managed_platform_provider() const { |
| 44 return managed_provider_.get(); | 46 return managed_platform_provider_.get(); |
| 45 } | 47 } |
| 46 | 48 |
| 47 ConfigurationPolicyProvider* recommended_provider() const { | 49 ConfigurationPolicyProvider* device_management_provider() const { |
| 50 return device_management_provider_.get(); |
| 51 } |
| 52 |
| 53 ConfigurationPolicyProvider* recommended_provider() const { |
| 48 return recommended_provider_.get(); | 54 return recommended_provider_.get(); |
| 49 } | 55 } |
| 50 | 56 |
| 51 private: | 57 private: |
| 52 scoped_ptr<ConfigurationPolicyProvider> managed_provider_; | 58 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_; |
| 59 scoped_ptr<ConfigurationPolicyProvider> device_management_provider_; |
| 53 scoped_ptr<ConfigurationPolicyProvider> recommended_provider_; | 60 scoped_ptr<ConfigurationPolicyProvider> recommended_provider_; |
| 54 | 61 |
| 55 static ConfigurationPolicyProvider* CreateManagedProvider(); | 62 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); |
| 63 static ConfigurationPolicyProvider* CreateDeviceManagementProvider(); |
| 56 static ConfigurationPolicyProvider* CreateRecommendedProvider(); | 64 static ConfigurationPolicyProvider* CreateRecommendedProvider(); |
| 57 | 65 |
| 58 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderKeeper); | 66 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderKeeper); |
| 59 }; | 67 }; |
| 60 | 68 |
| 61 | 69 |
| 62 ConfigurationPolicyProvider* | 70 ConfigurationPolicyProvider* |
| 63 ConfigurationPolicyProviderKeeper::CreateManagedProvider() { | 71 ConfigurationPolicyProviderKeeper::CreateDeviceManagementProvider() { |
| 64 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list = | 72 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list = |
| 65 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); | 73 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); |
| 66 #ifndef NDEBUG | |
| 67 // TODO(danno): This is a temporary solution only, the PrefValueStore needs to | |
| 68 // be changed to support two managed PrefStores, the local managed store and | |
| 69 // the device management policy store. | |
| 70 if (CommandLine::ForCurrentProcess()->HasSwitch( | 74 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 71 switches::kDeviceManagementUrl)) { | 75 switches::kDeviceManagementUrl)) { |
| 72 return new DeviceManagementPolicyProvider(policy_list); | 76 return new DeviceManagementPolicyProvider(policy_list); |
| 77 } else { |
| 78 return new DummyConfigurationPolicyProvider(policy_list); |
| 73 } | 79 } |
| 74 #endif | 80 } |
| 81 |
| 82 ConfigurationPolicyProvider* |
| 83 ConfigurationPolicyProviderKeeper::CreateManagedPlatformProvider() { |
| 84 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list = |
| 85 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); |
| 75 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 76 return new ConfigurationPolicyProviderWin(policy_list); | 87 return new ConfigurationPolicyProviderWin(policy_list); |
| 77 #elif defined(OS_MACOSX) | 88 #elif defined(OS_MACOSX) |
| 78 return new ConfigurationPolicyProviderMac(policy_list); | 89 return new ConfigurationPolicyProviderMac(policy_list); |
| 79 #elif defined(OS_POSIX) | 90 #elif defined(OS_POSIX) |
| 80 FilePath config_dir_path; | 91 FilePath config_dir_path; |
| 81 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | 92 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { |
| 82 return new ConfigDirPolicyProvider( | 93 return new ConfigDirPolicyProvider( |
| 83 policy_list, | 94 policy_list, |
| 84 config_dir_path.Append(FILE_PATH_LITERAL("managed"))); | 95 config_dir_path.Append(FILE_PATH_LITERAL("managed"))); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 arraysize(kSimplePolicyMap))) | 334 arraysize(kSimplePolicyMap))) |
| 324 return; | 335 return; |
| 325 | 336 |
| 326 // Other policy implementations go here. | 337 // Other policy implementations go here. |
| 327 NOTIMPLEMENTED(); | 338 NOTIMPLEMENTED(); |
| 328 delete value; | 339 delete value; |
| 329 } | 340 } |
| 330 | 341 |
| 331 // static | 342 // static |
| 332 ConfigurationPolicyPrefStore* | 343 ConfigurationPolicyPrefStore* |
| 333 ConfigurationPolicyPrefStore::CreateManagedPolicyPrefStore() { | 344 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() { |
| 334 ConfigurationPolicyProviderKeeper* keeper = | 345 ConfigurationPolicyProviderKeeper* keeper = |
| 335 Singleton<ConfigurationPolicyProviderKeeper>::get(); | 346 Singleton<ConfigurationPolicyProviderKeeper>::get(); |
| 336 return new ConfigurationPolicyPrefStore(keeper->managed_provider()); | 347 return new ConfigurationPolicyPrefStore(keeper->managed_platform_provider()); |
| 337 } | 348 } |
| 338 | 349 |
| 339 // static | 350 // static |
| 351 ConfigurationPolicyPrefStore* |
| 352 ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore() { |
| 353 ConfigurationPolicyProviderKeeper* keeper = |
| 354 Singleton<ConfigurationPolicyProviderKeeper>::get(); |
| 355 return new ConfigurationPolicyPrefStore( |
| 356 keeper->device_management_provider()); |
| 357 } |
| 358 |
| 359 // static |
| 340 ConfigurationPolicyPrefStore* | 360 ConfigurationPolicyPrefStore* |
| 341 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() { | 361 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() { |
| 342 ConfigurationPolicyProviderKeeper* keeper = | 362 ConfigurationPolicyProviderKeeper* keeper = |
| 343 Singleton<ConfigurationPolicyProviderKeeper>::get(); | 363 Singleton<ConfigurationPolicyProviderKeeper>::get(); |
| 344 return new ConfigurationPolicyPrefStore(keeper->recommended_provider()); | 364 return new ConfigurationPolicyPrefStore(keeper->recommended_provider()); |
| 345 } | 365 } |
| 346 | 366 |
| 347 // static | 367 // static |
| 348 void ConfigurationPolicyPrefStore::GetProxyPreferenceSet( | 368 void ConfigurationPolicyPrefStore::GetProxyPreferenceSet( |
| 349 ProxyPreferenceSet* proxy_pref_set) { | 369 ProxyPreferenceSet* proxy_pref_set) { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 std::string()); | 618 std::string()); |
| 599 return; | 619 return; |
| 600 } | 620 } |
| 601 } | 621 } |
| 602 // Required entries are not there. Remove any related entries. | 622 // Required entries are not there. Remove any related entries. |
| 603 RemovePreferencesOfMap(kDefaultSearchPolicyMap, | 623 RemovePreferencesOfMap(kDefaultSearchPolicyMap, |
| 604 arraysize(kDefaultSearchPolicyMap)); | 624 arraysize(kDefaultSearchPolicyMap)); |
| 605 } | 625 } |
| 606 | 626 |
| 607 } // namespace policy | 627 } // namespace policy |
| OLD | NEW |