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_mac.h" | 5 #include "chrome/app/chrome_main_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <mach/mach.h> | |
9 #include <servers/bootstrap.h> | |
10 | 8 |
11 #include <string> | 9 #include <string> |
12 | 10 |
13 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
14 #include "base/file_path.h" | 12 #include "base/file_path.h" |
15 #include "base/logging.h" | 13 #include "base/logging.h" |
16 #import "base/mac/foundation_util.h" | 14 #import "base/mac/foundation_util.h" |
17 #import "base/mac/scoped_nsautorelease_pool.h" | 15 #import "base/mac/scoped_nsautorelease_pool.h" |
18 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
19 #include "chrome/browser/policy/policy_path_parser.h" | 17 #include "chrome/browser/policy/policy_path_parser.h" |
(...skipping 18 matching lines...) Expand all Loading... |
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 void SwitchToMachBootstrapSubsetPort() { | |
50 // Testing tip: use launchctl bstree (as root) to make sure that the | |
51 // subset port is created properly and that new mappings wind up added to | |
52 // the subset port. | |
53 | |
54 #ifndef NDEBUG | |
55 static bool once_only = false; | |
56 DCHECK(!once_only); | |
57 once_only = true; | |
58 #endif | |
59 | |
60 mach_port_t self_task = mach_task_self(); | |
61 | |
62 mach_port_t original_bootstrap_port; | |
63 kern_return_t kr = task_get_bootstrap_port(self_task, | |
64 &original_bootstrap_port); | |
65 if (kr != KERN_SUCCESS) { | |
66 LOG(ERROR) << "task_get_bootstrap_port: " << kr << " " | |
67 << mach_error_string(kr); | |
68 return; | |
69 } | |
70 | |
71 mach_port_t bootstrap_subset_port; | |
72 kr = bootstrap_subset(original_bootstrap_port, | |
73 self_task, | |
74 &bootstrap_subset_port); | |
75 if (kr != BOOTSTRAP_SUCCESS) { | |
76 LOG(ERROR) << "bootstrap_subset: " << kr << " " << bootstrap_strerror(kr); | |
77 return; | |
78 } | |
79 | |
80 kr = task_set_bootstrap_port(self_task, bootstrap_subset_port); | |
81 if (kr != KERN_SUCCESS) { | |
82 LOG(ERROR) << "task_set_bootstrap_port: " << kr << " " | |
83 << mach_error_string(kr); | |
84 return; | |
85 } | |
86 | |
87 // Users of the bootstrap port often access it through this global variable. | |
88 bootstrap_port = bootstrap_subset_port; | |
89 } | |
OLD | NEW |