cef/libcef/cef_process_ui_thread_mac.mm
Marshall Greenblatt 1f7a4b4566 Mac:
- Implement the WebExternalPopupMenu interface to fix select popup menu display.
- Remove the kCFRunLoopBeforeTimers option from CFRunLoopObserverCreate to reduce CPU usage (issue #211).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@218 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2011-04-09 16:54:59 +00:00

77 lines
2.1 KiB
Plaintext

// Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "include/cef.h"
#include "cef_process_ui_thread.h"
#include "browser_webkit_glue.h"
#include "base/message_pump_mac.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
// CrAppProtocol implementation.
@interface CrApplication : NSApplication<CrAppProtocol> {
@private
BOOL handlingSendEvent_;
}
- (BOOL)isHandlingSendEvent;
@end
@implementation CrApplication
- (BOOL)isHandlingSendEvent {
return handlingSendEvent_;
}
- (void)sendEvent:(NSEvent*)event {
BOOL wasHandlingSendEvent = handlingSendEvent_;
handlingSendEvent_ = YES;
[super sendEvent:event];
handlingSendEvent_ = wasHandlingSendEvent;
}
@end
namespace {
// Memory autorelease pool.
static NSAutoreleasePool* g_autopool = nil;
void RunLoopObserver(CFRunLoopObserverRef observer, CFRunLoopActivity activity,
void* info)
{
CefDoMessageLoopWork();
}
} // namespace
void CefProcessUIThread::PlatformInit() {
// Initialize the CrApplication instance.
[CrApplication sharedApplication];
g_autopool = [[NSAutoreleasePool alloc] init];
InitWebCoreSystemInterface();
// Register the run loop observer.
CFRunLoopObserverRef observer =
CFRunLoopObserverCreate(NULL,
kCFRunLoopBeforeWaiting,
YES, /* repeat */
0,
&RunLoopObserver,
NULL);
if (observer) {
CFRunLoopAddObserver(CFRunLoopGetCurrent(), observer,
kCFRunLoopCommonModes);
}
webkit_glue::InitializeDataPak();
// On Mac, the select popup menus are rendered by the browser.
WebKit::WebView::setUseExternalPopupMenus(true);
}
void CefProcessUIThread::PlatformCleanUp() {
[g_autopool release];
}