| OLD | NEW |
| 1 // Copyright (c) 2010 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/configuration_policy_provider_mac.h" | 5 #include "chrome/browser/policy/configuration_policy_provider_mac.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 8 #include "base/logging.h" | |
| 9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/platform_file.h" |
| 11 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 13 #include "chrome/browser/preferences_mac.h" |
| 12 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 13 | 15 |
| 14 namespace policy { | 16 namespace policy { |
| 15 | 17 |
| 16 static FilePath GetManagedPolicyPath() { | 18 namespace { |
| 19 |
| 20 FilePath GetManagedPolicyPath() { |
| 17 // This constructs the path to the plist file in which Mac OS X stores the | 21 // This constructs the path to the plist file in which Mac OS X stores the |
| 18 // managed preference for the application. This is undocumented and therefore | 22 // managed preference for the application. This is undocumented and therefore |
| 19 // fragile, but if it doesn't work out, FileBasedPolicyLoader has a task that | 23 // fragile, but if it doesn't work out, FileBasedPolicyLoader has a task that |
| 20 // polls periodically in order to reload managed preferences later even if we | 24 // polls periodically in order to reload managed preferences later even if we |
| 21 // missed the change. | 25 // missed the change. |
| 22 FilePath path; | 26 FilePath path; |
| 23 if (!PathService::Get(chrome::DIR_MANAGED_PREFS, &path)) | 27 if (!PathService::Get(chrome::DIR_MANAGED_PREFS, &path)) |
| 24 return FilePath(); | 28 return FilePath(); |
| 25 | 29 |
| 26 CFBundleRef bundle(CFBundleGetMainBundle()); | 30 CFBundleRef bundle(CFBundleGetMainBundle()); |
| 27 if (!bundle) | 31 if (!bundle) |
| 28 return FilePath(); | 32 return FilePath(); |
| 29 | 33 |
| 30 CFStringRef bundle_id = CFBundleGetIdentifier(bundle); | 34 CFStringRef bundle_id = CFBundleGetIdentifier(bundle); |
| 31 if (!bundle_id) | 35 if (!bundle_id) |
| 32 return FilePath(); | 36 return FilePath(); |
| 33 | 37 |
| 34 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); | 38 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); |
| 35 } | 39 } |
| 36 | 40 |
| 41 } // namespace |
| 42 |
| 37 MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate( | 43 MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate( |
| 38 MacPreferences* preferences, | 44 MacPreferences* preferences, |
| 39 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) | 45 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) |
| 40 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()), | 46 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()), |
| 41 policy_list_(policy_list), | 47 policy_list_(policy_list), |
| 42 preferences_(preferences) { | 48 preferences_(preferences) { |
| 43 } | 49 } |
| 44 | 50 |
| 45 MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {} | 51 MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {} |
| 46 | 52 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 137 |
| 132 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac( | 138 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac( |
| 133 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, | 139 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, |
| 134 MacPreferences* preferences) | 140 MacPreferences* preferences) |
| 135 : FileBasedPolicyProvider(policy_list, | 141 : FileBasedPolicyProvider(policy_list, |
| 136 new MacPreferencesPolicyProviderDelegate(preferences, | 142 new MacPreferencesPolicyProviderDelegate(preferences, |
| 137 policy_list)) { | 143 policy_list)) { |
| 138 } | 144 } |
| 139 | 145 |
| 140 } // namespace policy | 146 } // namespace policy |
| OLD | NEW |