2010-11-15 16:39:56 +01:00
|
|
|
// 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"
|
2011-01-07 22:34:20 +01:00
|
|
|
#include "base/message_pump_mac.h"
|
2010-11-15 16:39:56 +01:00
|
|
|
#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
|
|
|
|
|
2011-01-07 22:34:20 +01:00
|
|
|
// 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
|
2010-11-15 16:39:56 +01:00
|
|
|
|
2011-01-10 01:23:42 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Memory autorelease pool.
|
|
|
|
static NSAutoreleasePool* g_autopool = nil;
|
|
|
|
|
2010-11-15 16:39:56 +01:00
|
|
|
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,
|
|
|
|
kCFRunLoopBeforeTimers | kCFRunLoopBeforeWaiting,
|
|
|
|
YES, /* repeat */
|
|
|
|
0,
|
|
|
|
&RunLoopObserver,
|
|
|
|
NULL);
|
|
|
|
if (observer) {
|
|
|
|
CFRunLoopAddObserver(CFRunLoopGetCurrent(), observer,
|
|
|
|
kCFRunLoopCommonModes);
|
|
|
|
}
|
|
|
|
|
|
|
|
webkit_glue::InitializeDataPak();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefProcessUIThread::PlatformCleanUp() {
|
|
|
|
[g_autopool release];
|
|
|
|
}
|
|
|
|
|