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

Unified Diff: content/renderer/renderer_main_platform_delegate_mac.mm

Issue 177243021: [Mac] Remove NSApplication from the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Defer FakeActiveWindow creation Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/renderer_main.cc ('k') | content/shell/renderer/test_runner/WebTestThemeEngineMac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_main_platform_delegate_mac.mm
diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
index df47f3d0e1072629559b5cea71258d4e54c18af5..7c42727ad32b3661c81a5411657622d9ca17748e 100644
--- a/content/renderer/renderer_main_platform_delegate_mac.mm
+++ b/content/renderer/renderer_main_platform_delegate_mac.mm
@@ -10,8 +10,6 @@
#include "base/command_line.h"
#include "base/logging.h"
-#import "base/mac/foundation_util.h"
-#import "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
@@ -19,56 +17,11 @@
#include "content/public/common/content_switches.h"
#import "content/public/common/injection_test_mac.h"
#include "content/common/sandbox_init_mac.h"
-#include "third_party/mach_override/mach_override.h"
-
-extern "C" {
-// SPI logging functions for CF that are exported externally.
-void CFLog(int32_t level, CFStringRef format, ...);
-void _CFLogvEx(void* log_func, void* copy_desc_func,
- CFDictionaryRef format_options, int32_t level,
- CFStringRef format, va_list args);
-} // extern "C"
namespace content {
namespace {
-// This leaked array stores the text input services input and layout sources,
-// which is returned in CrTISCreateInputSourceList(). This list is computed
-// right after the sandbox is initialized.
-CFArrayRef g_text_input_services_source_list_ = NULL;
-
-CFArrayRef CrTISCreateInputSourceList(
- CFDictionaryRef properties,
- Boolean includeAllInstalled) {
- DCHECK(g_text_input_services_source_list_);
- // Callers assume ownership of the result, so increase the retain count.
- CFRetain(g_text_input_services_source_list_);
- return g_text_input_services_source_list_;
-}
-
-// Text Input Services expects to be able to XPC to HIServices, but the
-// renderer sandbox blocks that. TIS then becomes very vocal about this on
-// every new renderer startup, so filter out those log messages.
-void CrRendererCFLog(int32_t level, CFStringRef format, ...) {
- const CFStringRef kAnnoyingLogMessages[] = {
- CFSTR("Error received in message reply handler: %s\n"),
- CFSTR("Connection Invalid error for service %s.\n"),
- };
-
- for (size_t i = 0; i < arraysize(kAnnoyingLogMessages); ++i) {
- if (CFStringCompare(format, kAnnoyingLogMessages[i], 0) ==
- kCFCompareEqualTo) {
- return;
- }
- }
-
- va_list args;
- va_start(args, format);
- _CFLogvEx(NULL, NULL, NULL, level, format, args);
- va_end(args);
-}
-
// You are about to read a pretty disgusting hack. In a static initializer,
// CoreFoundation decides to connect with cfprefsd(8) using Mach IPC. There is
// no public way to close this Mach port after-the-fact, nor a way to stop it
@@ -164,10 +117,6 @@ RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
// running a renderer needs to also be reflected in chrome_main.cc for
// --single-process support.
void RendererMainPlatformDelegate::PlatformInitialize() {
- // Initialize NSApplication up front. Without this call, drawing of
- // native UI elements (e.g. buttons) in WebKit will explode.
- [NSApplication sharedApplication];
-
if (![NSThread isMultiThreaded]) {
NSString* string = @"";
[NSThread detachNewThreadSelector:@selector(length)
@@ -209,51 +158,12 @@ bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) {
}
bool RendererMainPlatformDelegate::EnableSandbox() {
- // rdar://9251340 http://openradar.me/9251340
- // See http://crbug.com/31225 and http://crbug.com/152566
- // To check if this is broken:
- // 1. Enable Multi language input (simplified chinese)
- // 2. Ensure "Show/Hide Trackpad Handwriting" shortcut works.
- // (ctrl+shift+space).
- // 3. Now open a new tab in Google Chrome or start Google Chrome
- // 4. Try ctrl+shift+space shortcut again. Shortcut will not work, IME will
- // either not appear or (worse) not disappear on ctrl-shift-space.
- // (Run `ps aux | grep Chinese` (10.6/10.7) or `ps aux | grep Trackpad`
- // and then kill that pid to make it go away.)
- //
- // Chinese Handwriting was introduced in 10.6 and is confirmed broken on
- // 10.6, 10.7, and 10.8. It's fixed on 10.9.
- bool needs_ime_hack = base::mac::IsOSMountainLionOrEarlier();
-
- if (needs_ime_hack) {
- mach_error_t err = mach_override_ptr(
- (void*)&TISCreateInputSourceList,
- (void*)&CrTISCreateInputSourceList,
- NULL);
- CHECK_EQ(err_none, err);
-
- // Override the private CFLog function so that the console is not spammed
- // by TIS failing to connect to HIServices over XPC.
- err = mach_override_ptr((void*)&CFLog, (void*)&CrRendererCFLog, NULL);
- CHECK_EQ(err_none, err);
- }
-
// Enable the sandbox.
bool sandbox_initialized = InitializeSandbox();
- if (needs_ime_hack) {
- // After the sandbox is initialized, call into TIS. Doing this before
- // the sandbox is in place will open up renderer access to the
- // pasteboard and an XPC connection to "com.apple.hiservices-xpcservice".
- base::ScopedCFTypeRef<TISInputSourceRef> layout_source(
- TISCopyCurrentKeyboardLayoutInputSource());
- base::ScopedCFTypeRef<TISInputSourceRef> input_source(
- TISCopyCurrentKeyboardInputSource());
-
- CFTypeRef source_list[] = { layout_source.get(), input_source.get() };
- g_text_input_services_source_list_ = CFArrayCreate(kCFAllocatorDefault,
- source_list, arraysize(source_list), &kCFTypeArrayCallBacks);
- }
+ // The sandbox is now engaged. Make sure that the renderer has not connected
+ // itself to Cocoa.
+ CHECK(NSApp == nil);
DisconnectCFNotificationCenter();
« no previous file with comments | « content/renderer/renderer_main.cc ('k') | content/shell/renderer/test_runner/WebTestThemeEngineMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698