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

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

Issue 14294008: Add UMA histograms for policy loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 7 years, 8 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
« no previous file with comments | « chrome/browser/policy/policy_load_status.cc ('k') | chrome/browser/policy/policy_loader_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/policy_loader_mac.h" 5 #include "chrome/browser/policy/policy_loader_mac.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/mac/foundation_util.h" 12 #include "base/mac/foundation_util.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/platform_file.h" 15 #include "base/platform_file.h"
16 #include "base/strings/sys_string_conversions.h" 16 #include "base/strings/sys_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/policy/policy_bundle.h" 18 #include "chrome/browser/policy/policy_bundle.h"
19 #include "chrome/browser/policy/policy_load_status.h"
19 #include "chrome/browser/policy/policy_map.h" 20 #include "chrome/browser/policy/policy_map.h"
20 #include "chrome/browser/policy/preferences_mac.h" 21 #include "chrome/browser/policy/preferences_mac.h"
21 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
22 #include "policy/policy_constants.h" 23 #include "policy/policy_constants.h"
23 24
24 using base::mac::CFCast; 25 using base::mac::CFCast;
25 using base::mac::ScopedCFTypeRef; 26 using base::mac::ScopedCFTypeRef;
26 27
27 namespace policy { 28 namespace policy {
28 29
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 base::Bind(&PolicyLoaderMac::OnFileUpdated, base::Unretained(this))); 93 base::Bind(&PolicyLoaderMac::OnFileUpdated, base::Unretained(this)));
93 } 94 }
94 } 95 }
95 96
96 scoped_ptr<PolicyBundle> PolicyLoaderMac::Load() { 97 scoped_ptr<PolicyBundle> PolicyLoaderMac::Load() {
97 preferences_->AppSynchronize(kCFPreferencesCurrentApplication); 98 preferences_->AppSynchronize(kCFPreferencesCurrentApplication);
98 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); 99 scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
99 PolicyMap& chrome_policy = 100 PolicyMap& chrome_policy =
100 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); 101 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
101 102
103 PolicyLoadStatusSample status;
104 bool policy_present = false;
102 const PolicyDefinitionList::Entry* current; 105 const PolicyDefinitionList::Entry* current;
103 for (current = policy_list_->begin; current != policy_list_->end; ++current) { 106 for (current = policy_list_->begin; current != policy_list_->end; ++current) {
104 base::mac::ScopedCFTypeRef<CFStringRef> name( 107 base::mac::ScopedCFTypeRef<CFStringRef> name(
105 base::SysUTF8ToCFStringRef(current->name)); 108 base::SysUTF8ToCFStringRef(current->name));
106 base::mac::ScopedCFTypeRef<CFPropertyListRef> value( 109 base::mac::ScopedCFTypeRef<CFPropertyListRef> value(
107 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication)); 110 preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication));
108 if (!value.get()) 111 if (!value.get())
109 continue; 112 continue;
113 policy_present = true;
110 bool forced = 114 bool forced =
111 preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication); 115 preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication);
112 PolicyLevel level = forced ? POLICY_LEVEL_MANDATORY : 116 PolicyLevel level = forced ? POLICY_LEVEL_MANDATORY :
113 POLICY_LEVEL_RECOMMENDED; 117 POLICY_LEVEL_RECOMMENDED;
114 // TODO(joaodasilva): figure the policy scope. 118 // TODO(joaodasilva): figure the policy scope.
115 base::Value* policy = CreateValueFromProperty(value); 119 base::Value* policy = CreateValueFromProperty(value);
116 if (policy) 120 if (policy)
117 chrome_policy.Set(current->name, level, POLICY_SCOPE_USER, policy); 121 chrome_policy.Set(current->name, level, POLICY_SCOPE_USER, policy);
122 else
123 status.Add(POLICY_LOAD_STATUS_PARSE_ERROR);
118 } 124 }
119 125
126 if (!policy_present)
127 status.Add(POLICY_LOAD_STATUS_NO_POLICY);
128
120 return bundle.Pass(); 129 return bundle.Pass();
121 } 130 }
122 131
123 base::Time PolicyLoaderMac::LastModificationTime() { 132 base::Time PolicyLoaderMac::LastModificationTime() {
124 base::PlatformFileInfo file_info; 133 base::PlatformFileInfo file_info;
125 if (!file_util::GetFileInfo(managed_policy_path_, &file_info) || 134 if (!file_util::GetFileInfo(managed_policy_path_, &file_info) ||
126 file_info.is_directory) { 135 file_info.is_directory) {
127 return base::Time(); 136 return base::Time();
128 } 137 }
129 138
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 182
174 return NULL; 183 return NULL;
175 } 184 }
176 185
177 void PolicyLoaderMac::OnFileUpdated(const base::FilePath& path, bool error) { 186 void PolicyLoaderMac::OnFileUpdated(const base::FilePath& path, bool error) {
178 if (!error) 187 if (!error)
179 Reload(false); 188 Reload(false);
180 } 189 }
181 190
182 } // namespace policy 191 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_load_status.cc ('k') | chrome/browser/policy/policy_loader_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698