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/app/chrome_main.h" | 5 #include "chrome/app/chrome_main_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #import "base/mac/foundation_util.h" | 14 #import "base/mac/foundation_util.h" |
15 #import "base/mac/scoped_nsautorelease_pool.h" | 15 #import "base/mac/scoped_nsautorelease_pool.h" |
16 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
17 #include "chrome/browser/policy/policy_path_parser.h" | 17 #include "chrome/browser/policy/policy_path_parser.h" |
18 #include "chrome/common/chrome_paths_internal.h" | 18 #include "chrome/common/chrome_paths_internal.h" |
19 #include "policy/policy_constants.h" | 19 #include "policy/policy_constants.h" |
20 | 20 |
21 namespace chrome_main { | |
22 | |
23 void CheckUserDataDirPolicy(FilePath* user_data_dir) { | 21 void CheckUserDataDirPolicy(FilePath* user_data_dir) { |
24 base::mac::ScopedNSAutoreleasePool pool; | 22 base::mac::ScopedNSAutoreleasePool pool; |
25 | 23 |
26 // Since the configuration management infrastructure is not initialized when | 24 // Since the configuration management infrastructure is not initialized when |
27 // this code runs, read the policy preference directly. | 25 // this code runs, read the policy preference directly. |
28 NSString* key = base::SysUTF8ToNSString(policy::key::kUserDataDir); | 26 NSString* key = base::SysUTF8ToNSString(policy::key::kUserDataDir); |
29 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 27 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
30 NSString* value = [defaults stringForKey:key]; | 28 NSString* value = [defaults stringForKey:key]; |
31 if (value && [defaults objectIsForcedForKey:key]) { | 29 if (value && [defaults objectIsForcedForKey:key]) { |
32 std::string string_value = base::SysNSStringToUTF8(value); | 30 std::string string_value = base::SysNSStringToUTF8(value); |
33 // Now replace any vars the user might have used. | 31 // Now replace any vars the user might have used. |
34 string_value = | 32 string_value = |
35 policy::path_parser::ExpandPathVariables(string_value); | 33 policy::path_parser::ExpandPathVariables(string_value); |
36 *user_data_dir = FilePath(string_value); | 34 *user_data_dir = FilePath(string_value); |
37 } | 35 } |
38 } | 36 } |
39 | 37 |
40 void SetUpBundleOverrides() { | 38 void SetUpBundleOverrides() { |
41 base::mac::ScopedNSAutoreleasePool pool; | 39 base::mac::ScopedNSAutoreleasePool pool; |
42 | 40 |
43 base::mac::SetOverrideAppBundlePath(chrome::GetFrameworkBundlePath()); | 41 base::mac::SetOverrideAppBundlePath(chrome::GetFrameworkBundlePath()); |
44 | 42 |
45 NSBundle* base_bundle = chrome::OuterAppBundle(); | 43 NSBundle* base_bundle = chrome::OuterAppBundle(); |
46 base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]); | 44 base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]); |
47 } | 45 } |
48 | |
49 } // namespace chrome_main | |
OLD | NEW |