OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer/renderer_main_platform_delegate.h" | 5 #include "chrome/renderer/renderer_main_platform_delegate.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
| 9 #import "base/chrome_application_mac.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/sandbox_mac.h" | 12 #include "chrome/common/sandbox_mac.h" |
12 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" | 13 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" |
13 | 14 |
14 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 15 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
15 const MainFunctionParams& parameters) | 16 const MainFunctionParams& parameters) |
16 : parameters_(parameters) { | 17 : parameters_(parameters) { |
17 } | 18 } |
18 | 19 |
19 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { | 20 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { |
20 } | 21 } |
21 | 22 |
22 // TODO(mac-port): Any code needed to initialize a process for | 23 // TODO(mac-port): Any code needed to initialize a process for purposes of |
23 // purposes of running a renderer needs to also be reflected in | 24 // running a renderer needs to also be reflected in chrome_dll_main.cc for |
24 // chrome_dll_main.cc for --single-process support. | 25 // --single-process support. |
25 void RendererMainPlatformDelegate::PlatformInitialize() { | 26 void RendererMainPlatformDelegate::PlatformInitialize() { |
| 27 // Initialize NSApplication using the custom subclass. Without this call, |
| 28 // drawing of native UI elements (e.g. buttons) in WebKit will explode. |
| 29 [CrApplication sharedApplication]; |
| 30 |
26 // Load WebKit system interfaces. | 31 // Load WebKit system interfaces. |
27 InitWebCoreSystemInterface(); | 32 InitWebCoreSystemInterface(); |
28 | 33 |
29 if (![NSThread isMultiThreaded]) { | 34 if (![NSThread isMultiThreaded]) { |
30 NSString* string = @""; | 35 NSString* string = @""; |
31 [NSThread detachNewThreadSelector:@selector(length) | 36 [NSThread detachNewThreadSelector:@selector(length) |
32 toTarget:string | 37 toTarget:string |
33 withObject:nil]; | 38 withObject:nil]; |
34 } | 39 } |
35 | |
36 // Initialize Cocoa. Without this call, drawing of native UI | |
37 // elements (e.g. buttons) in WebKit will explode. | |
38 [NSApplication sharedApplication]; | |
39 } | 40 } |
40 | 41 |
41 void RendererMainPlatformDelegate::PlatformUninitialize() { | 42 void RendererMainPlatformDelegate::PlatformUninitialize() { |
42 } | 43 } |
43 | 44 |
44 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | 45 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |
45 return true; | 46 return true; |
46 } | 47 } |
47 | 48 |
48 bool RendererMainPlatformDelegate::EnableSandbox() { | 49 bool RendererMainPlatformDelegate::EnableSandbox() { |
49 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); | 50 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); |
50 SandboxInitWrapper sandbox_wrapper; | 51 SandboxInitWrapper sandbox_wrapper; |
51 return sandbox_wrapper.InitializeSandbox(*parsed_command_line, | 52 return sandbox_wrapper.InitializeSandbox(*parsed_command_line, |
52 switches::kRendererProcess); | 53 switches::kRendererProcess); |
53 } | 54 } |
54 | 55 |
55 void RendererMainPlatformDelegate::RunSandboxTests() { | 56 void RendererMainPlatformDelegate::RunSandboxTests() { |
56 // TODO(port): Run sandbox unit test here. | 57 // TODO(port): Run sandbox unit test here. |
57 } | 58 } |
OLD | NEW |