diff options
| author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
| commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
| tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebKit2/UIProcess/Plugins/mac | |
| parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
| download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 | |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebKit2/UIProcess/Plugins/mac')
| -rw-r--r-- | Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm | 138 |
1 files changed, 137 insertions, 1 deletions
diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm index 2adc473..8375fd2 100644 --- a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm +++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm @@ -31,7 +31,33 @@ #import "PluginProcessCreationParameters.h" #import "WebKitSystemInterface.h" +@interface WKPlaceholderModalWindow : NSWindow +@end + +@implementation WKPlaceholderModalWindow + +// Prevent NSApp from calling requestUserAttention: when the window is shown +// modally, even if the app is inactive. See 6823049. +- (BOOL)_wantsUserAttention +{ + return NO; +} + +@end + namespace WebKit { + +bool PluginProcessProxy::pluginNeedsExecutableHeap(const PluginInfoStore::Plugin& pluginInfo) +{ + static bool forceNonexecutableHeapForPlugins = [[NSUserDefaults standardUserDefaults] boolForKey:@"ForceNonexecutableHeapForPlugins"]; + if (forceNonexecutableHeapForPlugins) + return false; + + if (pluginInfo.bundleIdentifier == "com.apple.QuickTime Plugin.plugin") + return false; + + return true; +} void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters) { @@ -41,7 +67,117 @@ void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationPa if (renderServerPort != MACH_PORT_NULL) parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND); #endif -} +} + +bool PluginProcessProxy::getPluginProcessSerialNumber(ProcessSerialNumber& pluginProcessSerialNumber) +{ + pid_t pluginProcessPID = m_processLauncher->processIdentifier(); + return GetProcessForPID(pluginProcessPID, &pluginProcessSerialNumber) == noErr; +} + +void PluginProcessProxy::makePluginProcessTheFrontProcess() +{ + ProcessSerialNumber pluginProcessSerialNumber; + if (!getPluginProcessSerialNumber(pluginProcessSerialNumber)) + return; + + SetFrontProcess(&pluginProcessSerialNumber); +} + +void PluginProcessProxy::makeUIProcessTheFrontProcess() +{ + ProcessSerialNumber processSerialNumber; + GetCurrentProcess(&processSerialNumber); + SetFrontProcess(&processSerialNumber); +} + +void PluginProcessProxy::setFullscreenWindowIsShowing(bool fullscreenWindowIsShowing) +{ + if (m_fullscreenWindowIsShowing == fullscreenWindowIsShowing) + return; + + m_fullscreenWindowIsShowing = fullscreenWindowIsShowing; + if (m_fullscreenWindowIsShowing) + enterFullscreen(); + else + exitFullscreen(); +} + +void PluginProcessProxy::enterFullscreen() +{ + [NSMenu setMenuBarVisible:NO]; + + makePluginProcessTheFrontProcess(); +} + +void PluginProcessProxy::exitFullscreen() +{ + [NSMenu setMenuBarVisible:YES]; + + // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode. + + ProcessSerialNumber frontProcessSerialNumber; + GetFrontProcess(&frontProcessSerialNumber); + Boolean isSameProcess = 0; + + ProcessSerialNumber pluginProcessSerialNumber; + if (!getPluginProcessSerialNumber(pluginProcessSerialNumber)) + return; + + SameProcess(&frontProcessSerialNumber, &pluginProcessSerialNumber, &isSameProcess); + if (!isSameProcess) + return; + + makeUIProcessTheFrontProcess(); +} + +void PluginProcessProxy::setModalWindowIsShowing(bool modalWindowIsShowing) +{ + if (modalWindowIsShowing == m_modalWindowIsShowing) + return; + + m_modalWindowIsShowing = modalWindowIsShowing; + + if (m_modalWindowIsShowing) + beginModal(); + else + endModal(); +} + +void PluginProcessProxy::beginModal() +{ + ASSERT(!m_placeholderWindow); + ASSERT(!m_activationObserver); + + m_placeholderWindow.adoptNS([[WKPlaceholderModalWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]); + + m_activationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification object:NSApp queue:nil + usingBlock:^(NSNotification *){ applicationDidBecomeActive(); }]; + + [NSApp runModalForWindow:m_placeholderWindow.get()]; + + [m_placeholderWindow.get() orderOut:nil]; + m_placeholderWindow = nullptr; +} + +void PluginProcessProxy::endModal() +{ + ASSERT(m_placeholderWindow); + ASSERT(m_activationObserver); + + [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()]; + m_activationObserver = nullptr; + + [NSApp stopModal]; + + makeUIProcessTheFrontProcess(); +} + +void PluginProcessProxy::applicationDidBecomeActive() +{ + makePluginProcessTheFrontProcess(); +} + } // namespace WebKit |
