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