using content::PluginThread;
-namespace mac_plugin_interposing {
+namespace {
-// TODO(stuartmorgan): Make this an IPC to order the plugin process above the
-// browser process only if the browser is current frontmost.
-__attribute__((visibility("default")))
+// Brings the plugin process to the front so that the user can see its windows.
void SwitchToPluginProcess() {
ProcessSerialNumber this_process, front_process;
if ((GetCurrentProcess(&this_process) != noErr) ||
}
}
-__attribute__((visibility("default")))
-OpaquePluginRef GetActiveDelegate() {
- return content::WebPluginDelegateImpl::GetActiveDelegate();
-}
-
-__attribute__((visibility("default")))
-void NotifyBrowserOfPluginSelectWindow(uint32 window_id, CGRect bounds,
- bool modal) {
- PluginThread* plugin_thread = PluginThread::current();
- if (plugin_thread) {
- gfx::Rect window_bounds(bounds);
- plugin_thread->Send(
- new PluginProcessHostMsg_PluginSelectWindow(window_id, window_bounds,
- modal));
- }
-}
-
-__attribute__((visibility("default")))
+// Sends a message to the browser process to inform it that the given window
+// has been shown.
void NotifyBrowserOfPluginShowWindow(uint32 window_id, CGRect bounds,
bool modal) {
PluginThread* plugin_thread = PluginThread::current();
}
}
-__attribute__((visibility("default")))
+// Sends a message to the browser process to inform it that the given window
+// has been hidden, and switches focus back to the browser process if there are
+// no remaining plugin windows.
void NotifyBrowserOfPluginHideWindow(uint32 window_id, CGRect bounds) {
PluginThread* plugin_thread = PluginThread::current();
if (plugin_thread) {
}
}
+// Informs the host that the plugin has changed the cursor visibility.
void NotifyPluginOfSetCursorVisibility(bool visibility) {
PluginThread* plugin_thread = PluginThread::current();
if (plugin_thread) {
}
}
-} // namespace mac_plugin_interposing
-
-#pragma mark -
-
struct WindowInfo {
uint32 window_id;
CGRect bounds;
}
};
-static void OnPluginWindowClosed(const WindowInfo& window_info) {
+void OnPluginWindowClosed(const WindowInfo& window_info) {
if (window_info.window_id == 0)
return;
- mac_plugin_interposing::NotifyBrowserOfPluginHideWindow(window_info.window_id,
- window_info.bounds);
+ NotifyBrowserOfPluginHideWindow(window_info.window_id, window_info.bounds);
}
-static BOOL g_waiting_for_window_number = NO;
+BOOL g_waiting_for_window_number = NO;
-static void OnPluginWindowShown(const WindowInfo& window_info, BOOL is_modal) {
+void OnPluginWindowShown(const WindowInfo& window_info, BOOL is_modal) {
// The window id is 0 if it has never been shown (including while it is the
// process of being shown for the first time); when that happens, we'll catch
// it in _setWindowNumber instead.
is_modal = YES;
s_pending_display_is_modal = NO;
}
- mac_plugin_interposing::NotifyBrowserOfPluginShowWindow(
- window_info.window_id, window_info.bounds, is_modal);
+ NotifyBrowserOfPluginShowWindow(window_info.window_id, window_info.bounds,
+ is_modal);
}
+} // namespace
+
@interface NSWindow (ChromePluginUtilities)
// Returns YES if the window is visible and actually on the screen.
- (BOOL)chromePlugin_isWindowOnScreen;
- (void)chromePlugin_orderFront:(id)sender {
[self chromePlugin_orderFront:sender];
if ([self chromePlugin_isWindowOnScreen])
- mac_plugin_interposing::SwitchToPluginProcess();
+ SwitchToPluginProcess();
OnPluginWindowShown(WindowInfo(self), NO);
}
- (void)chromePlugin_makeKeyAndOrderFront:(id)sender {
[self chromePlugin_makeKeyAndOrderFront:sender];
if ([self chromePlugin_isWindowOnScreen])
- mac_plugin_interposing::SwitchToPluginProcess();
+ SwitchToPluginProcess();
OnPluginWindowShown(WindowInfo(self), NO);
}
[self chromePlugin_setWindowNumber:num];
return;
}
- mac_plugin_interposing::SwitchToPluginProcess();
+ SwitchToPluginProcess();
[self chromePlugin_setWindowNumber:num];
OnPluginWindowShown(WindowInfo(self), NO);
}
@implementation NSApplication (ChromePluginInterposing)
- (NSInteger)chromePlugin_runModalForWindow:(NSWindow*)window {
- mac_plugin_interposing::SwitchToPluginProcess();
+ SwitchToPluginProcess();
// This is out-of-order relative to the other calls, but runModalForWindow:
// won't return until the window closes, and the order only matters for
// full-screen windows.
@implementation NSCursor (ChromePluginInterposing)
- (void)chromePlugin_set {
- OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate();
+ content::WebPluginDelegateImpl* delegate =
+ content::WebPluginDelegateImpl::GetActiveDelegate();
if (delegate) {
- static_cast<content::WebPluginDelegateImpl*>(delegate)->SetNSCursor(self);
+ delegate->SetNSCursor(self);
return;
}
[self chromePlugin_set];
}
+ (void)chromePlugin_hide {
- mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(false);
+ NotifyPluginOfSetCursorVisibility(false);
}
+ (void)chromePlugin_unhide {
- mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(true);
+ NotifyPluginOfSetCursorVisibility(true);
}
@end