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/configuration_policy_pref_store.h" | 5 #include "chrome/browser/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/string16.h" | 10 #include "base/string16.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "chrome/browser/configuration_policy_provider.h" | 13 #include "chrome/browser/configuration_policy_provider.h" |
| 14 #if defined(OS_WIN) |
| 15 #include "chrome/browser/configuration_policy_provider_win.h" |
| 16 #elif defined(OS_MACOSX) |
| 17 #include "chrome/browser/configuration_policy_provider_mac.h" |
| 18 #elif defined(OS_POSIX) |
| 19 #include "chrome/browser/config_dir_policy_provider.h" |
| 20 #endif |
| 21 #include "chrome/browser/dummy_configuration_policy_provider.h" |
| 22 #include "chrome/common/chrome_paths.h" |
13 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
15 | 25 |
16 const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry | 26 const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry |
17 ConfigurationPolicyPrefStore::simple_policy_map_[] = { | 27 ConfigurationPolicyPrefStore::simple_policy_map_[] = { |
18 { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, | 28 { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, |
19 { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, | 29 { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, |
20 prefs::kHomePageIsNewTabPage }, | 30 prefs::kHomePageIsNewTabPage }, |
21 { Value::TYPE_BOOLEAN, kPolicyAlternateErrorPagesEnabled, | 31 { Value::TYPE_BOOLEAN, kPolicyAlternateErrorPagesEnabled, |
22 prefs::kAlternateErrorPagesEnabled }, | 32 prefs::kAlternateErrorPagesEnabled }, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ApplyProxySwitches(); | 104 ApplyProxySwitches(); |
95 | 105 |
96 proxy_disabled_ = false; | 106 proxy_disabled_ = false; |
97 proxy_configuration_specified_ = false; | 107 proxy_configuration_specified_ = false; |
98 command_line_proxy_settings_cleared_ = false; | 108 command_line_proxy_settings_cleared_ = false; |
99 | 109 |
100 return (provider_.get() == NULL || provider_->Provide(this)) ? | 110 return (provider_.get() == NULL || provider_->Provide(this)) ? |
101 PrefStore::PREF_READ_ERROR_NONE : PrefStore::PREF_READ_ERROR_OTHER; | 111 PrefStore::PREF_READ_ERROR_NONE : PrefStore::PREF_READ_ERROR_OTHER; |
102 } | 112 } |
103 | 113 |
| 114 // static |
| 115 ConfigurationPolicyPrefStore* |
| 116 ConfigurationPolicyPrefStore::CreateManagedPolicyPrefStore() { |
| 117 ConfigurationPolicyProvider* provider; |
| 118 #if defined(OS_WIN) |
| 119 provider = new ConfigurationPolicyProviderWin(); |
| 120 #elif defined(OS_MACOSX) |
| 121 provider = new ConfigurationPolicyProviderMac(); |
| 122 #elif defined(OS_POSIX) |
| 123 FilePath config_dir_path; |
| 124 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) |
| 125 provider = new ConfigDirPolicyProvider( |
| 126 config_dir_path.Append(FILE_PATH_LITERAL("managed"))); |
| 127 else |
| 128 provider = new DummyConfigurationPolicyProvider(); |
| 129 #else |
| 130 provider = new DummyConfigurationPolicyProvider(); |
| 131 #endif |
| 132 |
| 133 return new ConfigurationPolicyPrefStore(CommandLine::ForCurrentProcess(), |
| 134 provider); |
| 135 } |
| 136 |
| 137 // static |
| 138 ConfigurationPolicyPrefStore* |
| 139 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() { |
| 140 ConfigurationPolicyProvider* provider; |
| 141 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 142 FilePath config_dir_path; |
| 143 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) |
| 144 provider = new ConfigDirPolicyProvider( |
| 145 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); |
| 146 else |
| 147 provider = new DummyConfigurationPolicyProvider(); |
| 148 #else |
| 149 provider = new DummyConfigurationPolicyProvider(); |
| 150 #endif |
| 151 |
| 152 return new ConfigurationPolicyPrefStore(CommandLine::ForCurrentProcess(), |
| 153 provider); |
| 154 } |
| 155 |
104 bool ConfigurationPolicyPrefStore::ApplyProxyPolicy(PolicyType policy, | 156 bool ConfigurationPolicyPrefStore::ApplyProxyPolicy(PolicyType policy, |
105 Value* value) { | 157 Value* value) { |
106 bool result = false; | 158 bool result = false; |
107 bool warn_about_proxy_disable_config = false; | 159 bool warn_about_proxy_disable_config = false; |
108 bool warn_about_proxy_system_config = false; | 160 bool warn_about_proxy_system_config = false; |
109 | 161 |
110 const PolicyToPreferenceMapEntry* match_entry_ = NULL; | 162 const PolicyToPreferenceMapEntry* match_entry_ = NULL; |
111 for (const PolicyToPreferenceMapEntry* current = proxy_policy_map_; | 163 for (const PolicyToPreferenceMapEntry* current = proxy_policy_map_; |
112 current != proxy_policy_map_ + arraysize(proxy_policy_map_); ++current) { | 164 current != proxy_policy_map_ + arraysize(proxy_policy_map_); ++current) { |
113 if (current->policy_type == policy) { | 165 if (current->policy_type == policy) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 return; | 355 return; |
304 | 356 |
305 if (ApplyPolicyFromMap(policy, value, simple_policy_map_, | 357 if (ApplyPolicyFromMap(policy, value, simple_policy_map_, |
306 arraysize(simple_policy_map_))) | 358 arraysize(simple_policy_map_))) |
307 return; | 359 return; |
308 | 360 |
309 // Other policy implementations go here. | 361 // Other policy implementations go here. |
310 NOTIMPLEMENTED(); | 362 NOTIMPLEMENTED(); |
311 delete value; | 363 delete value; |
312 } | 364 } |
OLD | NEW |