Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: chrome/plugin/plugin_interpose_util_mac.mm

Issue 554003: (Mac) Intercept (Cocoa) cursor setting by plugins and forward it on properly.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/glue/plugins/webplugin_delegate_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/plugin/plugin_interpose_util_mac.h" 5 #include "chrome/plugin/plugin_interpose_util_mac.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 9
10 #include "chrome/common/plugin_messages.h" 10 #include "chrome/common/plugin_messages.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 new PluginProcessHostMsg_PluginHideWindow(window_id, window_bounds)); 68 new PluginProcessHostMsg_PluginHideWindow(window_id, window_bounds));
69 } 69 }
70 } 70 }
71 71
72 __attribute__((visibility("default"))) 72 __attribute__((visibility("default")))
73 void NotifyPluginOfSetThemeCursor(WebPluginDelegateImpl* delegate, 73 void NotifyPluginOfSetThemeCursor(WebPluginDelegateImpl* delegate,
74 ThemeCursor cursor) { 74 ThemeCursor cursor) {
75 delegate->SetThemeCursor(cursor); 75 delegate->SetThemeCursor(cursor);
76 } 76 }
77 77
78
79 } // namespace mac_plugin_interposing 78 } // namespace mac_plugin_interposing
80 79
81 #pragma mark - 80 #pragma mark -
82 81
83 struct WindowInfo { 82 struct WindowInfo {
84 uint32 window_id; 83 uint32 window_id;
85 CGRect bounds; 84 CGRect bounds;
86 WindowInfo(NSWindow* window) { 85 WindowInfo(NSWindow* window) {
87 NSInteger window_num = [window windowNumber]; 86 NSInteger window_num = [window windowNumber];
88 window_id = window_num > 0 ? window_num : 0; 87 window_id = window_num > 0 ? window_num : 0;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 mac_plugin_interposing::SwitchToPluginProcess(); 161 mac_plugin_interposing::SwitchToPluginProcess();
163 // This is out-of-order relative to the other calls, but runModalForWindow: 162 // This is out-of-order relative to the other calls, but runModalForWindow:
164 // won't return until the window closes, and the order only matters for 163 // won't return until the window closes, and the order only matters for
165 // full-screen windows. 164 // full-screen windows.
166 OnPluginWindowShown(WindowInfo(window), YES); 165 OnPluginWindowShown(WindowInfo(window), YES);
167 return [self chromePlugin_runModalForWindow:window]; 166 return [self chromePlugin_runModalForWindow:window];
168 } 167 }
169 168
170 @end 169 @end
171 170
171 @interface NSCursor (ChromePluginInterposing)
172 - (void)chromePlugin_set;
173 @end
174
175 @implementation NSCursor (ChromePluginInterposing)
176
177 - (void)chromePlugin_set {
178 WebPluginDelegateImpl* delegate = mac_plugin_interposing::GetActiveDelegate();
179 if (delegate) {
180 delegate->SetNSCursor(self);
181 return;
182 }
183 [self chromePlugin_set];
184 }
185
186 @end
187
172 #pragma mark - 188 #pragma mark -
173 189
174 static void ExchangeMethods(Class target_class, SEL original, SEL replacement) { 190 static void ExchangeMethods(Class target_class, SEL original, SEL replacement) {
175 Method m1 = class_getInstanceMethod(target_class, original); 191 Method m1 = class_getInstanceMethod(target_class, original);
176 Method m2 = class_getInstanceMethod(target_class, replacement); 192 Method m2 = class_getInstanceMethod(target_class, replacement);
177 if (m1 && m2) 193 if (m1 && m2)
178 method_exchangeImplementations(m1, m2); 194 method_exchangeImplementations(m1, m2);
179 else 195 else
180 NOTREACHED() << "Cocoa swizzling failed"; 196 NOTREACHED() << "Cocoa swizzling failed";
181 } 197 }
182 198
183 namespace mac_plugin_interposing { 199 namespace mac_plugin_interposing {
184 200
185 void SetUpCocoaInterposing() { 201 void SetUpCocoaInterposing() {
186 Class nswindow_class = [NSWindow class]; 202 Class nswindow_class = [NSWindow class];
187 ExchangeMethods(nswindow_class, @selector(orderOut:), 203 ExchangeMethods(nswindow_class, @selector(orderOut:),
188 @selector(chromePlugin_orderOut:)); 204 @selector(chromePlugin_orderOut:));
189 ExchangeMethods(nswindow_class, @selector(orderFront:), 205 ExchangeMethods(nswindow_class, @selector(orderFront:),
190 @selector(chromePlugin_orderFront:)); 206 @selector(chromePlugin_orderFront:));
191 ExchangeMethods(nswindow_class, @selector(makeKeyAndOrderFront:), 207 ExchangeMethods(nswindow_class, @selector(makeKeyAndOrderFront:),
192 @selector(chromePlugin_makeKeyAndOrderFront:)); 208 @selector(chromePlugin_makeKeyAndOrderFront:));
193 ExchangeMethods(nswindow_class, @selector(_setWindowNumber:), 209 ExchangeMethods(nswindow_class, @selector(_setWindowNumber:),
194 @selector(chromePlugin_setWindowNumber:)); 210 @selector(chromePlugin_setWindowNumber:));
195 211
196 ExchangeMethods([NSApplication class], @selector(runModalForWindow:), 212 ExchangeMethods([NSApplication class], @selector(runModalForWindow:),
197 @selector(chromePlugin_runModalForWindow:)); 213 @selector(chromePlugin_runModalForWindow:));
214
215 ExchangeMethods([NSCursor class], @selector(set),
216 @selector(chromePlugin_set));
198 } 217 }
199 218
200 } // namespace mac_plugin_interposing 219 } // namespace mac_plugin_interposing
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/plugins/webplugin_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698