OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
11 #include "chrome/plugin/plugin_thread.h" | 11 #include "chrome/plugin/plugin_thread.h" |
12 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 12 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
13 | 13 |
14 namespace mac_plugin_interposing { | 14 namespace mac_plugin_interposing { |
15 | 15 |
16 // TODO(stuartmorgan): Make this an IPC to order the plugin process above the | 16 // TODO(stuartmorgan): Make this an IPC to order the plugin process above the |
17 // browser process only if the browser is current frontmost. | 17 // browser process only if the browser is current frontmost. |
18 __attribute__((visibility("default"))) | 18 __attribute__((visibility("default"))) |
19 void SwitchToPluginProcess() { | 19 void SwitchToPluginProcess() { |
20 ProcessSerialNumber this_process, front_process; | 20 ProcessSerialNumber this_process, front_process; |
21 if ((GetCurrentProcess(&this_process) != noErr) || | 21 if ((GetCurrentProcess(&this_process) != noErr) || |
22 (GetFrontProcess(&front_process) != noErr)) { | 22 (GetFrontProcess(&front_process) != noErr)) { |
23 return; | 23 return; |
24 } | 24 } |
25 | 25 |
26 Boolean matched = false; | 26 Boolean matched = false; |
27 if ((SameProcess(&this_process, &front_process, &matched) == noErr) && | 27 if ((SameProcess(&this_process, &front_process, &matched) == noErr) && |
28 !matched) { | 28 !matched) { |
29 SetFrontProcess(&this_process); | 29 SetFrontProcess(&this_process); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 __attribute__((visibility("default"))) | 33 __attribute__((visibility("default"))) |
34 OpaquePluginRef GetActiveDelegate() { | 34 OpaquePluginRef GetActiveDelegate() { |
35 return WebPluginDelegateImpl::GetActiveDelegate(); | 35 return webkit::npapi::WebPluginDelegateImpl::GetActiveDelegate(); |
36 } | 36 } |
37 | 37 |
38 __attribute__((visibility("default"))) | 38 __attribute__((visibility("default"))) |
39 void NotifyBrowserOfPluginSelectWindow(uint32 window_id, CGRect bounds, | 39 void NotifyBrowserOfPluginSelectWindow(uint32 window_id, CGRect bounds, |
40 bool modal) { | 40 bool modal) { |
41 PluginThread* plugin_thread = PluginThread::current(); | 41 PluginThread* plugin_thread = PluginThread::current(); |
42 if (plugin_thread) { | 42 if (plugin_thread) { |
43 gfx::Rect window_bounds(bounds); | 43 gfx::Rect window_bounds(bounds); |
44 plugin_thread->Send( | 44 plugin_thread->Send( |
45 new PluginProcessHostMsg_PluginSelectWindow(window_id, window_bounds, | 45 new PluginProcessHostMsg_PluginSelectWindow(window_id, window_bounds, |
(...skipping 19 matching lines...) Loading... |
65 if (plugin_thread) { | 65 if (plugin_thread) { |
66 gfx::Rect window_bounds(bounds); | 66 gfx::Rect window_bounds(bounds); |
67 plugin_thread->Send( | 67 plugin_thread->Send( |
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(OpaquePluginRef delegate, | 73 void NotifyPluginOfSetThemeCursor(OpaquePluginRef delegate, |
74 ThemeCursor cursor) { | 74 ThemeCursor cursor) { |
75 static_cast<WebPluginDelegateImpl*>(delegate)->SetThemeCursor(cursor); | 75 static_cast<webkit::npapi::WebPluginDelegateImpl*>(delegate)->SetThemeCursor( |
| 76 cursor); |
76 } | 77 } |
77 | 78 |
78 __attribute__((visibility("default"))) | 79 __attribute__((visibility("default"))) |
79 void NotifyPluginOfSetCursor(OpaquePluginRef delegate, | 80 void NotifyPluginOfSetCursor(OpaquePluginRef delegate, |
80 const Cursor* cursor) { | 81 const Cursor* cursor) { |
81 static_cast<WebPluginDelegateImpl*>(delegate)->SetCursor(cursor); | 82 static_cast<webkit::npapi::WebPluginDelegateImpl*>(delegate)->SetCursor( |
| 83 cursor); |
82 } | 84 } |
83 | 85 |
84 void NotifyPluginOfSetCursorVisibility(bool visibility) { | 86 void NotifyPluginOfSetCursorVisibility(bool visibility) { |
85 PluginThread* plugin_thread = PluginThread::current(); | 87 PluginThread* plugin_thread = PluginThread::current(); |
86 if (plugin_thread) { | 88 if (plugin_thread) { |
87 plugin_thread->Send( | 89 plugin_thread->Send( |
88 new PluginProcessHostMsg_PluginSetCursorVisibility(visibility)); | 90 new PluginProcessHostMsg_PluginSetCursorVisibility(visibility)); |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 __attribute__((visibility("default"))) | 94 __attribute__((visibility("default"))) |
93 bool GetPluginWindowHasFocus(const OpaquePluginRef delegate) { | 95 bool GetPluginWindowHasFocus(const OpaquePluginRef delegate) { |
94 return static_cast<WebPluginDelegateImpl*>(delegate)->GetWindowHasFocus(); | 96 return static_cast<webkit::npapi::WebPluginDelegateImpl*>( |
| 97 delegate)->GetWindowHasFocus(); |
95 } | 98 } |
96 | 99 |
97 } // namespace mac_plugin_interposing | 100 } // namespace mac_plugin_interposing |
98 | 101 |
99 #pragma mark - | 102 #pragma mark - |
100 | 103 |
101 struct WindowInfo { | 104 struct WindowInfo { |
102 uint32 window_id; | 105 uint32 window_id; |
103 CGRect bounds; | 106 CGRect bounds; |
104 WindowInfo(NSWindow* window) { | 107 WindowInfo(NSWindow* window) { |
(...skipping 125 matching lines...) Loading... |
230 - (void)chromePlugin_set; | 233 - (void)chromePlugin_set; |
231 + (void)chromePlugin_hide; | 234 + (void)chromePlugin_hide; |
232 + (void)chromePlugin_unhide; | 235 + (void)chromePlugin_unhide; |
233 @end | 236 @end |
234 | 237 |
235 @implementation NSCursor (ChromePluginInterposing) | 238 @implementation NSCursor (ChromePluginInterposing) |
236 | 239 |
237 - (void)chromePlugin_set { | 240 - (void)chromePlugin_set { |
238 OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate(); | 241 OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate(); |
239 if (delegate) { | 242 if (delegate) { |
240 static_cast<WebPluginDelegateImpl*>(delegate)->SetNSCursor(self); | 243 static_cast<webkit::npapi::WebPluginDelegateImpl*>(delegate)->SetNSCursor( |
| 244 self); |
241 return; | 245 return; |
242 } | 246 } |
243 [self chromePlugin_set]; | 247 [self chromePlugin_set]; |
244 } | 248 } |
245 | 249 |
246 + (void)chromePlugin_hide { | 250 + (void)chromePlugin_hide { |
247 mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(false); | 251 mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(false); |
248 } | 252 } |
249 | 253 |
250 + (void)chromePlugin_unhide { | 254 + (void)chromePlugin_unhide { |
(...skipping 42 matching lines...) Loading... |
293 Class nscursor_class = [NSCursor class]; | 297 Class nscursor_class = [NSCursor class]; |
294 ExchangeMethods(nscursor_class, NO, @selector(set), | 298 ExchangeMethods(nscursor_class, NO, @selector(set), |
295 @selector(chromePlugin_set)); | 299 @selector(chromePlugin_set)); |
296 ExchangeMethods(nscursor_class, YES, @selector(hide), | 300 ExchangeMethods(nscursor_class, YES, @selector(hide), |
297 @selector(chromePlugin_hide)); | 301 @selector(chromePlugin_hide)); |
298 ExchangeMethods(nscursor_class, YES, @selector(unhide), | 302 ExchangeMethods(nscursor_class, YES, @selector(unhide), |
299 @selector(chromePlugin_unhide)); | 303 @selector(chromePlugin_unhide)); |
300 } | 304 } |
301 | 305 |
302 } // namespace mac_plugin_interposing | 306 } // namespace mac_plugin_interposing |
OLD | NEW |