summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-02 17:04:55 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-02 17:04:55 +0000
commit18db46180363c8705c6e21747b97f4beb00bfa01 (patch)
treee933f71549a0ff6594a16a7d498542512b74cef3 /chrome/plugin
parent1350c0f41aa6842ee0e0b28bce2147fd90cec21b (diff)
downloadchromium_src-18db46180363c8705c6e21747b97f4beb00bfa01.zip
chromium_src-18db46180363c8705c6e21747b97f4beb00bfa01.tar.gz
chromium_src-18db46180363c8705c6e21747b97f4beb00bfa01.tar.bz2
Hide/show cursor according to NSCursor requests.
BUG=http://crbug.com/32703 TEST=when hiding cursor (Flash 10.1), cursor hides (but doesn't stay hidden; that's a different bug) Review URL: http://codereview.chromium.org/560003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r--chrome/plugin/plugin_interpose_util_mac.mm51
1 files changed, 42 insertions, 9 deletions
diff --git a/chrome/plugin/plugin_interpose_util_mac.mm b/chrome/plugin/plugin_interpose_util_mac.mm
index 7dd20ad..d3c1d74 100644
--- a/chrome/plugin/plugin_interpose_util_mac.mm
+++ b/chrome/plugin/plugin_interpose_util_mac.mm
@@ -81,6 +81,14 @@ void NotifyPluginOfSetCursor(WebPluginDelegateImpl* delegate,
delegate->SetCursor(cursor);
}
+void NotifyPluginOfSetCursorVisibility(bool visibility) {
+ PluginThread* plugin_thread = PluginThread::current();
+ if (plugin_thread) {
+ plugin_thread->Send(
+ new PluginProcessHostMsg_PluginSetCursorVisibility(visibility));
+ }
+}
+
__attribute__((visibility("default")))
bool GetPluginWindowHasFocus(const WebPluginDelegateImpl* delegate) {
return delegate->GetWindowHasFocus();
@@ -181,6 +189,8 @@ static void OnPluginWindowShown(const WindowInfo& window_info, BOOL is_modal) {
@interface NSCursor (ChromePluginInterposing)
- (void)chromePlugin_set;
++ (void)chromePlugin_hide;
++ (void)chromePlugin_unhide;
@end
@implementation NSCursor (ChromePluginInterposing)
@@ -194,13 +204,31 @@ static void OnPluginWindowShown(const WindowInfo& window_info, BOOL is_modal) {
[self chromePlugin_set];
}
++ (void)chromePlugin_hide {
+ mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(false);
+}
+
++ (void)chromePlugin_unhide {
+ mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(true);
+}
+
@end
#pragma mark -
-static void ExchangeMethods(Class target_class, SEL original, SEL replacement) {
- Method m1 = class_getInstanceMethod(target_class, original);
- Method m2 = class_getInstanceMethod(target_class, replacement);
+static void ExchangeMethods(Class target_class,
+ BOOL class_method,
+ SEL original,
+ SEL replacement) {
+ Method m1;
+ Method m2;
+ if (class_method) {
+ m1 = class_getClassMethod(target_class, original);
+ m2 = class_getClassMethod(target_class, replacement);
+ } else {
+ m1 = class_getInstanceMethod(target_class, original);
+ m2 = class_getInstanceMethod(target_class, replacement);
+ }
if (m1 && m2)
method_exchangeImplementations(m1, m2);
else
@@ -211,20 +239,25 @@ namespace mac_plugin_interposing {
void SetUpCocoaInterposing() {
Class nswindow_class = [NSWindow class];
- ExchangeMethods(nswindow_class, @selector(orderOut:),
+ ExchangeMethods(nswindow_class, NO, @selector(orderOut:),
@selector(chromePlugin_orderOut:));
- ExchangeMethods(nswindow_class, @selector(orderFront:),
+ ExchangeMethods(nswindow_class, NO, @selector(orderFront:),
@selector(chromePlugin_orderFront:));
- ExchangeMethods(nswindow_class, @selector(makeKeyAndOrderFront:),
+ ExchangeMethods(nswindow_class, NO, @selector(makeKeyAndOrderFront:),
@selector(chromePlugin_makeKeyAndOrderFront:));
- ExchangeMethods(nswindow_class, @selector(_setWindowNumber:),
+ ExchangeMethods(nswindow_class, NO, @selector(_setWindowNumber:),
@selector(chromePlugin_setWindowNumber:));
- ExchangeMethods([NSApplication class], @selector(runModalForWindow:),
+ ExchangeMethods([NSApplication class], NO, @selector(runModalForWindow:),
@selector(chromePlugin_runModalForWindow:));
- ExchangeMethods([NSCursor class], @selector(set),
+ Class nscursor_class = [NSCursor class];
+ ExchangeMethods(nscursor_class, NO, @selector(set),
@selector(chromePlugin_set));
+ ExchangeMethods(nscursor_class, YES, @selector(hide),
+ @selector(chromePlugin_hide));
+ ExchangeMethods(nscursor_class, YES, @selector(unhide),
+ @selector(chromePlugin_unhide));
}
} // namespace mac_plugin_interposing