OLD | NEW |
---|---|
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/policy_path_parser.h" | 5 #include "chrome/browser/policy/policy_path_parser.h" |
6 | 6 |
7 #include "base/basictypes.h" | |
8 #include "base/file_path.h" | |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #import "base/mac/scoped_nsautorelease_pool.h" | |
12 #include "policy/policy_constants.h" | |
9 | 13 |
10 #import <Cocoa/Cocoa.h> | 14 #import <Cocoa/Cocoa.h> |
11 #import <SystemConfiguration/SCDynamicStore.h> | 15 #import <SystemConfiguration/SCDynamicStore.h> |
12 #import <SystemConfiguration/SCDynamicStoreCopySpecific.h> | 16 #import <SystemConfiguration/SCDynamicStoreCopySpecific.h> |
13 | 17 |
14 #include <string> | 18 #include <string> |
15 | 19 |
16 namespace policy { | 20 namespace policy { |
17 | 21 |
18 namespace path_parser { | 22 namespace path_parser { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 base::SysCFStringRefToUTF8(machinename)); | 87 base::SysCFStringRefToUTF8(machinename)); |
84 CFRelease(machinename); | 88 CFRelease(machinename); |
85 } else { | 89 } else { |
86 LOG(ERROR) << "Machine name variable can not be resolved."; | 90 LOG(ERROR) << "Machine name variable can not be resolved."; |
87 } | 91 } |
88 CFRelease(store); | 92 CFRelease(store); |
89 } | 93 } |
90 return result; | 94 return result; |
91 } | 95 } |
92 | 96 |
97 void CheckUserDataDirPolicy(base::FilePath* user_data_dir) { | |
98 base::mac::ScopedNSAutoreleasePool pool; | |
99 | |
100 // Since the configuration management infrastructure is not initialized when | |
101 // this code runs, read the policy preference directly. | |
102 NSString* key = base::SysUTF8ToNSString(policy::key::kUserDataDir); | |
103 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | |
104 NSString* value = [defaults stringForKey:key]; | |
105 if (value && [defaults objectIsForcedForKey:key]) { | |
106 std::string string_value = base::SysNSStringToUTF8(value); | |
107 // Now replace any vars the user might have used. | |
108 string_value = | |
109 policy::path_parser::ExpandPathVariables(string_value); | |
110 *user_data_dir = FilePath(string_value); | |
brettw
2013/02/19 04:49:52
Use base::FilePath
pastarmovj
2013/02/19 14:09:43
Done.
| |
111 } | |
112 } | |
113 | |
93 } // namespace path_parser | 114 } // namespace path_parser |
94 | 115 |
95 } // namespace policy | 116 } // namespace policy |
OLD | NEW |