| 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 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 NSString* string = @""; | 121 NSString* string = @""; |
| 122 [NSThread detachNewThreadSelector:@selector(length) | 122 [NSThread detachNewThreadSelector:@selector(length) |
| 123 toTarget:string | 123 toTarget:string |
| 124 withObject:nil]; | 124 withObject:nil]; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 void RendererMainPlatformDelegate::PlatformUninitialize() { | 128 void RendererMainPlatformDelegate::PlatformUninitialize() { |
| 129 } | 129 } |
| 130 | 130 |
| 131 static void LogTestMessage(std::string message, bool is_error) { | |
| 132 if (is_error) | |
| 133 LOG(ERROR) << message; | |
| 134 else | |
| 135 VLOG(0) << message; | |
| 136 } | |
| 137 | |
| 138 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | |
| 139 const CommandLine& command_line = parameters_.command_line; | |
| 140 | |
| 141 if (command_line.HasSwitch(switches::kTestSandbox)) { | |
| 142 std::string bundle_path = | |
| 143 command_line.GetSwitchValueNative(switches::kTestSandbox); | |
| 144 if (bundle_path.empty()) { | |
| 145 NOTREACHED() << "Bad bundle path"; | |
| 146 return false; | |
| 147 } | |
| 148 NSBundle* tests_bundle = | |
| 149 [NSBundle bundleWithPath:base::SysUTF8ToNSString(bundle_path)]; | |
| 150 if (![tests_bundle load]) { | |
| 151 NOTREACHED() << "Failed to load bundle"; | |
| 152 return false; | |
| 153 } | |
| 154 sandbox_tests_bundle_ = [tests_bundle retain]; | |
| 155 [objc_getClass("RendererSandboxTestsRunner") setLogFunction:LogTestMessage]; | |
| 156 } | |
| 157 return true; | |
| 158 } | |
| 159 | |
| 160 bool RendererMainPlatformDelegate::EnableSandbox() { | 131 bool RendererMainPlatformDelegate::EnableSandbox() { |
| 161 // Enable the sandbox. | 132 // Enable the sandbox. |
| 162 bool sandbox_initialized = InitializeSandbox(); | 133 bool sandbox_initialized = InitializeSandbox(); |
| 163 | 134 |
| 164 // The sandbox is now engaged. Make sure that the renderer has not connected | 135 // The sandbox is now engaged. Make sure that the renderer has not connected |
| 165 // itself to Cocoa. | 136 // itself to Cocoa. |
| 166 CHECK(NSApp == nil); | 137 CHECK(NSApp == nil); |
| 167 | 138 |
| 168 DisconnectCFNotificationCenter(); | 139 DisconnectCFNotificationCenter(); |
| 169 | 140 |
| 170 return sandbox_initialized; | 141 return sandbox_initialized; |
| 171 } | 142 } |
| 172 | 143 |
| 173 void RendererMainPlatformDelegate::RunSandboxTests(bool no_sandbox) { | |
| 174 Class tests_runner = objc_getClass("RendererSandboxTestsRunner"); | |
| 175 if (tests_runner) { | |
| 176 if (![tests_runner runTests]) | |
| 177 LOG(ERROR) << "Running renderer with failing sandbox tests!"; | |
| 178 [sandbox_tests_bundle_ unload]; | |
| 179 [sandbox_tests_bundle_ release]; | |
| 180 sandbox_tests_bundle_ = nil; | |
| 181 } | |
| 182 } | |
| 183 | |
| 184 } // namespace content | 144 } // namespace content |
| OLD | NEW |