| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/plugin/plugin_interpose_util_mac.h" | 5 #include "content/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 "content/child/npapi/webplugin_delegate_impl.h" |
| 10 #include "content/common/plugin_process_messages.h" | 11 #include "content/common/plugin_process_messages.h" |
| 11 #include "content/plugin/plugin_thread.h" | 12 #include "content/plugin/plugin_thread.h" |
| 12 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | |
| 13 | 13 |
| 14 using content::PluginThread; | 14 using content::PluginThread; |
| 15 | 15 |
| 16 namespace mac_plugin_interposing { | 16 namespace mac_plugin_interposing { |
| 17 | 17 |
| 18 // TODO(stuartmorgan): Make this an IPC to order the plugin process above the | 18 // TODO(stuartmorgan): Make this an IPC to order the plugin process above the |
| 19 // browser process only if the browser is current frontmost. | 19 // browser process only if the browser is current frontmost. |
| 20 __attribute__((visibility("default"))) | 20 __attribute__((visibility("default"))) |
| 21 void SwitchToPluginProcess() { | 21 void SwitchToPluginProcess() { |
| 22 ProcessSerialNumber this_process, front_process; | 22 ProcessSerialNumber this_process, front_process; |
| 23 if ((GetCurrentProcess(&this_process) != noErr) || | 23 if ((GetCurrentProcess(&this_process) != noErr) || |
| 24 (GetFrontProcess(&front_process) != noErr)) { | 24 (GetFrontProcess(&front_process) != noErr)) { |
| 25 return; | 25 return; |
| 26 } | 26 } |
| 27 | 27 |
| 28 Boolean matched = false; | 28 Boolean matched = false; |
| 29 if ((SameProcess(&this_process, &front_process, &matched) == noErr) && | 29 if ((SameProcess(&this_process, &front_process, &matched) == noErr) && |
| 30 !matched) { | 30 !matched) { |
| 31 SetFrontProcess(&this_process); | 31 SetFrontProcess(&this_process); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 __attribute__((visibility("default"))) | 35 __attribute__((visibility("default"))) |
| 36 OpaquePluginRef GetActiveDelegate() { | 36 OpaquePluginRef GetActiveDelegate() { |
| 37 return webkit::npapi::WebPluginDelegateImpl::GetActiveDelegate(); | 37 return content::WebPluginDelegateImpl::GetActiveDelegate(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 __attribute__((visibility("default"))) | 40 __attribute__((visibility("default"))) |
| 41 void NotifyBrowserOfPluginSelectWindow(uint32 window_id, CGRect bounds, | 41 void NotifyBrowserOfPluginSelectWindow(uint32 window_id, CGRect bounds, |
| 42 bool modal) { | 42 bool modal) { |
| 43 PluginThread* plugin_thread = PluginThread::current(); | 43 PluginThread* plugin_thread = PluginThread::current(); |
| 44 if (plugin_thread) { | 44 if (plugin_thread) { |
| 45 gfx::Rect window_bounds(bounds); | 45 gfx::Rect window_bounds(bounds); |
| 46 plugin_thread->Send( | 46 plugin_thread->Send( |
| 47 new PluginProcessHostMsg_PluginSelectWindow(window_id, window_bounds, | 47 new PluginProcessHostMsg_PluginSelectWindow(window_id, window_bounds, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 - (void)chromePlugin_set; | 204 - (void)chromePlugin_set; |
| 205 + (void)chromePlugin_hide; | 205 + (void)chromePlugin_hide; |
| 206 + (void)chromePlugin_unhide; | 206 + (void)chromePlugin_unhide; |
| 207 @end | 207 @end |
| 208 | 208 |
| 209 @implementation NSCursor (ChromePluginInterposing) | 209 @implementation NSCursor (ChromePluginInterposing) |
| 210 | 210 |
| 211 - (void)chromePlugin_set { | 211 - (void)chromePlugin_set { |
| 212 OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate(); | 212 OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate(); |
| 213 if (delegate) { | 213 if (delegate) { |
| 214 static_cast<webkit::npapi::WebPluginDelegateImpl*>(delegate)->SetNSCursor( | 214 static_cast<content::WebPluginDelegateImpl*>(delegate)->SetNSCursor(self); |
| 215 self); | |
| 216 return; | 215 return; |
| 217 } | 216 } |
| 218 [self chromePlugin_set]; | 217 [self chromePlugin_set]; |
| 219 } | 218 } |
| 220 | 219 |
| 221 + (void)chromePlugin_hide { | 220 + (void)chromePlugin_hide { |
| 222 mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(false); | 221 mac_plugin_interposing::NotifyPluginOfSetCursorVisibility(false); |
| 223 } | 222 } |
| 224 | 223 |
| 225 + (void)chromePlugin_unhide { | 224 + (void)chromePlugin_unhide { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 Class nscursor_class = [NSCursor class]; | 267 Class nscursor_class = [NSCursor class]; |
| 269 ExchangeMethods(nscursor_class, NO, @selector(set), | 268 ExchangeMethods(nscursor_class, NO, @selector(set), |
| 270 @selector(chromePlugin_set)); | 269 @selector(chromePlugin_set)); |
| 271 ExchangeMethods(nscursor_class, YES, @selector(hide), | 270 ExchangeMethods(nscursor_class, YES, @selector(hide), |
| 272 @selector(chromePlugin_hide)); | 271 @selector(chromePlugin_hide)); |
| 273 ExchangeMethods(nscursor_class, YES, @selector(unhide), | 272 ExchangeMethods(nscursor_class, YES, @selector(unhide), |
| 274 @selector(chromePlugin_unhide)); | 273 @selector(chromePlugin_unhide)); |
| 275 } | 274 } |
| 276 | 275 |
| 277 } // namespace mac_plugin_interposing | 276 } // namespace mac_plugin_interposing |
| OLD | NEW |