Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: content/renderer/renderer_main_platform_delegate_mac.mm

Issue 285283003: Remove flag --test-sandbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes requested by jln Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "content/common/sandbox_mac.h" 16 #include "content/common/sandbox_mac.h"
17 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
18 #import "content/public/common/injection_test_mac.h" 18 #import "content/public/common/injection_test_mac.h"
Robert Sesek 2014/05/30 17:36:48 Remove.
luken 2014/05/30 17:43:22 Done.
19 #include "content/common/sandbox_init_mac.h" 19 #include "content/common/sandbox_init_mac.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 namespace { 23 namespace {
24 24
25 // You are about to read a pretty disgusting hack. In a static initializer, 25 // You are about to read a pretty disgusting hack. In a static initializer,
26 // CoreFoundation decides to connect with cfprefsd(8) using Mach IPC. There is 26 // CoreFoundation decides to connect with cfprefsd(8) using Mach IPC. There is
27 // no public way to close this Mach port after-the-fact, nor a way to stop it 27 // no public way to close this Mach port after-the-fact, nor a way to stop it
28 // from happening since it is done pre-main in dyld. But the address of the 28 // from happening since it is done pre-main in dyld. But the address of the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « content/renderer/renderer_main_platform_delegate_linux.cc ('k') | content/renderer/renderer_main_platform_delegate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698