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

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

Issue 5562002: Refactor FileBasedPolicyProvider, introduce AsynchronousPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with TOT Created 10 years 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) 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_provider_mac.h" 5 #include "chrome/browser/policy/configuration_policy_provider_mac.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.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"
(...skipping 16 matching lines...) Expand all
27 if (!bundle) 27 if (!bundle)
28 return FilePath(); 28 return FilePath();
29 29
30 CFStringRef bundle_id = CFBundleGetIdentifier(bundle); 30 CFStringRef bundle_id = CFBundleGetIdentifier(bundle);
31 if (!bundle_id) 31 if (!bundle_id)
32 return FilePath(); 32 return FilePath();
33 33
34 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); 34 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist");
35 } 35 }
36 36
37 MacPreferencesPolicyLoader::MacPreferencesPolicyLoader( 37 MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate(
38 MacPreferences* preferences, 38 MacPreferences* preferences,
39 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) 39 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list)
40 : FileBasedPolicyProvider::Delegate(GetManagedPolicyPath()), 40 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()),
41 policy_list_(policy_list), 41 policy_list_(policy_list),
42 preferences_(preferences) { 42 preferences_(preferences) {
43 } 43 }
44 44
45 DictionaryValue* MacPreferencesPolicyLoader::Load() { 45 DictionaryValue* MacPreferencesPolicyProviderDelegate::Load() {
46 preferences_->AppSynchronize(kCFPreferencesCurrentApplication); 46 preferences_->AppSynchronize(kCFPreferencesCurrentApplication);
47 DictionaryValue* policy = new DictionaryValue; 47 DictionaryValue* policy = new DictionaryValue;
48 48
49 const ConfigurationPolicyProvider::PolicyDefinitionList::Entry* current; 49 const ConfigurationPolicyProvider::PolicyDefinitionList::Entry* current;
50 for (current = policy_list_->begin; current != policy_list_->end; ++current) { 50 for (current = policy_list_->begin; current != policy_list_->end; ++current) {
51 base::mac::ScopedCFTypeRef<CFStringRef> name( 51 base::mac::ScopedCFTypeRef<CFStringRef> name(
52 base::SysUTF8ToCFStringRef(current->name)); 52 base::SysUTF8ToCFStringRef(current->name));
53 base::mac::ScopedCFTypeRef<CFPropertyListRef> value( 53 base::mac::ScopedCFTypeRef<CFPropertyListRef> value(
54 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication)); 54 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication));
55 if (!value.get()) 55 if (!value.get())
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 break; 104 break;
105 default: 105 default:
106 NOTREACHED(); 106 NOTREACHED();
107 } 107 }
108 } 108 }
109 109
110 return policy; 110 return policy;
111 } 111 }
112 112
113 base::Time MacPreferencesPolicyLoader::GetLastModification() { 113 base::Time MacPreferencesPolicyProviderDelegate::GetLastModification() {
114 base::PlatformFileInfo file_info; 114 base::PlatformFileInfo file_info;
115 if (!file_util::GetFileInfo(config_file_path(), &file_info) || 115 if (!file_util::GetFileInfo(config_file_path(), &file_info) ||
116 file_info.is_directory) { 116 file_info.is_directory) {
117 return base::Time(); 117 return base::Time();
118 } 118 }
119 119
120 return file_info.last_modified; 120 return file_info.last_modified;
121 } 121 }
122 122
123 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac( 123 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac(
124 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) 124 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list)
125 : FileBasedPolicyProvider(policy_list, 125 : FileBasedPolicyProvider(policy_list,
126 new MacPreferencesPolicyLoader(new MacPreferences, policy_list)) { 126 new MacPreferencesPolicyProviderDelegate(new MacPreferences,
127 policy_list)) {
127 } 128 }
128 129
129 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac( 130 ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac(
130 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, 131 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list,
131 MacPreferences* preferences) 132 MacPreferences* preferences)
132 : FileBasedPolicyProvider(policy_list, 133 : FileBasedPolicyProvider(policy_list,
133 new MacPreferencesPolicyLoader(preferences, policy_list)) { 134 new MacPreferencesPolicyProviderDelegate(preferences,
135 policy_list)) {
134 } 136 }
135 137
136 } // namespace policy 138 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_provider_mac.h ('k') | chrome/browser/policy/file_based_policy_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698