Chromium Code Reviews| 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 "content/renderer/renderer_main_platform_delegate.h" | 5 #include "content/renderer/renderer_main_platform_delegate.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <objc/runtime.h> | 9 #include <objc/runtime.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 15 #include "base/mac/scoped_cftyperef.h" | 15 #include "base/mac/scoped_cftyperef.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "content/common/sandbox_init_mac.h" | 18 #include "content/common/sandbox_init_mac.h" |
| 19 #include "content/common/sandbox_mac.h" | 19 #include "content/common/sandbox_mac.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 | 21 |
| 22 extern "C" { | |
| 23 OSStatus SetApplicationIsDaemon(Boolean isDaemon); | |
| 24 }; | |
| 25 | |
| 22 namespace content { | 26 namespace content { |
| 23 | 27 |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 // You are about to read a pretty disgusting hack. In a static initializer, | 30 // You are about to read a pretty disgusting hack. In a static initializer, |
| 27 // CoreFoundation decides to connect with cfprefsd(8) using Mach IPC. There is | 31 // CoreFoundation decides to connect with cfprefsd(8) using Mach IPC. There is |
| 28 // no public way to close this Mach port after-the-fact, nor a way to stop it | 32 // no public way to close this Mach port after-the-fact, nor a way to stop it |
| 29 // from happening since it is done pre-main in dyld. But the address of the | 33 // from happening since it is done pre-main in dyld. But the address of the |
| 30 // CFMachPort can be found in the run loop's string description. Below, that | 34 // CFMachPort can be found in the run loop's string description. Below, that |
| 31 // address is parsed, cast, and then used to invalidate the Mach port to | 35 // address is parsed, cast, and then used to invalidate the Mach port to |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 [NSThread detachNewThreadSelector:@selector(length) | 125 [NSThread detachNewThreadSelector:@selector(length) |
| 122 toTarget:string | 126 toTarget:string |
| 123 withObject:nil]; | 127 withObject:nil]; |
| 124 } | 128 } |
| 125 } | 129 } |
| 126 | 130 |
| 127 void RendererMainPlatformDelegate::PlatformUninitialize() { | 131 void RendererMainPlatformDelegate::PlatformUninitialize() { |
| 128 } | 132 } |
| 129 | 133 |
| 130 bool RendererMainPlatformDelegate::EnableSandbox() { | 134 bool RendererMainPlatformDelegate::EnableSandbox() { |
| 135 // Allow the process to continue without a LaunchServices ASN. The | |
|
Robert Sesek
2017/06/28 22:15:23
Maybe moving this below InitializeSandbox() will f
| |
| 136 // INIT_Process function in HIServices will abort if it cannot connect to | |
| 137 // launchservicesd to get an ASN. By setting this flag, HIServices skips | |
| 138 // that. | |
| 139 SetApplicationIsDaemon(true); | |
| 140 | |
| 131 // Enable the sandbox. | 141 // Enable the sandbox. |
| 132 bool sandbox_initialized = InitializeSandbox(); | 142 bool sandbox_initialized = InitializeSandbox(); |
| 133 | 143 |
| 134 // The sandbox is now engaged. Make sure that the renderer has not connected | 144 // The sandbox is now engaged. Make sure that the renderer has not connected |
| 135 // itself to Cocoa. | 145 // itself to Cocoa. |
| 136 CHECK(NSApp == nil); | 146 CHECK(NSApp == nil); |
| 137 | 147 |
| 138 DisconnectCFNotificationCenter(); | 148 DisconnectCFNotificationCenter(); |
| 139 | 149 |
| 140 return sandbox_initialized; | 150 return sandbox_initialized; |
| 141 } | 151 } |
| 142 | 152 |
| 143 } // namespace content | 153 } // namespace content |
| OLD | NEW |