Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/policy/configuration_policy_provider_mac.cc

Issue 8258018: Generate Chrome policy definition list from policy_templates.json. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the unittest fix Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.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/platform_file.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "chrome/browser/preferences_mac.h" 13 #include "chrome/browser/preferences_mac.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "policy/policy_constants.h"
15 16
16 namespace policy { 17 namespace policy {
17 18
18 namespace { 19 namespace {
19 20
20 FilePath GetManagedPolicyPath() { 21 FilePath GetManagedPolicyPath() {
21 // This constructs the path to the plist file in which Mac OS X stores the 22 // This constructs the path to the plist file in which Mac OS X stores the
22 // managed preference for the application. This is undocumented and therefore 23 // managed preference for the application. This is undocumented and therefore
23 // fragile, but if it doesn't work out, FileBasedPolicyLoader has a task that 24 // fragile, but if it doesn't work out, FileBasedPolicyLoader has a task that
24 // polls periodically in order to reload managed preferences later even if we 25 // polls periodically in order to reload managed preferences later even if we
(...skipping 10 matching lines...) Expand all
35 if (!bundle_id) 36 if (!bundle_id)
36 return FilePath(); 37 return FilePath();
37 38
38 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); 39 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist");
39 } 40 }
40 41
41 } // namespace 42 } // namespace
42 43
43 MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate( 44 MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate(
44 MacPreferences* preferences, 45 MacPreferences* preferences,
45 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) 46 const PolicyDefinitionList* policy_list)
46 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()), 47 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()),
47 policy_list_(policy_list), 48 policy_list_(policy_list),
48 preferences_(preferences) { 49 preferences_(preferences) {
49 } 50 }
50 51
51 MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {} 52 MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {}
52 53
53 DictionaryValue* MacPreferencesPolicyProviderDelegate::Load() { 54 DictionaryValue* MacPreferencesPolicyProviderDelegate::Load() {
54 preferences_->AppSynchronize(kCFPreferencesCurrentApplication); 55 preferences_->AppSynchronize(kCFPreferencesCurrentApplication);
55 DictionaryValue* policy = new DictionaryValue; 56 DictionaryValue* policy = new DictionaryValue;
56 57
57 const ConfigurationPolicyProvider::PolicyDefinitionList::Entry* current; 58 const PolicyDefinitionList::Entry* current;
58 for (current = policy_list_->begin; current != policy_list_->end; ++current) { 59 for (current = policy_list_->begin; current != policy_list_->end; ++current) {
59 base::mac::ScopedCFTypeRef<CFStringRef> name( 60 base::mac::ScopedCFTypeRef<CFStringRef> name(
60 base::SysUTF8ToCFStringRef(current->name)); 61 base::SysUTF8ToCFStringRef(current->name));
61 base::mac::ScopedCFTypeRef<CFPropertyListRef> value( 62 base::mac::ScopedCFTypeRef<CFPropertyListRef> value(
62 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication)); 63 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication));
63 if (!value.get()) 64 if (!value.get())
64 continue; 65 continue;
65 if (!preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication)) 66 if (!preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication))
66 continue; 67 continue;
67 68
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 base::PlatformFileInfo file_info; 123 base::PlatformFileInfo file_info;
123 if (!file_util::GetFileInfo(config_file_path(), &file_info) || 124 if (!file_util::GetFileInfo(config_file_path(), &file_info) ||
124 file_info.is_directory) { 125 file_info.is_directory) {
125 return base::Time(); 126 return base::Time();
126 } 127 }
127 128
128 return file_info.last_modified; 129 return file_info.last_modified;
129 } 130 }
130 131
131 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac( 132 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac(
132 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) 133 const PolicyDefinitionList* policy_list)
133 : FileBasedPolicyProvider(policy_list, 134 : FileBasedPolicyProvider(policy_list,
134 new MacPreferencesPolicyProviderDelegate(new MacPreferences, 135 new MacPreferencesPolicyProviderDelegate(new MacPreferences,
135 policy_list)) { 136 policy_list)) {
136 } 137 }
137 138
138 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac( 139 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac(
139 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, 140 const PolicyDefinitionList* policy_list,
140 MacPreferences* preferences) 141 MacPreferences* preferences)
141 : FileBasedPolicyProvider(policy_list, 142 : FileBasedPolicyProvider(policy_list,
142 new MacPreferencesPolicyProviderDelegate(preferences, 143 new MacPreferencesPolicyProviderDelegate(preferences,
143 policy_list)) { 144 policy_list)) {
144 } 145 }
145 146
146 } // namespace policy 147 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698