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

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

Issue 10384145: Removed ConfigurationPolicyProvider::Provide(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string>
8
7 #include "base/file_path.h" 9 #include "base/file_path.h"
8 #include "base/file_util.h" 10 #include "base/file_util.h"
9 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
10 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
11 #include "base/path_service.h" 13 #include "base/path_service.h"
12 #include "base/platform_file.h" 14 #include "base/platform_file.h"
13 #include "base/sys_string_conversions.h" 15 #include "base/sys_string_conversions.h"
14 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/policy/policy_bundle.h"
15 #include "chrome/browser/policy/policy_map.h" 18 #include "chrome/browser/policy/policy_map.h"
16 #include "chrome/browser/preferences_mac.h" 19 #include "chrome/browser/preferences_mac.h"
17 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
18 #include "policy/policy_constants.h" 21 #include "policy/policy_constants.h"
19 22
20 using base::mac::CFCast; 23 using base::mac::CFCast;
21 using base::mac::ScopedCFTypeRef; 24 using base::mac::ScopedCFTypeRef;
22 25
23 namespace policy { 26 namespace policy {
24 27
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 MacPreferences* preferences, 80 MacPreferences* preferences,
78 const PolicyDefinitionList* policy_list, 81 const PolicyDefinitionList* policy_list,
79 PolicyLevel level) 82 PolicyLevel level)
80 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()), 83 : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()),
81 policy_list_(policy_list), 84 policy_list_(policy_list),
82 preferences_(preferences), 85 preferences_(preferences),
83 level_(level) {} 86 level_(level) {}
84 87
85 MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {} 88 MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {}
86 89
87 PolicyMap* MacPreferencesPolicyProviderDelegate::Load() { 90 scoped_ptr<PolicyBundle> MacPreferencesPolicyProviderDelegate::Load() {
88 preferences_->AppSynchronize(kCFPreferencesCurrentApplication); 91 preferences_->AppSynchronize(kCFPreferencesCurrentApplication);
89 PolicyMap* policies = new PolicyMap; 92 scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
93 PolicyMap& chrome_policy = bundle->Get(POLICY_DOMAIN_CHROME, std::string());
90 94
91 const PolicyDefinitionList::Entry* current; 95 const PolicyDefinitionList::Entry* current;
92 for (current = policy_list_->begin; current != policy_list_->end; ++current) { 96 for (current = policy_list_->begin; current != policy_list_->end; ++current) {
93 base::mac::ScopedCFTypeRef<CFStringRef> name( 97 base::mac::ScopedCFTypeRef<CFStringRef> name(
94 base::SysUTF8ToCFStringRef(current->name)); 98 base::SysUTF8ToCFStringRef(current->name));
95 base::mac::ScopedCFTypeRef<CFPropertyListRef> value( 99 base::mac::ScopedCFTypeRef<CFPropertyListRef> value(
96 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication)); 100 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication));
97 if (!value.get()) 101 if (!value.get())
98 continue; 102 continue;
99 bool forced = 103 bool forced =
100 preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication); 104 preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication);
101 PolicyLevel level = forced ? POLICY_LEVEL_MANDATORY : 105 PolicyLevel level = forced ? POLICY_LEVEL_MANDATORY :
102 POLICY_LEVEL_RECOMMENDED; 106 POLICY_LEVEL_RECOMMENDED;
103 if (level != level_) 107 if (level != level_)
104 continue; 108 continue;
105 109
106 // TODO(joaodasilva): figure the policy scope. 110 // TODO(joaodasilva): figure the policy scope.
107 111
108 base::Value* policy = CreateValueFromProperty(value); 112 base::Value* policy = CreateValueFromProperty(value);
109 if (policy) 113 if (policy)
110 policies->Set(current->name, level_, POLICY_SCOPE_USER, policy); 114 chrome_policy.Set(current->name, level_, POLICY_SCOPE_USER, policy);
111 } 115 }
112 116
113 return policies; 117 return bundle.Pass();
114 } 118 }
115 119
116 base::Time MacPreferencesPolicyProviderDelegate::GetLastModification() { 120 base::Time MacPreferencesPolicyProviderDelegate::GetLastModification() {
117 base::PlatformFileInfo file_info; 121 base::PlatformFileInfo file_info;
118 if (!file_util::GetFileInfo(config_file_path(), &file_info) || 122 if (!file_util::GetFileInfo(config_file_path(), &file_info) ||
119 file_info.is_directory) { 123 file_info.is_directory) {
120 return base::Time(); 124 return base::Time();
121 } 125 }
122 126
123 return file_info.last_modified; 127 return file_info.last_modified;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const PolicyDefinitionList* policy_list, 184 const PolicyDefinitionList* policy_list,
181 PolicyLevel level, 185 PolicyLevel level,
182 MacPreferences* preferences) 186 MacPreferences* preferences)
183 : FileBasedPolicyProvider( 187 : FileBasedPolicyProvider(
184 policy_list, 188 policy_list,
185 new MacPreferencesPolicyProviderDelegate(preferences, 189 new MacPreferencesPolicyProviderDelegate(preferences,
186 policy_list, 190 policy_list,
187 level)) {} 191 level)) {}
188 192
189 } // namespace policy 193 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698