diff options
Diffstat (limited to 'Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm')
-rw-r--r-- | Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm | 58 |
1 files changed, 4 insertions, 54 deletions
diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm index fceb99b37..98476535a 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm @@ -42,35 +42,6 @@ extern "C" void WebKitPluginProcessShimInitialize(const PluginProcessShimCallbac static PluginProcessShimCallbacks pluginProcessShimCallbacks; -static IMP NSApplication_RunModalForWindow; -static unsigned modalCount = 0; - -static void beginModal() -{ - // Make sure to make ourselves the front process - ProcessSerialNumber psn; - GetCurrentProcess(&psn); - SetFrontProcess(&psn); - - if (!modalCount++) - pluginProcessShimCallbacks.setModal(true); -} - -static void endModal() -{ - if (!--modalCount) - pluginProcessShimCallbacks.setModal(false); -} - -static NSInteger shim_NSApplication_RunModalForWindow(id self, SEL _cmd, NSWindow* window) -{ - beginModal(); - NSInteger result = ((NSInteger (*)(id, SEL, NSWindow *))NSApplication_RunModalForWindow)(self, _cmd, window); - endModal(); - - return result; -} - #ifndef __LP64__ #if COMPILER(CLANG) @@ -102,16 +73,16 @@ static Boolean shimIsWindowActive(WindowRef window) static void shimModalDialog(ModalFilterUPP modalFilter, DialogItemIndex *itemHit) { - beginModal(); + pluginProcessShimCallbacks.beginModal(); ModalDialog(modalFilter, itemHit); - endModal(); + pluginProcessShimCallbacks.endModal(); } static DialogItemIndex shimAlert(SInt16 alertID, ModalFilterUPP modalFilter) { - beginModal(); + pluginProcessShimCallbacks.beginModal(); DialogItemIndex index = Alert(alertID, modalFilter); - endModal(); + pluginProcessShimCallbacks.endModal(); return index; } @@ -146,27 +117,6 @@ __attribute__((visibility("default"))) void WebKitPluginProcessShimInitialize(const PluginProcessShimCallbacks& callbacks) { pluginProcessShimCallbacks = callbacks; - - // Override -[NSApplication runModalForWindow:] - Method runModalForWindowMethod = class_getInstanceMethod(objc_getClass("NSApplication"), @selector(runModalForWindow:)); - NSApplication_RunModalForWindow = method_setImplementation(runModalForWindowMethod, reinterpret_cast<IMP>(shim_NSApplication_RunModalForWindow)); - - NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; - - // Track when any Cocoa window is about to be be shown. - id orderOnScreenObserver = [defaultCenter addObserverForName:WKWindowWillOrderOnScreenNotification() - object:nil - queue:nil - usingBlock:^(NSNotification *notification) { pluginProcessShimCallbacks.cocoaWindowShown([notification object]); }]; - // Track when any cocoa window is about to be hidden. - id orderOffScreenObserver = [defaultCenter addObserverForName:WKWindowWillOrderOffScreenNotification() - object:nil - queue:nil - usingBlock:^(NSNotification *notification) { pluginProcessShimCallbacks.cocoaWindowHidden([notification object]); }]; - - // Leak the two observers so that they observe notifications for the lifetime of the process. - CFRetain(orderOnScreenObserver); - CFRetain(orderOffScreenObserver); } } // namespace WebKit |